pike.git
/
lib
/
modules
/
Crypto.pmod
/
DSA.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Crypto.pmod/DSA.pmod:65:
this_program set_public_key(Gmp.mpz modulo, Gmp.mpz order, Gmp.mpz generator, Gmp.mpz key) { p = modulo; q = order; g = generator; y = key; return this; }
+
//! Sets the public key in this DSA object.
+
//!
+
//! @param params
+
//! The finite-field diffie-hellman group parameters.
+
//! @param key
+
//! The public key y parameter.
+
variant this_program set_public_key(Crypto.DH.Parameters params, Gmp.mpz key)
+
{
+
p = params->p;
+
q = params->q;
+
g = params->g;
+
y = key;
+
return this;
+
}
+
//! Compares the public key in this object with that in the provided //! DSA object. int(0..1) public_key_equal(this_program dsa) { return (p == dsa->get_p()) && (q == dsa->get_q()) && (g == dsa->get_g()) && (y == dsa->get_y()); } //! Compares the keys of this DSA object with something other. protected int(0..1) _equal(mixed other)
pike.git/lib/modules/Crypto.pmod/DSA.pmod:220:
//! Nettle version @[q_bits] can be 160, 224 and 256 bits. 160 works //! for all versions. variant this_program generate_key(int p_bits, int q_bits) { [ p, q, g, y, x ] = Nettle.dsa_generate_keypair(p_bits, q_bits, random); return this; } #endif
+
//! Generates a public/private key pair with the specified
+
//! finite field diffie-hellman parameters.
+
variant this_program generate_key(Crypto.DH.Parameters params)
+
{
+
p = params->p;
+
g = params->g;
+
q = params->q;
+
+
[y, x] = params->generate_keypair(random);
+
return this;
+
}
+
//! Generates a public/private key pair. Needs the public parameters
-
//! p, q and g set,
either
through @[set_public_key]
or
-
//! @[generate_key(int,int)].
+
//! p, q and g set, through
one of
@[set_public_key]
,
+
//! @[generate_key(int,int)]
or @[generate_key(params)]
.
variant this_program generate_key() { /* x in { 2, 3, ... q - 1 } */ if(!p || !q || !g) error("Public parameters not set..\n"); x = [object(Gmp.mpz)](random_number( [object(Gmp.mpz)](q-2) ) + 2); y = g->powm(x, p); return this; }