Branch: Tag:

2014-04-21

2014-04-21 17:35:04 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Nettle.DH_Params: Added C-code for Diffie-Hellman.

Crypto.DH.DHParams now uses Nettle.DH_Params if available.

5:   //! Diffie-Hellman parameters.   class DHParameters   { + #if constant(Nettle.DH_Params) +  inherit Nettle.DH_Params; + #else    //! Prime.    Gmp.mpz p;   
14:    //! Subgroup size.    Gmp.mpz q;    +  // FIXME: generate(). +  +  //! Generate a Diffie-Hellman key pair. +  //! +  //! @returns +  //! Returns the following array: +  //! @array +  //! @elem Gmp.mpz 0 +  //! The generated public key. +  //! @rlem Gmp.mpz 1 +  //! The corresponding private key. +  //! @endarray +  array(Gmp.mpz) generate_keypair(function(int(0..):string(8bit)) rnd) +  { +  Gmp.mpz key = Gmp.mpz(rnd(q->size() / 8 + 16), 256) % (q - 1) + 1; +  +  Gmp.mpz pub = g->powm(key, p); +  +  return ({ pub, key }); +  } + #endif +     //! Alias for @[q].    //!    //! @deprecated q