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:33:
if(TYPEOF(Pike_sp[-1])!=T_STRING) Pike_error("Random function did not return string value.\n"); if(Pike_sp[-1].u.string->len != (unsigned int)num) Pike_error("Random function did not return correct number of bytes.\n"); memcpy(out, Pike_sp[-1].u.string->str, num); pop_stack(); } /*! @decl array(object(Gmp.mpz)) @ *! dsa_generate_keypair(int p_bits, int q_bits, @
-
*! function(int:string(0..255)) rnd)
+
*! function(int
(0..)
: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:63:
*! 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(0..255)) rnd)
+
dsa_generate_keypair(int p_bits, int q_bits, function(int
(0..)
:string(0..255)) rnd)
{ struct dsa_public_key pub; struct dsa_private_key key; dsa_public_key_init(&pub); dsa_private_key_init(&key); if( !nettle_dsa_generate_keypair(&pub, &key, rnd, random_func_wrapper, NULL, NULL, p_bits #ifdef HAVE_DSA_QBITS_KEYPAIR_ARG
pike.git/src/post_modules/Nettle/hogweed.cmod:99:
dsa_private_key_clear(&key); dsa_public_key_clear(&pub); f_aggregate(5); stack_pop_n_elems_keep_top(args); /* Remove p_bits, q_bits and rnd. */ } /*! @decl array(object(Gmp.mpz)) @ *! rsa_generate_keypair(int bits, int e, @
-
*! function(int:string(0..255)) rnd)
+
*! function(int
(0..)
: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(0..255)) rnd)
+
rsa_generate_keypair(int bits, int e, function(int
(0..)
:string(0..255)) rnd)
{ struct rsa_public_key pub; struct rsa_private_key key; rsa_public_key_init(&pub); rsa_private_key_init(&key); mpz_set_ui((MP_INT *)&pub.e, e); if( !nettle_rsa_generate_keypair(&pub, &key, rnd, random_func_wrapper,
pike.git/src/post_modules/Nettle/hogweed.cmod:239:
/*! @decl int size() *! *! @returns *! Returns the size in bits for a single coordinate on the curve. */ PIKEFUN int size() { push_int(THIS->field_size); }
-
/*! @decl Gmp.mpz new_scalar(function(int:string(8bit)) rnd)
+
/*! @decl Gmp.mpz new_scalar(function(int
(0..)
:string(8bit)) rnd)
*! *! @param rnd *! Randomness function to use as source. *! *! @returns *! Returns a random scalar suitable to use as an @[ECDSA] private key *! or as an ECDH exponent. */
-
PIKEFUN object(Gmp.mpz) new_scalar(function(int:string(8bit)) rnd)
+
PIKEFUN object(Gmp.mpz) new_scalar(function(int
(0..)
:string(8bit)) rnd)
{ struct ecc_scalar s; struct object *ret; if (!THIS->curve) Pike_error("No curve defined.\n"); ecc_scalar_init(&s, THIS->curve); ecc_scalar_random(&s, rnd, random_func_wrapper);
pike.git/src/post_modules/Nettle/hogweed.cmod:378:
PIKECLASS ECDSA program_flags PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT; { /*! @decl inherit __builtin.Nettle.Sign */ INHERIT "__builtin.Nettle.Sign"; CVAR struct ecc_scalar key; CVAR struct ecc_point pub;
-
PIKEVAR function(int:string(0..255)) random
+
PIKEVAR function(int
(0..)
:string(0..255)) random
flags ID_PROTECTED; INIT { const struct ecc_curve *curve = (((const struct Nettle_ECC_Curve_struct *)parent_storage(1))->curve); if (!curve) Pike_error("No curve selected.\n"); ecc_point_init(&THIS->pub, curve); ecc_scalar_init(&THIS->key, curve); push_constant_text("Crypto.Random.random_string");
pike.git/src/post_modules/Nettle/hogweed.cmod:503:
{ convert_svalue_to_bignum(x); convert_svalue_to_bignum(y); if (!ecc_point_set(&THIS->pub, (mpz_srcptr)x->u.object->storage, (mpz_srcptr)y->u.object->storage)) { SIMPLE_ARG_ERROR("set_point", 1, "Invalid point on curve."); } }
-
/*! @decl void set_random(function(int:string(8bit)) r)
+
/*! @decl void set_random(function(int
(0..)
:string(8bit)) r)
*! *! Set the random function, used to generate keys and parameters, *! to the function @[r]. */
-
PIKEFUN void set_random(function(int:string(8bit)) r)
+
PIKEFUN void set_random(function(int
(0..)
:string(8bit)) r)
{ assign_svalue(&THIS->random, r); } /*! @decl int(0..1) raw_verify(string(8bit) digest, @ *! object(Gmp.mpz) r, @ *! object(Gmp.mpz) s) *! *! Verify the signature @[r], @[s] against the message digest @[digest]. */