61 unsigned bytes = (bits + 7) / 8;
62 int last_bits = bits & 7;
76 buf[0] >>= 8 - last_bits;
77 buf[0] |= 1 << (last_bits - 1);
110 px_debug(
"mpi_to_bn: bignum conversion failed: mpi=%d, bn=%d",
130 if (bytes != n->
bytes)
132 px_debug(
"bn_to_mpi: bignum conversion failed: bn=%d, mpi=%d",
160 return p_bits / 10 + 160;
162 return (p_bits / 8 + 200) * 3 / 2;
180 if (!m || !p || !g || !y || !k || !yk || !c1 || !c2)
228 if (!c1 || !c2 || !p || !x || !c1x || !div || !m)
262 if (!m || !e || !n || !c)
290 if (!m || !d || !n || !c)
mp_result mp_int_mul(mp_int a, mp_int b, mp_int c)
mp_result mp_int_invmod(mp_int a, mp_int m, mp_int c)
struct PGP_PubKey::@9::@12 rsa
mp_result mp_int_read_unsigned(mp_int z, unsigned char *buf, int len)
struct PGP_PubKey::@9::@11 elg
mp_result mp_int_to_unsigned(mp_int z, unsigned char *buf, int limit)
mp_result mp_int_mod(mp_int a, mp_int m, mp_int c)
mp_result mp_int_count_bits(mp_int z)
static mpz_t * mpi_to_bn(PGP_MPI *n)
int pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c1_p, PGP_MPI **c2_p)
mp_result mp_int_exptmod(mp_int a, mp_int b, mp_int m, mp_int c)
int pgp_mpi_alloc(int bits, PGP_MPI **mpi)
void mp_int_free(mp_int z)
int px_get_random_bytes(uint8 *dst, unsigned count)
int pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c_p)
mp_result mp_int_init_size(mp_int z, mp_size prec)
int pgp_mpi_free(PGP_MPI *mpi)
static int decide_k_bits(int p_bits)
static PGP_MPI * bn_to_mpi(mpz_t *bn)
void px_debug(const char *fmt,...)
static int mp_px_rand(uint32 bits, mpz_t *res)
static void mp_modmul(mpz_t *a, mpz_t *b, mpz_t *p, mpz_t *res)
int pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, PGP_MPI **msg_p)
#define PXE_PGP_MATH_FAILED
int pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *_c, PGP_MPI **m_p)
mp_int mp_int_alloc(void)
static void mp_clear_free(mpz_t *a)
union PGP_PubKey::@10 sec