#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 }
| int px_find_combo | ( | const char * | name, | |
| PX_Combo ** | res | |||
| ) |
Definition at line 383 of file px.c.
References px_combo::cipher, combo_decrypt(), combo_decrypt_len(), combo_encrypt(), combo_encrypt_len(), combo_free(), combo_init(), cx(), px_combo::decrypt, px_combo::decrypt_len, px_combo::encrypt, px_combo::encrypt_len, error_desc::err, px_combo::free, px_combo::init, NULL, px_combo::padding, parse_cipher_name(), px_alloc, px_cipher_free, px_find_cipher(), px_free, PXE_NO_CIPHER, and s_pad().
Referenced by pg_decrypt(), pg_decrypt_iv(), pg_encrypt(), and pg_encrypt_iv().
00384 { 00385 int err; 00386 char *buf, 00387 *s_cipher, 00388 *s_pad; 00389 00390 PX_Combo *cx; 00391 00392 cx = px_alloc(sizeof(*cx)); 00393 memset(cx, 0, sizeof(*cx)); 00394 00395 buf = px_alloc(strlen(name) + 1); 00396 strcpy(buf, name); 00397 00398 err = parse_cipher_name(buf, &s_cipher, &s_pad); 00399 if (err) 00400 { 00401 px_free(buf); 00402 px_free(cx); 00403 return err; 00404 } 00405 00406 err = px_find_cipher(s_cipher, &cx->cipher); 00407 if (err) 00408 goto err1; 00409 00410 if (s_pad != NULL) 00411 { 00412 if (!strcmp(s_pad, "pkcs")) 00413 cx->padding = 1; 00414 else if (!strcmp(s_pad, "none")) 00415 cx->padding = 0; 00416 else 00417 goto err1; 00418 } 00419 else 00420 cx->padding = 1; 00421 00422 cx->init = combo_init; 00423 cx->encrypt = combo_encrypt; 00424 cx->decrypt = combo_decrypt; 00425 cx->encrypt_len = combo_encrypt_len; 00426 cx->decrypt_len = combo_decrypt_len; 00427 cx->free = combo_free; 00428 00429 px_free(buf); 00430 00431 *res = cx; 00432 00433 return 0; 00434 00435 err1: 00436 if (cx->cipher) 00437 px_cipher_free(cx->cipher); 00438 px_free(cx); 00439 px_free(buf); 00440 return PXE_NO_CIPHER; 00441 }
| int px_find_digest | ( | const char * | name, | |
| PX_MD ** | res | |||
| ) |
Definition at line 580 of file internal.c.
References OSSLDigest::algo, px_digest::block_size, compat_find_digest(), OSSLDigest::ctx, digest_block_size(), digest_finish(), digest_free(), digest_reset(), digest_result_size(), digest_update(), EVP_DigestInit_ex(), EVP_MD_CTX_init(), px_digest::finish, px_digest::free, int_digest::init, int_digest::name, NULL, px_digest::p, pg_strcasecmp(), px_digest::ptr, px_alloc, px_openssl_initialized, PXE_NO_HASH, px_digest::reset, px_digest::result_size, and px_digest::update.
Referenced by add_entropy(), pg_digest(), pgp_load_digest(), px_crypt_md5(), px_find_hmac(), and try_unix_std().
00581 { 00582 const struct int_digest *p; 00583 PX_MD *h; 00584 00585 for (p = int_digest_list; p->name; p++) 00586 if (pg_strcasecmp(p->name, name) == 0) 00587 { 00588 h = px_alloc(sizeof(*h)); 00589 p->init(h); 00590 00591 *res = h; 00592 00593 return 0; 00594 } 00595 return PXE_NO_HASH; 00596 }
| int px_find_hmac | ( | const char * | name, | |
| PX_HMAC ** | res | |||
| ) |
Definition at line 145 of file px-hmac.c.
References px_hmac::block_size, px_hmac::finish, px_hmac::free, hmac_block_size(), hmac_finish(), hmac_free(), hmac_init(), hmac_reset(), hmac_result_size(), hmac_update(), px_hmac::init, px_hmac::ipad, px_hmac::md, px_hmac::opad, px_hmac::p, px_alloc, px_find_digest(), px_md_block_size, px_md_free, PXE_HASH_UNUSABLE_FOR_HMAC, px_hmac::reset, px_hmac::result_size, and px_hmac::update.
Referenced by pg_hmac().
00146 { 00147 int err; 00148 PX_MD *md; 00149 PX_HMAC *h; 00150 unsigned bs; 00151 00152 err = px_find_digest(name, &md); 00153 if (err) 00154 return err; 00155 00156 bs = px_md_block_size(md); 00157 if (bs < 2) 00158 { 00159 px_md_free(md); 00160 return PXE_HASH_UNUSABLE_FOR_HMAC; 00161 } 00162 00163 h = px_alloc(sizeof(*h)); 00164 h->p.ipad = px_alloc(bs); 00165 h->p.opad = px_alloc(bs); 00166 h->md = md; 00167 00168 h->result_size = hmac_result_size; 00169 h->block_size = hmac_block_size; 00170 h->reset = hmac_reset; 00171 h->update = hmac_update; 00172 h->finish = hmac_finish; 00173 h->free = hmac_free; 00174 h->init = hmac_init; 00175 00176 *res = h; 00177 00178 return 0; 00179 }
| int px_get_pseudo_random_bytes | ( | uint8 * | dst, | |
| unsigned | count | |||
| ) |
Definition at line 628 of file internal.c.
References init_openssl_rand(), openssl_random_init, px_get_random_bytes(), and PXE_OSSL_RAND_ERROR.
Referenced by pgp_s2k_fill(), and px_gen_salt().
00629 { 00630 return px_get_random_bytes(dst, count); 00631 }
| int px_get_random_bytes | ( | uint8 * | dst, | |
| unsigned | count | |||
| ) |
Definition at line 676 of file internal.c.
References fortuna_get_bytes(), init_openssl_rand(), openssl_random_init, PXE_OSSL_RAND_ERROR, and system_reseed().
Referenced by add_entropy(), init_sess_key(), mp_px_rand(), pad_eme_pkcs1_v15(), pg_random_bytes(), px_get_pseudo_random_bytes(), system_reseed(), and write_prefix().
00677 { 00678 system_reseed(); 00679 fortuna_get_bytes(count, dst); 00680 return 0; 00681 }
| const char* px_resolve_alias | ( | const PX_Alias * | aliases, | |
| const char * | name | |||
| ) |
Definition at line 109 of file px.c.
References px_alias::alias, px_alias::name, and pg_strcasecmp().
Referenced by px_find_cipher().
00110 { 00111 while (list->name) 00112 { 00113 if (pg_strcasecmp(list->alias, name) == 0) 00114 return list->name; 00115 list++; 00116 } 00117 return name; 00118 }
| void px_set_debug_handler | ( | void(*)(const char *) | handler | ) |
Definition at line 123 of file px.c.
References debug_handler.
Referenced by decrypt_internal(), encrypt_internal(), and init_work().
00124 { 00125 debug_handler = handler; 00126 }
| const char* px_strerror | ( | int | err | ) |
Definition at line 97 of file px.c.
References error_desc::desc, and error_desc::err.
Referenced by decrypt_internal(), encrypt_internal(), find_provider(), init_work(), pg_dearmor(), pg_decrypt(), pg_decrypt_iv(), pg_encrypt(), pg_encrypt_iv(), pg_gen_salt(), pg_gen_salt_rounds(), pg_random_bytes(), and pgp_key_id_w().
00098 { 00099 const struct error_desc *e; 00100 00101 for (e = px_err_list; e->desc; e++) 00102 if (e->err == err) 00103 return e->desc; 00104 return "Bad error code"; 00105 }
1.5.8