![]() |
![]() |
![]() |
GNU TLS API Reference Manual | ![]() |
---|---|---|---|---|
#define OPENCDK_VERSION #define OPENCDK_VERSION_MAJOR #define OPENCDK_VERSION_MINOR #define OPENCDK_VERSION_PATCH struct cdk_ctx_s; typedef cdk_ctx_t; struct cdk_strlist_s; typedef cdk_strlist_t; struct cdk_listkey_s; typedef cdk_listkey_t; struct cdk_dek_s; typedef cdk_dek_t; struct cdk_s2k_s; typedef cdk_s2k_t; struct cdk_stream_s; typedef cdk_stream_t; struct cdk_prefitem_s; typedef cdk_prefitem_t; struct cdk_kbnode_s; typedef cdk_kbnode_t; struct cdk_keydb_hd_s; typedef cdk_keydb_hd_t; struct cdk_keylist_s; typedef cdk_keylist_t; struct cdk_subpkt_s; typedef cdk_subpkt_t; struct cdk_keygen_ctx_s; typedef cdk_keygen_ctx_t; struct cdk_desig_revoker_s; typedef cdk_desig_revoker_t; typedef cdk_mpi_t; enum cdk_error_t; enum cdk_key_flags_t; enum cdk_lit_format_t; enum cdk_packet_type_t; #define MAX_CDK_PK_PARTS #define MAX_CDK_DATA_PARTS typedef cdk_pkt_signature_t; typedef cdk_pkt_userid_t; typedef cdk_pkt_pubkey_t; typedef cdk_pubkey_t; typedef cdk_pkt_seckey_t; typedef cdk_seckey_t; typedef cdk_pkt_onepass_sig_t; typedef cdk_pkt_pubkey_enc_t; typedef cdk_pkt_symkey_enc_t; typedef cdk_pkt_encrypted_t; typedef cdk_pkt_mdc_t; typedef cdk_pkt_literal_t; typedef cdk_pkt_compressed_t; typedef cdk_packet_t; void (*cdk_log_fnc_t) (void *, ..., const char *, va_list ); void cdk_set_log_level (int lvl); void cdk_set_log_handler (cdk_log_fnc_t logfnc, void *opaque); const char* cdk_strerror (int ec); void cdk_set_malloc_hooks (void* (new_alloc_funcsize_t n) (), void* (new_alloc_secure_funcsize_t n) (), void* (new_realloc_funcvoid *p, size_t n) (), void* (new_calloc_funcsize_t m, size_t n) (), void (new_free_funcvoid *) ()); int cdk_malloc_hook_initialized (void); void* cdk_malloc (size_t size); void* cdk_calloc (size_t n, size_t m); void* cdk_realloc (void *ptr, size_t size); void* cdk_salloc (size_t size, int clear); char* cdk_strdup (const char *ptr); void cdk_free (void *ptr); void cdk_lib_startup (void); void cdk_lib_shutdown (void); cdk_error_t cdk_handle_new (cdk_ctx_t *r_ctx); void cdk_handle_free (cdk_ctx_t c); void cdk_handle_set_keydb (cdk_ctx_t hd, cdk_keydb_hd_t db); cdk_error_t cdk_handle_set_keyring (cdk_ctx_t hd, int type, const char *kringname); cdk_keydb_hd_t cdk_handle_get_keydb (cdk_ctx_t hd, int type); int cdk_handle_control (cdk_ctx_t hd, int action, int cmd, ...); void cdk_handle_set_passphrase_cb (cdk_ctx_t hd, char* (cbvoid *opa, const char *prompt) (), void *cb_value); #define cdk_handle_set_armor (a, val) #define cdk_handle_set_compress (a, algo, level) #define cdk_handle_set_blockmode (a, val) #define cdk_handle_set_cipher (a, val) #define cdk_handle_set_digest (a, val) #define cdk_handle_set_s2k (a, val1, val2) typedef cdk_verify_result_t; cdk_verify_result_t cdk_handle_verify_get_result (cdk_ctx_t hd); cdk_error_t cdk_pkt_new (cdk_packet_t *r_pkt); cdk_error_t cdk_pkt_alloc (cdk_packet_t *r_pkt, int pkttype); void cdk_pkt_free (cdk_packet_t pkt); void cdk_pkt_release (cdk_packet_t pkt); cdk_error_t cdk_pkt_read (cdk_stream_t inp, cdk_packet_t pkt); cdk_error_t cdk_pkt_write (cdk_stream_t out, cdk_packet_t pkt); cdk_subpkt_t cdk_subpkt_new (size_t size); void cdk_subpkt_free (cdk_subpkt_t ctx); cdk_subpkt_t cdk_subpkt_find (cdk_subpkt_t ctx, size_t type); cdk_subpkt_t cdk_subpkt_find_next (cdk_subpkt_t root, size_t type); size_t cdk_subpkt_type_count (cdk_subpkt_t ctx, size_t type); cdk_subpkt_t cdk_subpkt_find_nth (cdk_subpkt_t ctx, size_t type, size_t index); cdk_error_t cdk_subpkt_add (cdk_subpkt_t root, cdk_subpkt_t node); const unsigned char* cdk_subpkt_get_data (cdk_subpkt_t ctx, size_t *r_type, size_t *r_nbytes); void cdk_subpkt_init (cdk_subpkt_t node, size_t type, const void *buf, size_t buflen); const unsigned char* cdk_key_desig_revoker_walk (cdk_desig_revoker_t root, cdk_desig_revoker_t *ctx, int *r_class, int *r_algid); #define is_RSA (a) #define is_ELG (a) #define is_DSA (a) cdk_error_t cdk_pk_encrypt (cdk_pubkey_t pk, cdk_pkt_pubkey_enc_t pke, gcry_mpi_t sk); cdk_error_t cdk_pk_decrypt (cdk_seckey_t sk, cdk_pkt_pubkey_enc_t pke, gcry_mpi_t *r_sk); cdk_error_t cdk_pk_sign (cdk_seckey_t sk, cdk_pkt_signature_t sig, unsigned char *md); cdk_error_t cdk_pk_verify (cdk_pubkey_t pk, cdk_pkt_signature_t sig, unsigned char *md); cdk_error_t cdk_pk_get_mpi (cdk_pubkey_t pk, size_t idx, unsigned char *buf, size_t buflen, size_t *r_nwritten, size_t *r_nbits); cdk_error_t cdk_sk_get_mpi (cdk_seckey_t sk, size_t idx, unsigned char *buf, size_t buflen, size_t *r_nwritten, size_t *r_nbits); int cdk_pk_get_nbits (cdk_pubkey_t pk); int cdk_pk_get_npkey (int algo); int cdk_pk_get_nskey (int algo); int cdk_pk_get_nsig (int algo); int cdk_pk_get_nenc (int algo); cdk_error_t cdk_pk_get_fingerprint (cdk_pubkey_t pk, unsigned char *fpr); cdk_error_t cdk_pk_to_fingerprint (cdk_pubkey_t pk, unsigned char *fpr, size_t fprlen, size_t *r_nout); unsigned int cdk_pk_fingerprint_get_keyid (unsigned char *fpr, size_t fprlen, unsigned int *keyid); unsigned int cdk_pk_get_keyid (cdk_pubkey_t pk, unsigned int *keyid); unsigned int cdk_sk_get_keyid (cdk_seckey_t sk, unsigned int *keyid); unsigned int cdk_sig_get_keyid (cdk_pkt_signature_t sig, unsigned int *keyid); void cdk_pk_release (cdk_pubkey_t pk); void cdk_sk_release (cdk_seckey_t sk); cdk_error_t cdk_sk_unprotect (cdk_seckey_t sk, const char *pw); cdk_error_t cdk_sk_protect (cdk_seckey_t sk, const char *pw); cdk_error_t cdk_pk_from_secret_key (cdk_seckey_t sk, cdk_pubkey_t *ret_pk); cdk_error_t cdk_pubkey_to_sexp (cdk_pubkey_t pk, char **sexp, size_t *len); cdk_error_t cdk_seckey_to_sexp (cdk_seckey_t sk, char **sexp, size_t *len); cdk_error_t cdk_dek_new (cdk_dek_t *r_dek); void cdk_dek_free (cdk_dek_t dek); cdk_error_t cdk_dek_set_cipher (cdk_dek_t dek, int cipher_algo); cdk_error_t cdk_dek_get_cipher (cdk_dek_t dek, int *r_cipher_algo); cdk_error_t cdk_dek_set_key (cdk_dek_t dek, unsigned char *key, size_t keylen); void cdk_dek_set_mdc_flag (cdk_dek_t dek, int val); int cdk_dek_get_mdc_flag (cdk_dek_t dek); cdk_error_t cdk_dek_from_passphrase (cdk_dek_t *ret_dek, int cipher_algo, cdk_s2k_t s2k, int rndsalt, const char *passphrase); cdk_error_t cdk_s2k_new (cdk_s2k_t *ret_s2k, int mode, int digest_algo, unsigned char *salt); void cdk_s2k_free (cdk_s2k_t s2k); cdk_error_t cdk_file_armor (cdk_ctx_t hd, const char *file, const char *output); cdk_error_t cdk_file_dearmor (const char *file, const char *output); int cdk_armor_filter_use (cdk_stream_t inp); cdk_error_t cdk_armor_encode_buffer (unsigned char *inbuf, size_t inlen, char *outbuf, size_t outlen, size_t *nwritten, int type); cdk_error_t open (void *); cdk_error_t release (void *); int read (void *, void *buf, size_t ); int write (void *, const void *buf, size_t ); int seek (void *, off_t ); typedef cdk_stream_cbs_t; int cdk_stream_is_compressed (cdk_stream_t s); cdk_error_t cdk_stream_sockopen (const char *host, unsigned short port, cdk_stream_t *ret_out); cdk_error_t cdk_stream_open (const char *file, cdk_stream_t *ret_s); cdk_error_t cdk_stream_new (const char *file, cdk_stream_t *ret_s); cdk_error_t cdk_stream_new_from_cbs (cdk_stream_cbs_t cbs, void *opa, cdk_stream_t *ret_s); cdk_error_t cdk_stream_create (const char *file, cdk_stream_t *ret_s); cdk_error_t cdk_stream_tmp_new (cdk_stream_t *r_out); cdk_error_t cdk_stream_tmp_from_mem (const void *buf, size_t buflen, cdk_stream_t *r_out); void cdk_stream_tmp_set_mode (cdk_stream_t s, int val); cdk_error_t cdk_stream_flush (cdk_stream_t s); cdk_error_t cdk_stream_enable_cache (cdk_stream_t s, int val); cdk_error_t cdk_stream_filter_disable (cdk_stream_t s, int type); cdk_error_t cdk_stream_close (cdk_stream_t s); off_t cdk_stream_get_length (cdk_stream_t s); int cdk_stream_read (cdk_stream_t s, void *buf, size_t count); int cdk_stream_write (cdk_stream_t s, const void *buf, size_t count); int cdk_stream_putc (cdk_stream_t s, int c); int cdk_stream_getc (cdk_stream_t s); int cdk_stream_eof (cdk_stream_t s); off_t cdk_stream_tell (cdk_stream_t s); cdk_error_t cdk_stream_seek (cdk_stream_t s, off_t offset); cdk_error_t cdk_stream_set_armor_flag (cdk_stream_t s, int type); cdk_error_t cdk_stream_set_literal_flag (cdk_stream_t s, cdk_lit_format_t mode, const char *fname); cdk_error_t cdk_stream_set_cipher_flag (cdk_stream_t s, cdk_dek_t dek, int use_mdc); cdk_error_t cdk_stream_set_compress_flag (cdk_stream_t s, int algo, int level); cdk_error_t cdk_stream_set_hash_flag (cdk_stream_t s, int algo); cdk_error_t cdk_stream_set_text_flag (cdk_stream_t s, const char *lf); cdk_error_t cdk_stream_kick_off (cdk_stream_t inp, cdk_stream_t out); cdk_error_t cdk_stream_mmap (cdk_stream_t s, unsigned char **ret_buf, size_t *ret_buflen); cdk_error_t cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len, unsigned char **ret_buf, size_t *ret_buflen); int cdk_stream_peek (cdk_stream_t inp, unsigned char *buf, size_t buflen); cdk_error_t cdk_keydb_new (cdk_keydb_hd_t *r_hd, int type, void *data, size_t count); cdk_error_t cdk_keydb_new_from_mem (cdk_keydb_hd_t *r_hd, int secret, const void *data, size_t datlen); cdk_error_t cdk_keydb_new_from_file (cdk_keydb_hd_t *r_hd, int secret, const char *fname); cdk_error_t cdk_keydb_new_from_stream (cdk_keydb_hd_t *r_hd, int secret, cdk_stream_t in); cdk_error_t cdk_keydb_check_sk (cdk_keydb_hd_t hd, unsigned int *keyid); cdk_error_t cdk_keydb_search_start (cdk_keydb_hd_t hd, int type, void *desc); cdk_error_t cdk_keydb_search (cdk_keydb_hd_t hd, cdk_kbnode_t *ret_key); void cdk_keydb_free (cdk_keydb_hd_t hd); cdk_error_t cdk_keydb_get_bykeyid (cdk_keydb_hd_t hd, unsigned int *keyid, cdk_kbnode_t *ret_pk); cdk_error_t cdk_keydb_get_byfpr (cdk_keydb_hd_t hd, unsigned char *fpr, cdk_kbnode_t *ret_pk); cdk_error_t cdk_keydb_get_bypattern (cdk_keydb_hd_t hd, const char *patt, cdk_kbnode_t *ret_pk); cdk_error_t cdk_keydb_get_pk (cdk_keydb_hd_t khd, unsigned int *keyid, cdk_pubkey_t *ret_pk); cdk_error_t cdk_keydb_get_sk (cdk_keydb_hd_t khd, unsigned int *keyid, cdk_seckey_t *ret_sk); cdk_error_t cdk_keydb_get_keyblock (cdk_stream_t inp, cdk_kbnode_t *ret_key); cdk_error_t cdk_keydb_idx_rebuild (cdk_keydb_hd_t hd); cdk_error_t cdk_keydb_export (cdk_keydb_hd_t hd, cdk_stream_t out, cdk_strlist_t remusr); cdk_error_t cdk_keydb_import (cdk_keydb_hd_t hd, cdk_kbnode_t knode); cdk_error_t cdk_listkey_start (cdk_listkey_t *r_ctx, cdk_keydb_hd_t db, const char *patt, cdk_strlist_t fpatt); void cdk_listkey_close (cdk_listkey_t ctx); cdk_error_t cdk_listkey_next (cdk_listkey_t ctx, cdk_kbnode_t *ret_key); cdk_kbnode_t cdk_kbnode_new (cdk_packet_t pkt); cdk_error_t cdk_kbnode_read_from_mem (cdk_kbnode_t *ret_node, unsigned char *buf, size_t buflen); cdk_error_t cdk_kbnode_write_to_mem (cdk_kbnode_t node, unsigned char *buf, size_t *r_nbytes); cdk_error_t cdk_kbnode_write_to_mem_alloc (cdk_kbnode_t node, unsigned char **r_buf, size_t *r_buflen); void cdk_kbnode_release (cdk_kbnode_t node); cdk_kbnode_t cdk_kbnode_walk (cdk_kbnode_t root, cdk_kbnode_t *ctx, int all); cdk_packet_t cdk_kbnode_find_packet (cdk_kbnode_t node, int pkttype); cdk_packet_t cdk_kbnode_get_packet (cdk_kbnode_t node); cdk_kbnode_t cdk_kbnode_find (cdk_kbnode_t node, int pkttype); cdk_kbnode_t cdk_kbnode_find_prev (cdk_kbnode_t root, cdk_kbnode_t node, int pkttype); cdk_kbnode_t cdk_kbnode_find_next (cdk_kbnode_t node, int pkttype); cdk_error_t cdk_kbnode_hash (cdk_kbnode_t node, gcry_md_hd_t md, int is_v4, int pkttype, int flags); cdk_error_t cdk_pk_check_sigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int *r_status); cdk_error_t cdk_pk_check_self_sig (cdk_kbnode_t knode, int *r_status); int cdk_pklist_select_algo (cdk_keylist_t pkl, int preftype); int cdk_pklist_use_mdc (cdk_keylist_t pkl); cdk_error_t cdk_pklist_build (cdk_keylist_t *ret_pkl, cdk_keydb_hd_t hd, cdk_strlist_t remusr, int use); void cdk_pklist_release (cdk_keylist_t pkl); cdk_error_t cdk_pklist_encrypt (cdk_keylist_t pkl, cdk_dek_t dek, cdk_stream_t out); cdk_error_t cdk_sklist_build (cdk_keylist_t *ret_skl, cdk_keydb_hd_t db, cdk_ctx_t hd, cdk_strlist_t locusr, int unlock, unsigned int use); void cdk_sklist_release (cdk_keylist_t skl); cdk_error_t cdk_sklist_write (cdk_keylist_t skl, cdk_stream_t outp, gcry_md_hd_t mdctx, int sigclass, int sigver); cdk_error_t cdk_sklist_write_onepass (cdk_keylist_t skl, cdk_stream_t outp, int sigclass, int mdalgo); cdk_error_t cdk_stream_encrypt (cdk_ctx_t hd, cdk_strlist_t remusr, cdk_stream_t inp, cdk_stream_t out); cdk_error_t cdk_stream_decrypt (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t out); cdk_error_t cdk_file_encrypt (cdk_ctx_t hd, cdk_strlist_t remusr, const char *file, const char *output); cdk_error_t cdk_file_decrypt (cdk_ctx_t hd, const char *file, const char *output); cdk_error_t cdk_data_transform (cdk_ctx_t hd, enum cdk_crypto_mode_t mode, cdk_strlist_t locusr, cdk_strlist_t remusr, const void *inbuf, size_t insize, unsigned char **outbuf, size_t *outsize, int modval); cdk_error_t cdk_stream_sign (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t out, cdk_strlist_t locusr, cdk_strlist_t remusr, int encryptflag, int sigmode); cdk_error_t cdk_file_sign (cdk_ctx_t hd, cdk_strlist_t locusr, cdk_strlist_t remusr, const char *file, const char *output, int sigmode, int encryptflag); cdk_error_t cdk_stream_verify (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t data, cdk_stream_t out); cdk_error_t cdk_file_verify (cdk_ctx_t hd, const char *file, const char *data_file, const char *output); int cdk_trustdb_get_validity (cdk_stream_t inp, cdk_pkt_userid_t id, int *r_val); int cdk_trustdb_get_ownertrust (cdk_stream_t inp, cdk_pubkey_t pk, int *r_val, int *r_flags); void cdk_strlist_free (cdk_strlist_t sl); cdk_strlist_t cdk_strlist_add (cdk_strlist_t *list, const char *string); cdk_strlist_t cdk_strlist_next (cdk_strlist_t root, const char **r_str); const char* cdk_check_version (const char *req_version); char* cdk_utf8_encode (const char *string); char* cdk_utf8_decode (const char *string, size_t length, int delim); cdk_error_t cdk_keyserver_recv_key (const char *host, int port, unsigned char *keyid, int kid_type, cdk_kbnode_t *r_key); cdk_error_t cdk_keygen_new (cdk_keygen_ctx_t *r_hd); void cdk_keygen_free (cdk_keygen_ctx_t hd); cdk_error_t cdk_keygen_set_prefs (cdk_keygen_ctx_t hd, enum cdk_pref_type_t type, unsigned char *array, size_t n); cdk_error_t cdk_keygen_set_algo_info (cdk_keygen_ctx_t hd, int type, int usage, enum cdk_pubkey_algo_t algo, unsigned int bits); int cdk_keygen_set_keyserver_flags (cdk_keygen_ctx_t hd, int no_modify, const char *pref_url); int cdk_keygen_set_expire_date (cdk_keygen_ctx_t hd, int type, long timestamp ); void cdk_keygen_set_name (cdk_keygen_ctx_t hd, const char *name); void cdk_keygen_set_passphrase (cdk_keygen_ctx_t hd, const char *pass); cdk_error_t cdk_keygen_start (cdk_keygen_ctx_t hd); cdk_error_t cdk_keygen_save (cdk_keygen_ctx_t hd, const char *pubf, const char *secf);
typedef enum { CDK_EOF = -1, CDK_Success = 0, CDK_General_Error = 1, CDK_File_Error = 2, CDK_Bad_Sig = 3, CDK_Inv_Packet = 4, CDK_Inv_Algo = 5, CDK_Not_Implemented = 6, CDK_Armor_Error = 8, CDK_Armor_CRC_Error = 9, CDK_MPI_Error = 10, CDK_Inv_Value = 11, CDK_Error_No_Key = 12, CDK_Chksum_Error = 13, CDK_Time_Conflict = 14, CDK_Zlib_Error = 15, CDK_Weak_Key = 16, CDK_Out_Of_Core = 17, CDK_Wrong_Seckey = 18, CDK_Bad_MDC = 19, CDK_Inv_Mode = 20, CDK_Error_No_Keyring = 21, CDK_Wrong_Format = 22, CDK_Inv_Packet_Ver = 23, CDK_Too_Short = 24, CDK_Unusable_Key = 25, CDK_No_Data = 26, CDK_No_Passphrase = 27, CDK_Network_Error = 28 } cdk_error_t;
typedef enum { CDK_FLAG_KEY_REVOKED = 256, CDK_FLAG_KEY_EXPIRED = 512, CDK_FLAG_SIG_EXPIRED = 1024 } cdk_key_flags_t;
typedef enum { CDK_LITFMT_BINARY = 0, CDK_LITFMT_TEXT = 1, CDK_LITFMT_UNICODE= 2 } cdk_lit_format_t;
typedef enum { CDK_PKT_RESERVED = 0, CDK_PKT_PUBKEY_ENC = 1, CDK_PKT_SIGNATURE = 2, CDK_PKT_SYMKEY_ENC = 3, CDK_PKT_ONEPASS_SIG = 4, CDK_PKT_SECRET_KEY = 5, CDK_PKT_PUBLIC_KEY = 6, CDK_PKT_SECRET_SUBKEY = 7, CDK_PKT_COMPRESSED = 8, CDK_PKT_ENCRYPTED = 9, CDK_PKT_MARKER = 10, CDK_PKT_LITERAL = 11, CDK_PKT_RING_TRUST = 12, CDK_PKT_USER_ID = 13, CDK_PKT_PUBLIC_SUBKEY = 14, CDK_PKT_OLD_COMMENT = 16, CDK_PKT_ATTRIBUTE = 17, CDK_PKT_ENCRYPTED_MDC = 18, CDK_PKT_MDC = 19 } cdk_packet_type_t;
void (*cdk_log_fnc_t) (void *, ..., const char *, va_list );
|
|
|
|
|
|
|
void cdk_set_log_handler (cdk_log_fnc_t logfnc, void *opaque);
Set a custom handler for logging.
|
the function pointer |
|
a private values for the function |
const char* cdk_strerror (int ec);
Return an error text for the given id.
|
the error number |
Returns : |
void cdk_set_malloc_hooks (void* (new_alloc_funcsize_t n) (), void* (new_alloc_secure_funcsize_t n) (), void* (new_realloc_funcvoid *p, size_t n) (), void* (new_calloc_funcsize_t m, size_t n) (), void (new_free_funcvoid *) ());
Set private memory hooks for the library.
|
malloc replacement |
|
secure malloc replacement |
|
realloc replacement |
|
calloc replacement |
|
free replacement |
int cdk_malloc_hook_initialized (void);
Return if the malloc hooks are already initialized.
Returns : |
void* cdk_calloc (size_t n, size_t m);
Safe wrapper around the c-function calloc.
|
amount of elements |
|
size of one element |
Returns : |
void* cdk_salloc (size_t size, int clear);
Allocated the requested amount of bytes in 'secure' memory.
|
how much bytes should be allocated. |
|
shall the buffer cleared after the allocation? |
Returns : |
void cdk_lib_startup (void);
Prepare the internal structures of the library. This function should be called before any other CDK function.
void cdk_lib_shutdown (void);
Shutdown the library and free all internal and globally used memory and structures. This function should be called in the exit handler of the calling program.
cdk_error_t cdk_handle_new (cdk_ctx_t *r_ctx);
create a new session handle.
|
context to store the handle |
Returns : |
void cdk_handle_set_keydb (cdk_ctx_t hd, cdk_keydb_hd_t db);
set the key database handle. the function automatically detects whether this is a public or secret keyring and the right handle is set.
|
session handle |
|
the database handle |
cdk_error_t cdk_handle_set_keyring (cdk_ctx_t hd, int type, const char *kringname);
Convenient function to set the keyring for the current session.
|
session handle |
|
public=0 or secret=1 keyring type |
|
file name of the keyring which shall be used. |
Returns : |
cdk_keydb_hd_t cdk_handle_get_keydb (cdk_ctx_t hd, int type);
Return the keydb handle from the session handle. The caller should not free these handles.
|
session handle |
|
type of the keyring |
Returns : |
int cdk_handle_control (cdk_ctx_t hd, int action, int cmd, ...);
Perform various control operations for the current session.
|
session handle |
|
flag which indicates whether put or get is requested |
|
command id |
|
|
Returns : |
void cdk_handle_set_passphrase_cb (cdk_ctx_t hd, char* (cbvoid *opa, const char *prompt) (), void *cb_value);
set the passphrase callback.
|
session handle |
|
callback function |
|
the opaque value for the cb function |
cdk_verify_result_t cdk_handle_verify_get_result (cdk_ctx_t hd);
Return the verify result for the current session. Do not free the pointer.
|
the session handle |
Returns : |
cdk_error_t cdk_pkt_alloc (cdk_packet_t *r_pkt, int pkttype);
Allocate a new packet structure with the given packet type.
|
output is the new packet |
|
the requested packet type |
Returns : |
void cdk_pkt_release (cdk_packet_t pkt);
Free the contents of the given package and release the memory of the structure.
|
the packet |
cdk_error_t cdk_pkt_read (cdk_stream_t inp, cdk_packet_t pkt);
Parse the next packet on the inp
stream and return its contents in pkt
.
|
the input stream |
|
allocated packet handle to store the packet |
Returns : |
cdk_error_t cdk_pkt_write (cdk_stream_t out, cdk_packet_t pkt);
Write the contents of pkt
into the out
stream.
Return 0 on success.
|
the output stream handle |
|
the packet itself |
Returns : |
cdk_subpkt_t cdk_subpkt_new (size_t size);
Create a new sub packet node with the size of size
.
|
the size of the new context |
Returns : |
void cdk_subpkt_free (cdk_subpkt_t ctx);
Release the context.
|
the sub packet node to free |
cdk_subpkt_t cdk_subpkt_find (cdk_subpkt_t ctx, size_t type);
Find the given packet type in the node. If no packet with this type was found, return null otherwise pointer to the node.
|
the sub packet node |
|
the packet type to find |
Returns : |
cdk_subpkt_t cdk_subpkt_find_next (cdk_subpkt_t root, size_t type);
Try to find the next node after root
with type.
If type is 0, the next node will be returned.
|
the base where to begin the iteration |
|
the type to find or 0 for the next node. |
Returns : |
size_t cdk_subpkt_type_count (cdk_subpkt_t ctx, size_t type);
Return the amount of sub packets with this type.
|
The sub packet context |
|
The sub packet type. |
Returns : |
cdk_subpkt_t cdk_subpkt_find_nth (cdk_subpkt_t ctx, size_t type, size_t index);
Return the nth sub packet of the given type.
|
The sub packet context |
|
The sub packet type |
|
The nth packet to retrieve, 0 means the first |
Returns : |
cdk_error_t cdk_subpkt_add (cdk_subpkt_t root, cdk_subpkt_t node);
Add the node in node
to the root node root
.
|
the root node |
|
the node to add |
Returns : |
const unsigned char* cdk_subpkt_get_data (cdk_subpkt_t ctx, size_t *r_type, size_t *r_nbytes);
Extract the data from the given sub packet. The type is returned
in r_type
and the size in r_nbytes
.
|
the sub packet node |
|
pointer store the packet type |
|
pointer to store the packet size |
Returns : |
void cdk_subpkt_init (cdk_subpkt_t node, size_t type, const void *buf, size_t buflen);
Set the packet data of the given root and set the type of it.
|
the sub packet node |
|
type of the packet which data should be initialized |
|
the buffer with the actual data |
|
the size of the data |
const unsigned char* cdk_key_desig_revoker_walk (cdk_desig_revoker_t root, cdk_desig_revoker_t *ctx, int *r_class, int *r_algid);
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_pk_encrypt (cdk_pubkey_t pk, cdk_pkt_pubkey_enc_t pke, gcry_mpi_t sk);
Encrypt the session key in esk
and write its encrypted content
into the pke
struct.
|
the public key |
|
the public key encrypted packet |
|
|
Returns : |
cdk_error_t cdk_pk_decrypt (cdk_seckey_t sk, cdk_pkt_pubkey_enc_t pke, gcry_mpi_t *r_sk);
Decrypt the encrypted session key from pke
into r_sk
.
|
the secret key |
|
public key encrypted packet |
|
the object to store the plain session key |
Returns : |
cdk_error_t cdk_pk_sign (cdk_seckey_t sk, cdk_pkt_signature_t sig, unsigned char *md);
Sign the message digest from md
and write the result into sig
.
|
secret key |
|
signature |
|
the message digest |
Returns : |
cdk_error_t cdk_pk_verify (cdk_pubkey_t pk, cdk_pkt_signature_t sig, unsigned char *md);
Verify the signature in sig
and compare it with the message digest in md
.
|
the public key |
|
signature |
|
the message digest |
Returns : |
cdk_error_t cdk_pk_get_mpi (cdk_pubkey_t pk, size_t idx, unsigned char *buf, size_t buflen, size_t *r_nwritten, size_t *r_nbits);
Return the MPI with the given index of the public key.
|
public key |
|
index of the MPI to retrieve |
|
buffer to hold the raw data |
|
|
|
output how large the raw data is |
|
size of the MPI in bits. |
Returns : |
cdk_error_t cdk_sk_get_mpi (cdk_seckey_t sk, size_t idx, unsigned char *buf, size_t buflen, size_t *r_nwritten, size_t *r_nbits);
Return the MPI of the given secret key with the
index idx
. It is important to check if the key
is protected and thus no real MPI data will be returned then.
|
secret key |
|
index of the MPI to retrieve |
|
buffer to hold the raw data |
|
|
|
output length of the raw data |
|
length of the MPI data in bits. |
Returns : |
int cdk_pk_get_nbits (cdk_pubkey_t pk);
Return the number of MPIs a signature consists of.
|
|
Returns : |
int cdk_pk_get_npkey (int algo);
Return the number of multiprecison integer forming an public key with the given algorithm.
|
The public key algorithm. |
Returns : |
int cdk_pk_get_nskey (int algo);
Return the number of multiprecision integers forming an secret key with the given algorithm.
|
the public key algorithm |
Returns : |
int cdk_pk_get_nenc (int algo);
Return the number of MPI's the encrypted data consists of.
|
the public key algorithm |
Returns : |
cdk_error_t cdk_pk_get_fingerprint (cdk_pubkey_t pk, unsigned char *fpr);
Return the fingerprint of the given public key.
The buffer must be at least 20 octets.
This function should be considered deprecated and
the new cdk_pk_to_fingerprint()
should be used whenever
possible to avoid overflows.
|
the public key |
|
the buffer to hold the fingerprint |
Returns : |
cdk_error_t cdk_pk_to_fingerprint (cdk_pubkey_t pk, unsigned char *fpr, size_t fprlen, size_t *r_nout);
Calculate a fingerprint of the given key and return it in the given byte array.
|
the public key |
|
|
|
|
|
actual length of the fingerprint. |
Returns : |
unsigned int cdk_pk_fingerprint_get_keyid (unsigned char *fpr, size_t fprlen, unsigned int *keyid);
Derive the key ID from the key fingerprint. For version 3 keys, this is not working.
|
the key fingerprint |
|
the length of the fingerprint |
|
|
Returns : |
unsigned int cdk_pk_get_keyid (cdk_pubkey_t pk, unsigned int *keyid);
Calculate the key ID of the given public key.
|
the public key |
|
buffer to store the key ID |
Returns : |
unsigned int cdk_sk_get_keyid (cdk_seckey_t sk, unsigned int *keyid);
Calculate the key ID of the secret key, actually the public key.
|
the secret key |
|
buffer to hold the key ID |
Returns : |
unsigned int cdk_sig_get_keyid (cdk_pkt_signature_t sig, unsigned int *keyid);
Retrieve the key ID from the given signature.
|
the signature |
|
buffer to hold the key ID |
Returns : |
cdk_error_t cdk_sk_unprotect (cdk_seckey_t sk, const char *pw);
Unprotect the given secret key with the passphrase.
|
the secret key |
|
the passphrase |
Returns : |
cdk_error_t cdk_sk_protect (cdk_seckey_t sk, const char *pw);
Protect the given secret key with a passphrase.
|
the secret key |
|
the passphrase to use |
Returns : |
cdk_error_t cdk_pk_from_secret_key (cdk_seckey_t sk, cdk_pubkey_t *ret_pk);
Create a new public key from a secret key.
|
the secret key |
|
the new public key |
Returns : |
cdk_error_t cdk_pubkey_to_sexp (cdk_pubkey_t pk, char **sexp, size_t *len);
Convert a public key to an S-expression. sexp is allocated by this
function, but you have to cdk_free()
it yourself. The S-expression
is stored in canonical format as used by libgcrypt
(GCRYSEXP_FMT_CANON).
|
the public key |
|
where to store the S-expression |
|
the length of sexp |
Returns : |
cdk_error_t cdk_seckey_to_sexp (cdk_seckey_t sk, char **sexp, size_t *len);
Convert a public key to an S-expression. sexp is allocated by this
function, but you have to cdk_free()
it yourself. The S-expression
is stored in canonical format as used by libgcrypt
(GCRYSEXP_FMT_CANON).
|
the secret key |
|
where to store the S-expression |
|
the length of sexp |
Returns : |
cdk_error_t cdk_dek_new (cdk_dek_t *r_dek);
Create a new DEK object.
|
the new DEK object |
Returns : |
cdk_error_t cdk_dek_set_cipher (cdk_dek_t dek, int cipher_algo);
Set the cipher for the given DEK object.
|
the DEK object |
|
|
Returns : |
cdk_error_t cdk_dek_get_cipher (cdk_dek_t dek, int *r_cipher_algo);
|
|
|
|
Returns : |
cdk_error_t cdk_dek_set_key (cdk_dek_t dek, unsigned char *key, size_t keylen);
Set the random session key for the given DEK object.
If key
and keylen
is NULL (0) a random key will be generated.
In any case, cdk_dek_set_cipher must be called first.
|
the DEK object |
|
the random session key |
|
the length of the session key. |
Returns : |
void cdk_dek_set_mdc_flag (cdk_dek_t dek, int val);
Enable or disable the MDC flag for the given DEK object.
|
the DEK object |
|
value to enable or disable the use |
cdk_error_t cdk_dek_from_passphrase (cdk_dek_t *ret_dek, int cipher_algo, cdk_s2k_t s2k, int rndsalt, const char *passphrase);
Transform a passphrase into a DEK object.
|
the new DEK. |
|
symmetric key algorithm to use |
|
the S2K to use |
|
1=create random salt |
|
|
Returns : |
cdk_error_t cdk_s2k_new (cdk_s2k_t *ret_s2k, int mode, int digest_algo, unsigned char *salt);
Create a new S2K object with the given parameter.
The salt
parameter must be always 8 octets.
|
output for the new S2K object |
|
the S2K mode (simple, salted, iter+salted) |
|
the hash algorithm |
|
random salt |
Returns : |
void cdk_s2k_free (cdk_s2k_t s2k);
Release the given S2K object.
|
the S2K object |
cdk_error_t cdk_file_armor (cdk_ctx_t hd, const char *file, const char *output);
Protect a file with ASCII armor.
|
Handle |
|
Name of the file to protect. |
|
Output filename. |
Returns : |
cdk_error_t cdk_file_dearmor (const char *file, const char *output);
Remove ASCII armor from a file.
|
Name of the file to unprotect. |
|
Output filename. |
Returns : |
int cdk_armor_filter_use (cdk_stream_t inp);
Check if the stream contains armored data.
|
the stream to check |
Returns : |
cdk_error_t cdk_armor_encode_buffer (unsigned char *inbuf, size_t inlen, char *outbuf, size_t outlen, size_t *nwritten, int type);
Encode the given buffer into base64 format.
|
the raw input buffer |
|
raw buffer len |
|
the destination buffer for the base64 output |
|
destination buffer len |
|
actual length of the base64 data |
|
the base64 file type. |
Returns : |
int cdk_stream_is_compressed (cdk_stream_t s);
Return 0 if the stream is uncompressed, otherwise the compression algorithm.
|
the stream |
Returns : |
cdk_error_t cdk_stream_sockopen (const char *host, unsigned short port, cdk_stream_t *ret_out);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_stream_open (const char *file, cdk_stream_t *ret_s);
Create a new stream based on an existing file. The stream is opened in read-only mode.
|
The file to open |
|
The new STREAM object |
Returns : |
cdk_error_t cdk_stream_new (const char *file, cdk_stream_t *ret_s);
|
The name of the new file |
|
The new STREAM object |
Returns : |
cdk_error_t cdk_stream_new_from_cbs (cdk_stream_cbs_t cbs, void *opa, cdk_stream_t *ret_s);
This function creates a stream which uses user callback for the core operations (open, close, read, write, seek).
|
the callback context with all user callback functions |
|
opaque handle which is passed to all callbacks. |
|
the allocated stream |
Returns : |
cdk_error_t cdk_stream_create (const char *file, cdk_stream_t *ret_s);
The difference to cdk_stream_new is, that no filtering can be used with this kind of stream and everything is written directly to the stream.
|
the filename |
|
the object |
Returns : |
cdk_error_t cdk_stream_tmp_new (cdk_stream_t *r_out);
Allocate a new tempory stream which is not associated with a file.
|
the new temp stream. |
Returns : |
cdk_error_t cdk_stream_tmp_from_mem (const void *buf, size_t buflen, cdk_stream_t *r_out);
Create a new tempory stream with the given contests.
|
the buffer which shall be written to the temp stream. |
|
how large the buffer is |
|
the new stream with the given contents. |
Returns : |
cdk_error_t cdk_stream_enable_cache (cdk_stream_t s, int val);
Enable or disable the cache section of a stream object.
|
the stream object |
|
1=on, 0=off |
Returns : |
cdk_error_t cdk_stream_filter_disable (cdk_stream_t s, int type);
|
The STREAM object |
|
The numberic filter ID. |
Returns : |
cdk_error_t cdk_stream_close (cdk_stream_t s);
This function work different for read or write streams. When the stream is for reading, the filtering is already done and we can simply close the file and all buffers. But for the case it's a write stream, we need to apply all registered filters now. The file is closed in the filter function and not here.
|
The STREAM object. |
Returns : |
off_t cdk_stream_get_length (cdk_stream_t s);
This function should work for both read and write streams. For write streams an additional flush is used to write possible pending data.
|
The STREAM object. |
Returns : |
int cdk_stream_read (cdk_stream_t s, void *buf, size_t count);
When this function is called the first time, it can take a while because all filters need to be processed. Please remember that you need to add the filters in reserved order.
|
The STREAM object. |
|
The buffer to insert the readed bytes. |
|
Request so much bytes. |
Returns : |
int cdk_stream_write (cdk_stream_t s, const void *buf, size_t count);
In this function we simply write the bytes to the stream. We can't use the filters here because it would mean they have to support partial flushing.
|
The STREAM object |
|
The buffer with the values to write. |
|
The size of the buffer. |
Returns : |
int cdk_stream_eof (cdk_stream_t s);
This function will only work with read streams.
|
The STREAM object. |
Returns : |
cdk_error_t cdk_stream_seek (cdk_stream_t s, off_t offset);
|
|
|
|
Returns : |
cdk_error_t cdk_stream_set_armor_flag (cdk_stream_t s, int type);
If the file is in read-mode, no armor type needs to be
defined (armor_type=0) because the armor filter will be
used for decoding existing armor data.
For the write mode, armor_type
can be set to any valid
armor type (message, key, sig).
|
the stream object |
|
the type of armor to use |
Returns : |
cdk_error_t cdk_stream_set_literal_flag (cdk_stream_t s, cdk_lit_format_t mode, const char *fname);
In read mode it kicks off the literal decoding routine to
unwrap the data from the packet. The mode
parameter is ignored.
In write mode the function can be used to wrap the stream data
into a literal packet with the given mode and file name.
|
the stream object |
|
the mode to use (binary, text, unicode) |
|
the file name to store in the packet. |
Returns : |
cdk_error_t cdk_stream_set_cipher_flag (cdk_stream_t s, cdk_dek_t dek, int use_mdc);
In read mode it kicks off the cipher filter to decrypt the data
from the stream with the key given in dek
.
In write mode the stream data will be encrypted with the DEK object
and optionally, the use_mdc
parameter can be used to enable the MDC mode.
|
the stream object |
|
the data encryption key |
|
1 means to use the MDC mode |
Returns : |
cdk_error_t cdk_stream_set_compress_flag (cdk_stream_t s, int algo, int level);
In read mode it kicks off the decompression filter to retrieve the uncompressed data. In write mode the stream data will be compressed with the given algorithm at the given level.
|
the stream object |
|
the compression algo |
|
level of compression (0..9) |
Returns : |
cdk_error_t cdk_stream_set_hash_flag (cdk_stream_t s, int algo);
This is for read-only streams. It pushes a digest filter to calculate the digest of the given stream data.
|
the stream object |
|
|
Returns : |
cdk_error_t cdk_stream_set_text_flag (cdk_stream_t s, const char *lf);
Pushes the text filter to store the stream data in cannoncial format.
|
the stream object |
|
line ending |
Returns : |
cdk_error_t cdk_stream_kick_off (cdk_stream_t inp, cdk_stream_t out);
Passes the entire data from inp
into the output stream out
with all the activated filters.
|
the input stream |
|
the output stream. |
Returns : |
cdk_error_t cdk_stream_mmap (cdk_stream_t s, unsigned char **ret_buf, size_t *ret_buflen);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len, unsigned char **ret_buf, size_t *ret_buflen);
Map the data of the given stream into a memory section. ret_count
contains the length of the buffer.
|
the stream |
|
the offset where to start |
|
how much bytes shall be mapped |
|
the buffer to store the content |
|
length of the buffer |
Returns : |
int cdk_stream_peek (cdk_stream_t inp, unsigned char *buf, size_t buflen);
The function acts like cdk_stream_read with the difference that the file pointer is moved to the old position after the bytes were read.
|
the input stream handle |
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_new (cdk_keydb_hd_t *r_hd, int type, void *data, size_t count);
Create a new keydb object
|
handle to store the new keydb object |
|
type of the keyring |
|
data which depends on the keyring type |
|
length of the data |
Returns : |
cdk_error_t cdk_keydb_new_from_mem (cdk_keydb_hd_t *r_hd, int secret, const void *data, size_t datlen);
Create a new keyring db handle from the contents of a buffer.
|
The keydb output handle. |
|
|
|
The raw key data. |
|
The length of the raw data. |
Returns : |
cdk_error_t cdk_keydb_new_from_file (cdk_keydb_hd_t *r_hd, int secret, const char *fname);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_new_from_stream (cdk_keydb_hd_t *r_hd, int secret, cdk_stream_t in);
This function creates a new keydb handle based on the given
stream. The stream is not closed in cdk_keydb_free()
and it
is up to the caller to close it. No decoding is done.
|
the output keydb handle |
|
does the stream contain secret key data |
|
the input stream to use |
Returns : |
cdk_error_t cdk_keydb_check_sk (cdk_keydb_hd_t hd, unsigned int *keyid);
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_search_start (cdk_keydb_hd_t hd, int type, void *desc);
Create a new keydb search object.
|
|
|
specifies the search type |
|
description which depends on the type |
Returns : |
cdk_error_t cdk_keydb_search (cdk_keydb_hd_t hd, cdk_kbnode_t *ret_key);
Search for a key in the given keyring. The search mode is handled
via ks
. If the key was found, ret_key
contains the key data.
|
the keydb object |
|
kbnode object to store the key |
Returns : |
void cdk_keydb_free (cdk_keydb_hd_t hd);
Free the keydb object.
|
the keydb object |
cdk_error_t cdk_keydb_get_bykeyid (cdk_keydb_hd_t hd, unsigned int *keyid, cdk_kbnode_t *ret_pk);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_get_byfpr (cdk_keydb_hd_t hd, unsigned char *fpr, cdk_kbnode_t *ret_pk);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_get_bypattern (cdk_keydb_hd_t hd, const char *patt, cdk_kbnode_t *ret_pk);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_get_pk (cdk_keydb_hd_t khd, unsigned int *keyid, cdk_pubkey_t *ret_pk);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_get_sk (cdk_keydb_hd_t khd, unsigned int *keyid, cdk_seckey_t *ret_sk);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_get_keyblock (cdk_stream_t inp, cdk_kbnode_t *ret_key);
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_idx_rebuild (cdk_keydb_hd_t hd);
Rebuild the key index files for the given key database.
|
key database handle |
Returns : |
cdk_error_t cdk_keydb_export (cdk_keydb_hd_t hd, cdk_stream_t out, cdk_strlist_t remusr);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keydb_import (cdk_keydb_hd_t hd, cdk_kbnode_t knode);
|
|
|
|
Returns : |
cdk_error_t cdk_listkey_start (cdk_listkey_t *r_ctx, cdk_keydb_hd_t db, const char *patt, cdk_strlist_t fpatt);
Prepare a key listing with the given parameters. Two modes are supported. The first mode uses string pattern to determine if the key should be returned or not. The other mode uses a string list to request the key which should be listed.
|
pointer to store the new context |
|
the key database handle |
|
string pattern |
|
recipients from a stringlist to show |
Returns : |
void cdk_listkey_close (cdk_listkey_t ctx);
Free the list key context.
|
the list key context |
cdk_error_t cdk_listkey_next (cdk_listkey_t ctx, cdk_kbnode_t *ret_key);
Retrieve the next key from the pattern of the key list context.
|
list key context |
|
|
Returns : |
cdk_kbnode_t cdk_kbnode_new (cdk_packet_t pkt);
Allocate a new key node and add the packet.
|
the packet to add |
Returns : |
cdk_error_t cdk_kbnode_read_from_mem (cdk_kbnode_t *ret_node, unsigned char *buf, size_t buflen);
Try to read a key node from the memory buffer buf
.
|
the new key node |
|
the buffer which stores the key sequence |
|
the length of the buffer |
Returns : |
cdk_error_t cdk_kbnode_write_to_mem (cdk_kbnode_t node, unsigned char *buf, size_t *r_nbytes);
Try to write the contents of the key node to the buffer buf
and
return the length of it in r_nbytes
. If buf is zero, only the
length of the node is calculated and returned in r_nbytes
.
Whenever it is possible, the cdk_kbnode_write_to_mem_alloc should be used.
|
the key node |
|
the buffer to store the node data |
|
the new length of the buffer. |
Returns : |
cdk_error_t cdk_kbnode_write_to_mem_alloc (cdk_kbnode_t node, unsigned char **r_buf, size_t *r_buflen);
The function acts similar to cdk_kbnode_write_to_mem but it allocates the buffer to avoid the lengthy second run.
|
the key node |
|
buffer to hold the raw data |
|
buffer length of the allocated raw data. |
Returns : |
void cdk_kbnode_release (cdk_kbnode_t node);
Release the memory of the node.
|
cdk_kbnode_t cdk_kbnode_walk (cdk_kbnode_t root, cdk_kbnode_t *ctx, int all);
|
|
|
|
|
|
Returns : |
cdk_packet_t cdk_kbnode_find_packet (cdk_kbnode_t node, int pkttype);
Same as cdk_kbnode_find but it returns the packet instead of the node.
|
the key node |
|
packet type |
Returns : |
cdk_packet_t cdk_kbnode_get_packet (cdk_kbnode_t node);
Return the packet which is stored inside the node in node
.
|
the key node |
Returns : |
cdk_kbnode_t cdk_kbnode_find (cdk_kbnode_t node, int pkttype);
Try to find the next node with the packettype pkttype
.
|
the key node |
|
packet type |
Returns : |
cdk_kbnode_t cdk_kbnode_find_prev (cdk_kbnode_t root, cdk_kbnode_t node, int pkttype);
Find the previous node (if pkttype
= 0) or the previous node
with pkttype pkttype
in the list starting with root
of node
.
|
the root key node |
|
the key node |
|
packet type |
Returns : |
cdk_kbnode_t cdk_kbnode_find_next (cdk_kbnode_t node, int pkttype);
Ditto, but find the next packet. The behaviour is trivial if
pkttype
is 0 but if it is specified, the next node with a packet
of this type is returned. The function has some knowledge about
the valid ordering of packets: e.g. if the next signature packet
is requested, the function will not return one if it encounters
a user-id.
|
the key node |
|
packet type |
Returns : |
cdk_error_t cdk_kbnode_hash (cdk_kbnode_t node, gcry_md_hd_t md, int is_v4, int pkttype, int flags);
Hash the key node contents. Two modes are supported. If the packet type is used (!= 0) then the function searches the first node with this type. Otherwise the node is seen as a single node and the type is extracted from it.
|
the key node |
|
|
|
OpenPGP signature (yes=1, no=0) |
|
packet type to hash (if zero use the packet type from the node) |
|
flags which depend on the operation |
Returns : |
cdk_error_t cdk_pk_check_sigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int *r_status);
Check all signatures. When no key is available for checking, the
sigstat is marked as 'NOKEY'. The r_status
contains the key flags
which are or-ed or zero when there are no flags.
|
the key node |
|
an optinal key database handle |
|
variable to store the status of the key |
Returns : |
cdk_error_t cdk_pk_check_self_sig (cdk_kbnode_t knode, int *r_status);
A convenient function to make sure the key is valid. Valid means the self signature is ok.
|
the key node |
|
output the status of the key. |
Returns : |
int cdk_pklist_select_algo (cdk_keylist_t pkl, int preftype);
|
|
|
|
Returns : |
cdk_error_t cdk_pklist_build (cdk_keylist_t *ret_pkl, cdk_keydb_hd_t hd, cdk_strlist_t remusr, int use);
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_pklist_encrypt (cdk_keylist_t pkl, cdk_dek_t dek, cdk_stream_t out);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_sklist_build (cdk_keylist_t *ret_skl, cdk_keydb_hd_t db, cdk_ctx_t hd, cdk_strlist_t locusr, int unlock, unsigned int use);
|
|
|
|
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_sklist_write (cdk_keylist_t skl, cdk_stream_t outp, gcry_md_hd_t mdctx, int sigclass, int sigver);
|
|
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_sklist_write_onepass (cdk_keylist_t skl, cdk_stream_t outp, int sigclass, int mdalgo);
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_stream_encrypt (cdk_ctx_t hd, cdk_strlist_t remusr, cdk_stream_t inp, cdk_stream_t out);
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_stream_decrypt (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t out);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_file_encrypt (cdk_ctx_t hd, cdk_strlist_t remusr, const char *file, const char *output);
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_file_decrypt (cdk_ctx_t hd, const char *file, const char *output);
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_data_transform (cdk_ctx_t hd, enum cdk_crypto_mode_t mode, cdk_strlist_t locusr, cdk_strlist_t remusr, const void *inbuf, size_t insize, unsigned char **outbuf, size_t *outsize, int modval);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_stream_sign (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t out, cdk_strlist_t locusr, cdk_strlist_t remusr, int encryptflag, int sigmode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_file_sign (cdk_ctx_t hd, cdk_strlist_t locusr, cdk_strlist_t remusr, const char *file, const char *output, int sigmode, int encryptflag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_stream_verify (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t data, cdk_stream_t out);
|
session handle |
|
the input stream |
|
for detached signatures, this is the data stream inp is the sig
|
|
where the output shall be written. |
Returns : |
cdk_error_t cdk_file_verify (cdk_ctx_t hd, const char *file, const char *data_file, const char *output);
Verify a signature.
|
the session handle |
|
the input file |
|
for detached signature this is the data file and file is the sig.
|
|
the output file |
Returns : |
int cdk_trustdb_get_validity (cdk_stream_t inp, cdk_pkt_userid_t id, int *r_val);
|
|
|
|
|
|
Returns : |
int cdk_trustdb_get_ownertrust (cdk_stream_t inp, cdk_pubkey_t pk, int *r_val, int *r_flags);
|
|
|
|
|
|
|
|
Returns : |
void cdk_strlist_free (cdk_strlist_t sl);
Release the string list object.
|
the string list |
cdk_strlist_t cdk_strlist_add (cdk_strlist_t *list, const char *string);
Add the given list to the string list.
|
destination string list |
|
the string to add |
Returns : |
cdk_strlist_t cdk_strlist_next (cdk_strlist_t root, const char **r_str);
Return the next string list node from root
. The optional
argument r_str
return the data of the current (!) node.
|
the opaque string list. |
|
optional argument to store the string data. |
Returns : |
const char* cdk_check_version (const char *req_version);
Check that the the version of the library is at minimum the requested one and return the version string; return NULL if the condition is not satisfied. If a NULL is passed to this function, no check is done, but the version string is simply returned.
|
The requested version |
Returns : |
char* cdk_utf8_encode (const char *string);
Encode the given string in utf8 and return it.
|
|
Returns : |
char* cdk_utf8_decode (const char *string, size_t length, int delim);
Decode the given utf8 string and return the native representation.
|
the string to decode |
|
the length of the string |
|
the delimiter |
Returns : |
cdk_error_t cdk_keyserver_recv_key (const char *host, int port, unsigned char *keyid, int kid_type, cdk_kbnode_t *r_key);
|
|
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keygen_set_prefs (cdk_keygen_ctx_t hd, enum cdk_pref_type_t type, unsigned char *array, size_t n);
|
|
|
|
|
|
|
|
Returns : |
cdk_error_t cdk_keygen_set_algo_info (cdk_keygen_ctx_t hd, int type, int usage, enum cdk_pubkey_algo_t algo, unsigned int bits);
|
|
|
|
|
|
|
|
|
|
Returns : |
int cdk_keygen_set_keyserver_flags (cdk_keygen_ctx_t hd, int no_modify, const char *pref_url);
|
|
|
|
|
|
Returns : |
int cdk_keygen_set_expire_date (cdk_keygen_ctx_t hd, int type, long timestamp );
|
|
|
|
|
|
Returns : |
void cdk_keygen_set_name (cdk_keygen_ctx_t hd, const char *name);
|
|
|
void cdk_keygen_set_passphrase (cdk_keygen_ctx_t hd, const char *pass);
|
|
|
cdk_error_t cdk_keygen_save (cdk_keygen_ctx_t hd, const char *pubf, const char *secf);
|
|
|
|
|
|
Returns : |