src/simplepgp.h
/*
* simplepgp.h
* libsimplepgp
*
* Created by Trevor Bentley on 11/1/11.
*
* Copyright 2011 Trevor Bentley
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
typedef struct spgp_packet_header_struct spgp_pkt_header_t;
typedef struct spgp_packet_struct spgp_packet_t;
typedef struct spgp_mpi_struct spgp_mpi_t;
typedef struct spgp_public_packet_struct spgp_public_pkt_t;
typedef struct spgp_secret_packet_struct spgp_secret_pkt_t;
typedef struct spgp_userid_packet_struct spgp_userid_pkt_t;
typedef struct spgp_session_packet_struct spgp_session_pkt_t;
typedef struct spgp_literal_packet_struct spgp_literal_pkt_t;
typedef struct spgp_signature_packet_struct spgp_signature_pkt_t;
/**
* Initialize simplepgp library
*
* This function MUST be called before calling any other functions in the
* simplepgp library. It initializes global variables and data structures
* that are used throughout the library.
*
* @return 0 on success, non-zero on failure
*/
uint8_t ;
/**
* Call when finished with simplepgp library to free resources.
*
* @return 0 on success, non-zero on failure
*/
uint8_t ;
/**
* Break a binary OpenPGP message into decoded packets.
*
* This is the work-horse function of the library. OpenPGP message, which may
* be keys or encrypted data, are passed into this function. It splits them
* into a linked-list of OpenPGP packets, which can further be manipulated
* by other functions within the library.
*
* Encrypted messages will be decrypted automatically using keys found in the
* in-RAM keychain. See spgp_decrypt_all_secret_keys() for how to load
* a secret key into the keychain.
*
* @param message Binary OpenPGP message to analyze
* @param length Length of |message|
* @return Linked list of decoded PGP packets, or NULL on failure
*/
spgp_packet_t *;
/**
* Decrypt all secret keys found in |msg| with given passphrase.
*
* Call this function after decoding a message known to contain secret keys.
* This function decrypts the secret keys in the packet chain, and stores the
* decrypted keys internally in the in-RAM keychain.
*
* @param msg Linked list of PGP packets
* @param passphrase String to use as decryption passphrase. No NUL termination.
* @param length Length of passphrase.
* @return 0 for success, non-0 for failure.
*/
uint8_t ;
/**
* Gets the literal data buffer from a decrypted message
*
* @param Linked-list of packets to search for data
* @param datalen Set to size of returned data (in bytes)
* @param filename Set to buffer containing filename
* @param filenamelen Set to size of filename (in bytes)
* @return Buffer with literal data, or NULL if none available
*/
char *;
/**
* Frees all dynamic resources associated with |pkt|.
*
* @param pkt Pointer-to-pointer-to-packet to free.
*/
void ;
/**
* Get last error code
*
* @return Value of last error
*/
uint32_t ;
/**
* Return a string describing error code |err|.
*
* @return String describing error code |err|
*/
const char *;
/**
* Return true if debugging enabled, false otherwise.
*
* @return 0 if logging disabled, non-zero if logging enabled.
*/
uint8_t ;
/**
* Enables debug logging to stderr
*
* @param enable 0 if logging should be off, 1 if logging should be on.
*/
void ;