pike.git
/
src
/
post_modules
/
Nettle
/
hogweed.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/post_modules/Nettle/hogweed.cmod:32:
memcpy(out, Pike_sp[-1].u.string->str, num); pop_stack(); } #define MAKE_GMP(X,Y) do { push_int(0); \ apply_svalue(&auto_bignum_program, 1); \ Y = Pike_sp[-1].u.object; \ memcpy(&X.Y, get_storage(Y, auto_bignum_program.u.program), sizeof(mpz_t));\ } while(0)
-
/*! @decl array(object(Gmp.mpz)) dsa_generate_keypair(int p_bits, int q_bits, @
-
*!
function(int:string) rnd)
+
/*! @decl array(object(Gmp.mpz))
@
+
*!
dsa_generate_keypair(int p_bits, int q_bits, @
+
*! function(int:string
(0..255
)
)
rnd)
*! *! Generates a DSA key pair with @[p_bits] number of bits (sometimes *! referred to as L) for p, and @[q_bits] number of bits (sometimes *! referred to as N) for q, using the random function @[rnd]. *! *! Valid combinations as per FIPS 186-3 are *! @pre{ *! p_bits q_bits *! 1024 160 *! 2048 224 (rejected by some versions of Hogweed)
pike.git/src/post_modules/Nettle/hogweed.cmod:62:
*! @elem Gmp.mpz 1 *! The value q, the group order. *! @elem Gmp.mpz 2 *! The value g, the generator. *! @elem Gmp.mpz 3 *! The value y, the public value. *! @elem Gmp.mpz 4 *! The value x, the private value. *! @endarray */
-
PIKEFUN array(object(Gmp.mpz)) dsa_generate_keypair(int p_bits, int q_bits,
-
function(int:string) rnd)
+
PIKEFUN array(object(Gmp.mpz))
+
dsa_generate_keypair(int p_bits, int q_bits, function(int:string
(0..255
)
)
rnd)
{ struct dsa_public_key pub; struct object *p, *q, *g, *y; struct dsa_private_key key; struct object *x; MAKE_GMP(pub,p); MAKE_GMP(pub,q); MAKE_GMP(pub,g); MAKE_GMP(pub,y);
pike.git/src/post_modules/Nettle/hogweed.cmod:93:
memcpy(get_storage(q, auto_bignum_program.u.program), &pub.q, sizeof(mpz_t)); memcpy(get_storage(g, auto_bignum_program.u.program), &pub.g, sizeof(mpz_t)); memcpy(get_storage(y, auto_bignum_program.u.program), &pub.y, sizeof(mpz_t)); memcpy(get_storage(x, auto_bignum_program.u.program), &key.x, sizeof(mpz_t)); f_aggregate(5); stack_pop_n_elems_keep_top(3); /* Remove p_bits, q_bits and rnd. */ } /*! @decl array(object(Gmp.mpz)) @
-
*! rsa_generate_keypair(int bits, int e, function(int:string) rnd)
+
*! rsa_generate_keypair(int bits, int e, function(int:string
(0..255
)
)
rnd)
*! *! Generates an RSA key pair with a @[bits] sized modulus (n), using *! the provided value for @[e] and random function @[rnd]. *! *! @returns *! @array *! @elem Gmp.mpz 0 *! The value n, the modulo. *! @elem Gmp.mpz 1 *! The value d, the private exponent. *! @elem Gmp.mpz 2 *! The value p, a prime. *! @elem Gmp.mpz 3 *! The value q, a prime. *! @endarray */ PIKEFUN array(object(Gmp.mpz))
-
rsa_generate_keypair(int bits, int e, function(int:string) rnd)
+
rsa_generate_keypair(int bits, int e, function(int:string
(0..255
)
)
rnd)
{ struct rsa_public_key pub; struct object *n, *_e; struct rsa_private_key key; struct object *d, *p, *q, *a, *b, *c; push_int(e); apply_svalue(&auto_bignum_program, 1); _e = Pike_sp[-1].u.object; memcpy(&pub.e, get_storage(_e, auto_bignum_program.u.program),