#include <sys/types.h>#include <sys/param.h>


Go to the source code of this file.
Data Structures | |
| struct | px_digest |
| struct | px_alias |
| struct | px_hmac |
| struct | px_cipher |
| struct | px_combo |
Defines | |
| #define | PX_DEBUG |
| #define | px_alloc(s) palloc(s) |
| #define | px_realloc(p, s) repalloc(p, s) |
| #define | px_free(p) pfree(p) |
| #define | PX_MAX_NAMELEN 128 |
| #define | PX_MAX_SALT_LEN 128 |
| #define | PXE_OK 0 |
| #define | PXE_ERR_GENERIC -1 |
| #define | PXE_NO_HASH -2 |
| #define | PXE_NO_CIPHER -3 |
| #define | PXE_NOTBLOCKSIZE -4 |
| #define | PXE_BAD_OPTION -5 |
| #define | PXE_BAD_FORMAT -6 |
| #define | PXE_KEY_TOO_BIG -7 |
| #define | PXE_CIPHER_INIT -8 |
| #define | PXE_HASH_UNUSABLE_FOR_HMAC -9 |
| #define | PXE_DEV_READ_ERROR -10 |
| #define | PXE_OSSL_RAND_ERROR -11 |
| #define | PXE_BUG -12 |
| #define | PXE_ARGUMENT_ERROR -13 |
| #define | PXE_UNKNOWN_SALT_ALGO -14 |
| #define | PXE_BAD_SALT_ROUNDS -15 |
| #define | PXE_MCRYPT_INTERNAL -16 |
| #define | PXE_NO_RANDOM -17 |
| #define | PXE_DECRYPT_FAILED -18 |
| #define | PXE_MBUF_SHORT_READ -50 |
| #define | PXE_PGP_CORRUPT_DATA -100 |
| #define | PXE_PGP_CORRUPT_ARMOR -101 |
| #define | PXE_PGP_UNSUPPORTED_COMPR -102 |
| #define | PXE_PGP_UNSUPPORTED_CIPHER -103 |
| #define | PXE_PGP_UNSUPPORTED_HASH -104 |
| #define | PXE_PGP_COMPRESSION_ERROR -105 |
| #define | PXE_PGP_NOT_TEXT -106 |
| #define | PXE_PGP_UNEXPECTED_PKT -107 |
| #define | PXE_PGP_NO_BIGNUM -108 |
| #define | PXE_PGP_MATH_FAILED -109 |
| #define | PXE_PGP_SHORT_ELGAMAL_KEY -110 |
| #define | PXE_PGP_RSA_UNSUPPORTED -111 |
| #define | PXE_PGP_UNKNOWN_PUBALGO -112 |
| #define | PXE_PGP_WRONG_KEY -113 |
| #define | PXE_PGP_MULTIPLE_KEYS -114 |
| #define | PXE_PGP_EXPECT_PUBLIC_KEY -115 |
| #define | PXE_PGP_EXPECT_SECRET_KEY -116 |
| #define | PXE_PGP_NOT_V4_KEYPKT -117 |
| #define | PXE_PGP_KEYPKT_CORRUPT -118 |
| #define | PXE_PGP_NO_USABLE_KEY -119 |
| #define | PXE_PGP_NEED_SECRET_PSW -120 |
| #define | PXE_PGP_BAD_S2K_MODE -121 |
| #define | PXE_PGP_UNSUPPORTED_PUBALGO -122 |
| #define | PXE_PGP_MULTIPLE_SUBKEYS -123 |
| #define | px_md_result_size(md) (md)->result_size(md) |
| #define | px_md_block_size(md) (md)->block_size(md) |
| #define | px_md_reset(md) (md)->reset(md) |
| #define | px_md_update(md, data, dlen) (md)->update(md, data, dlen) |
| #define | px_md_finish(md, buf) (md)->finish(md, buf) |
| #define | px_md_free(md) (md)->free(md) |
| #define | px_hmac_result_size(hmac) (hmac)->result_size(hmac) |
| #define | px_hmac_block_size(hmac) (hmac)->block_size(hmac) |
| #define | px_hmac_reset(hmac) (hmac)->reset(hmac) |
| #define | px_hmac_init(hmac, key, klen) (hmac)->init(hmac, key, klen) |
| #define | px_hmac_update(hmac, data, dlen) (hmac)->update(hmac, data, dlen) |
| #define | px_hmac_finish(hmac, buf) (hmac)->finish(hmac, buf) |
| #define | px_hmac_free(hmac) (hmac)->free(hmac) |
| #define | px_cipher_key_size(c) (c)->key_size(c) |
| #define | px_cipher_block_size(c) (c)->block_size(c) |
| #define | px_cipher_iv_size(c) (c)->iv_size(c) |
| #define | px_cipher_init(c, k, klen, iv) (c)->init(c, k, klen, iv) |
| #define | px_cipher_encrypt(c, data, dlen, res) (c)->encrypt(c, data, dlen, res) |
| #define | px_cipher_decrypt(c, data, dlen, res) (c)->decrypt(c, data, dlen, res) |
| #define | px_cipher_free(c) (c)->free(c) |
| #define | px_combo_encrypt_len(c, dlen) (c)->encrypt_len(c, dlen) |
| #define | px_combo_decrypt_len(c, dlen) (c)->decrypt_len(c, dlen) |
| #define | px_combo_init(c, key, klen, iv, ivlen) (c)->init(c, key, klen, iv, ivlen) |
| #define | px_combo_encrypt(c, data, dlen, res, rlen) (c)->encrypt(c, data, dlen, res, rlen) |
| #define | px_combo_decrypt(c, data, dlen, res, rlen) (c)->decrypt(c, data, dlen, res, rlen) |
| #define | px_combo_free(c) (c)->free(c) |
Typedefs | |
| typedef struct px_digest | PX_MD |
| typedef struct px_alias | PX_Alias |
| typedef struct px_hmac | PX_HMAC |
| typedef struct px_cipher | PX_Cipher |
| typedef struct px_combo | PX_Combo |
Functions | |
| int | px_find_digest (const char *name, PX_MD **res) |
| int | px_find_hmac (const char *name, PX_HMAC **res) |
| int | px_find_cipher (const char *name, PX_Cipher **res) |
| int | px_find_combo (const char *name, PX_Combo **res) |
| int | px_get_random_bytes (uint8 *dst, unsigned count) |
| int | px_get_pseudo_random_bytes (uint8 *dst, unsigned count) |
| int | px_add_entropy (const uint8 *data, unsigned count) |
| unsigned | px_acquire_system_randomness (uint8 *dst) |
| const char * | px_strerror (int err) |
| const char * | px_resolve_alias (const PX_Alias *aliases, const char *name) |
| void | px_set_debug_handler (void(*handler)(const char *)) |
| void | px_debug (const char *fmt,...) |
| #define px_alloc | ( | s | ) | palloc(s) |
Definition at line 45 of file px.h.
Referenced by bf_load(), combo_encrypt(), combo_init(), compat_find_digest(), create_secmsg(), encrypt_init(), hmac_finish(), hmac_init(), init_md5(), init_sha1(), init_sha224(), init_sha256(), init_sha384(), init_sha512(), mbuf_create(), mbuf_create_from_data(), mdcbuf_init(), mp_int_alloc(), mp_px_rand(), pad_eme_pkcs1_v15(), pgp_cfb_create(), pgp_create_pkt_reader(), pgp_init(), pgp_key_alloc(), pgp_mpi_alloc(), pkt_stream_init(), pullf_create(), pushf_create(), px_find_cipher(), px_find_combo(), px_find_digest(), px_find_hmac(), rj_load(), s_alloc(), and try_unix_std().
| #define px_cipher_block_size | ( | c | ) | (c)->block_size(c) |
Definition at line 229 of file px.h.
Referenced by combo_decrypt(), combo_encrypt(), combo_init(), and pgp_cfb_create().
Definition at line 236 of file px.h.
Referenced by combo_free(), pgp_cfb_create(), pgp_cfb_free(), and px_find_combo().
Definition at line 247 of file px.h.
Referenced by pg_decrypt(), pg_decrypt_iv(), pg_encrypt(), and pg_encrypt_iv().
Definition at line 241 of file px.h.
Referenced by pg_decrypt(), pg_decrypt_iv(), pg_encrypt(), and pg_encrypt_iv().
| #define px_free | ( | p | ) | pfree(p) |
Definition at line 47 of file px.h.
Referenced by combo_encrypt(), combo_free(), combo_init(), create_secmsg(), digest_free(), encrypt_free(), gen_ossl_free(), hmac_finish(), hmac_free(), hmac_init(), int_md5_free(), int_sha1_free(), int_sha224_free(), int_sha256_free(), int_sha384_free(), int_sha512_free(), intctx_free(), mbuf_free(), mdcbuf_free(), mp_int_free(), mp_px_rand(), pad_eme_pkcs1_v15(), pgp_cfb_free(), pgp_create_pkt_reader(), pgp_free(), pgp_key_free(), pgp_mpi_free(), pkt_stream_free(), pktreader_free(), pullf_free(), pushf_free(), px_find_combo(), s_ksqr(), and try_unix_std().
| #define px_hmac_block_size | ( | hmac | ) | (hmac)->block_size(hmac) |
| #define px_hmac_finish | ( | hmac, | |||
| buf | ) | (hmac)->finish(hmac, buf) |
| #define px_hmac_free | ( | hmac | ) | (hmac)->free(hmac) |
| #define px_hmac_init | ( | hmac, | |||
| key, | |||||
| klen | ) | (hmac)->init(hmac, key, klen) |
| #define px_hmac_result_size | ( | hmac | ) | (hmac)->result_size(hmac) |
| #define px_hmac_update | ( | hmac, | |||
| data, | |||||
| dlen | ) | (hmac)->update(hmac, data, dlen) |
| #define px_md_block_size | ( | md | ) | (md)->block_size(md) |
Definition at line 213 of file px.h.
Referenced by calc_s2k_iter_salted(), calc_s2k_salted(), calc_s2k_simple(), hmac_block_size(), hmac_finish(), hmac_free(), hmac_init(), hmac_reset(), and px_find_hmac().
| #define px_md_finish | ( | md, | |||
| buf | ) | (md)->finish(md, buf) |
Definition at line 216 of file px.h.
Referenced by add_block_entropy(), calc_key_id(), calc_s2k_iter_salted(), calc_s2k_salted(), calc_s2k_simple(), check_key_sha1(), hmac_finish(), hmac_init(), mdc_finish(), mdc_flush(), mdcbuf_finish(), pg_digest(), px_crypt_md5(), and try_unix_std().
| #define px_md_free | ( | md | ) | (md)->free(md) |
Definition at line 217 of file px.h.
Referenced by add_entropy(), calc_key_id(), check_key_sha1(), hmac_free(), mdc_free(), mdcbuf_free(), pg_digest(), pgp_s2k_process(), px_crypt_md5(), px_find_hmac(), and try_unix_std().
| #define px_md_reset | ( | md | ) | (md)->reset(md) |
Definition at line 214 of file px.h.
Referenced by add_block_entropy(), calc_s2k_iter_salted(), calc_s2k_salted(), calc_s2k_simple(), hmac_finish(), hmac_init(), hmac_reset(), and px_crypt_md5().
| #define px_md_result_size | ( | md | ) | (md)->result_size(md) |
Definition at line 212 of file px.h.
Referenced by calc_s2k_iter_salted(), calc_s2k_salted(), calc_s2k_simple(), hmac_finish(), hmac_init(), hmac_result_size(), and pg_digest().
| #define px_md_update | ( | md, | |||
| data, | |||||
| dlen | ) | (md)->update(md, data, dlen) |
Definition at line 215 of file px.h.
Referenced by add_block_entropy(), calc_key_id(), calc_s2k_iter_salted(), calc_s2k_salted(), calc_s2k_simple(), hmac_finish(), hmac_init(), hmac_reset(), hmac_update(), mdc_flush(), mdc_read(), mdc_write(), mdcbuf_finish(), mdcbuf_load_data(), pg_digest(), pgp_mpi_hash(), px_crypt_md5(), and try_unix_std().
| #define px_realloc | ( | p, | |||
| s | ) | repalloc(p, s) |
| #define PXE_ARGUMENT_ERROR -13 |
Definition at line 76 of file px.h.
Referenced by parse_args(), pgp_encrypt(), pgp_set_compress_algo(), pgp_set_compress_level(), pgp_set_s2k_mode(), pgp_set_symkey(), and set_arg().
| #define PXE_BAD_FORMAT -6 |
| #define PXE_BAD_OPTION -5 |
| #define PXE_BAD_SALT_ROUNDS -15 |
| #define PXE_BUG -12 |
Definition at line 75 of file px.h.
Referenced by mbuf_append(), mdc_finish(), pad_eme_pkcs1_v15(), pgp_parse_pubenc_sesskey(), pgp_write_pubenc_sesskey(), pkt_stream_process(), prefix_init(), and wrap_process().
| #define PXE_CIPHER_INIT -8 |
| #define PXE_DECRYPT_FAILED -18 |
| #define PXE_HASH_UNUSABLE_FOR_HMAC -9 |
| #define PXE_KEY_TOO_BIG -7 |
Definition at line 70 of file px.h.
Referenced by bf_init(), ossl_aes_init(), ossl_aes_key_init(), and rj_init().
| #define PXE_MBUF_SHORT_READ -50 |
| #define PXE_NO_CIPHER -3 |
| #define PXE_NO_HASH -2 |
| #define PXE_NOTBLOCKSIZE -4 |
Definition at line 67 of file px.h.
Referenced by bf_decrypt(), bf_encrypt(), combo_decrypt(), rj_decrypt(), and rj_encrypt().
| #define PXE_OK 0 |
| #define PXE_OSSL_RAND_ERROR -11 |
Definition at line 74 of file px.h.
Referenced by px_get_pseudo_random_bytes(), and px_get_random_bytes().
| #define PXE_PGP_BAD_S2K_MODE -121 |
Definition at line 106 of file px.h.
Referenced by pgp_s2k_fill(), pgp_s2k_process(), and pgp_s2k_read().
| #define PXE_PGP_CORRUPT_ARMOR -101 |
Definition at line 86 of file px.h.
Referenced by b64_decode(), find_header(), and pgp_armor_decode().
| #define PXE_PGP_CORRUPT_DATA -100 |
Definition at line 85 of file px.h.
Referenced by decrypt_key(), mdc_finish(), mdc_read(), mdcbuf_finish(), parse_compressed_data(), parse_literal_data(), parse_new_len(), parse_old_len(), parse_symenc_mdc_data(), parse_symenc_sesskey(), pgp_decrypt(), pgp_expect_packet_end(), pgp_get_keyid(), pgp_load_cipher(), pgp_load_digest(), pgp_mpi_alloc(), pgp_parse_pkt_hdr(), pgp_parse_pubenc_sesskey(), prefix_init(), and process_data_packets().
| #define PXE_PGP_EXPECT_PUBLIC_KEY -115 |
| #define PXE_PGP_EXPECT_SECRET_KEY -116 |
| #define PXE_PGP_KEYPKT_CORRUPT -118 |
Definition at line 103 of file px.h.
Referenced by check_key_cksum(), check_key_sha1(), and process_secret_key().
| #define PXE_PGP_MATH_FAILED -109 |
Definition at line 94 of file px.h.
Referenced by pgp_elgamal_decrypt(), pgp_elgamal_encrypt(), pgp_rsa_decrypt(), and pgp_rsa_encrypt().
| #define PXE_PGP_MULTIPLE_KEYS -114 |
| #define PXE_PGP_MULTIPLE_SUBKEYS -123 |
| #define PXE_PGP_NEED_SECRET_PSW -120 |
| #define PXE_PGP_NO_USABLE_KEY -119 |
| #define PXE_PGP_NOT_TEXT -106 |
| #define PXE_PGP_NOT_V4_KEYPKT -117 |
| #define PXE_PGP_UNEXPECTED_PKT -107 |
| #define PXE_PGP_UNKNOWN_PUBALGO -112 |
Definition at line 97 of file px.h.
Referenced by _pgp_read_public_key(), and pgp_parse_pubenc_sesskey().
| #define PXE_PGP_UNSUPPORTED_CIPHER -103 |
Definition at line 88 of file px.h.
Referenced by pgp_get_cipher_code(), pgp_load_cipher(), pgp_s2k_process(), and process_secret_key().
| #define PXE_PGP_UNSUPPORTED_COMPR -102 |
Definition at line 87 of file px.h.
Referenced by parse_compressed_data(), pgp_compress_filter(), and pgp_decompress_filter().
| #define PXE_PGP_UNSUPPORTED_HASH -104 |
| #define PXE_PGP_WRONG_KEY -113 |
Definition at line 98 of file px.h.
Referenced by control_cksum(), decrypt_elgamal(), decrypt_rsa(), and pgp_parse_pubenc_sesskey().
| #define PXE_UNKNOWN_SALT_ALGO -14 |
| unsigned px_acquire_system_randomness | ( | uint8 * | dst | ) |
Definition at line 227 of file random.c.
References try_unix_std().
Referenced by system_reseed().
00228 { 00229 uint8 *p = dst; 00230 00231 #ifdef TRY_DEV_RANDOM 00232 p = try_dev_random(p); 00233 #endif 00234 #ifdef TRY_WIN32_GENRAND 00235 p = try_win32_genrand(p); 00236 #endif 00237 #ifdef TRY_WIN32_PERFC 00238 p = try_win32_perfc(p); 00239 #endif 00240 #ifdef TRY_UNIXSTD 00241 p = try_unix_std(p); 00242 #endif 00243 return p - dst; 00244 }
| int px_add_entropy | ( | const uint8 * | data, | |
| unsigned | count | |||
| ) |
Definition at line 684 of file internal.c.
References fortuna_add_entropy(), and system_reseed().
Referenced by add_block_entropy().
00685 { 00686 system_reseed(); 00687 fortuna_add_entropy(data, count); 00688 return 0; 00689 }
| void px_debug | ( | const char * | fmt, | |
| ... | ||||
| ) |
Definition at line 129 of file px.c.
References debug_handler, and vsnprintf().
Referenced by _pgp_read_public_key(), bn_to_mpi(), check_key_cksum(), check_key_sha1(), control_cksum(), decrypt_key(), internal_read_key(), mbuf_append(), mdc_finish(), mdc_read(), mdcbuf_finish(), mpi_to_bn(), parse_compressed_data(), parse_literal_data(), parse_new_len(), parse_old_len(), parse_symenc_mdc_data(), parse_symenc_sesskey(), pgp_decrypt(), pgp_expect_packet_end(), pgp_mpi_alloc(), pgp_parse_pkt_hdr(), pgp_parse_pubenc_sesskey(), pgp_write_pubenc_sesskey(), prefix_init(), process_data_packets(), process_secret_key(), and pullf_read_fixed().
00130 { 00131 va_list ap; 00132 00133 va_start(ap, fmt); 00134 if (debug_handler) 00135 { 00136 char buf[512]; 00137 00138 vsnprintf(buf, sizeof(buf), fmt, ap); 00139 debug_handler(buf); 00140 } 00141 va_end(ap); 00142 }
| int px_find_cipher | ( | const char * | name, | |
| PX_Cipher ** | res | |||
| ) |
Definition at line 599 of file internal.c.
References px_cipher::block_size, ossl_cipher_lookup::ciph, ossldata::ciph, ossl_cipher::decrypt, px_cipher::decrypt, ossl_cipher::encrypt, px_cipher::encrypt, px_cipher::free, gen_ossl_block_size(), gen_ossl_free(), gen_ossl_iv_size(), gen_ossl_key_size(), i, ossl_cipher::init, px_cipher::init, px_cipher::iv_size, px_cipher::key_size, int_cipher::load, ossl_cipher_lookup::name, int_cipher::name, NULL, px_cipher::ptr, px_alloc, px_resolve_alias(), and PXE_NO_CIPHER.
Referenced by pgp_load_cipher(), and px_find_combo().
00600 { 00601 int i; 00602 PX_Cipher *c = NULL; 00603 00604 name = px_resolve_alias(int_aliases, name); 00605 00606 for (i = 0; int_ciphers[i].name; i++) 00607 if (!strcmp(int_ciphers[i].name, name)) 00608 { 00609 c = int_ciphers[i].load(); 00610 break; 00611 } 00612 00613 if (c == NULL) 00614 return PXE_NO_CIPHER; 00615 00616 *res = c; 00617 return 0; 00618 }