Branch: Tag:

2004-02-08

2004-02-08 03:21:02 by Martin Nilsson <mani@lysator.liu.se>

Some more doc

Rev: lib/modules/Crypto.pmod/RSA.pike:1.5

1: - /* $Id: RSA.pike,v 1.4 2004/02/05 19:21:15 nilsson Exp $ + /* $Id: RSA.pike,v 1.5 2004/02/08 03:21:02 nilsson Exp $    *    * Follow the PKCS#1 standard for padding and encryption.    */
36: Inside #if constant(Gmp.mpz)
   return d;   }    - // Returns the first RSA prime (if known). + //! Returns the first RSA prime (if known).   Gmp.mpz get_p()   {    return p;   }    - // Returns the second RSA prime (if known). + //! Returns the second RSA prime (if known).   Gmp.mpz get_q()   {    return q;
66: Inside #if constant(Gmp.mpz)
   return d->digits(256);   }    - // Returns the first RSA prime (if known) as a binary string. + //! Returns the first RSA prime (if known) as a binary string.   string cooked_get_p()   {    return p->digits(256);   }    - // Returns the second RSA prime (if known) as a binary string. + //! Returns the second RSA prime (if known) as a binary string.   string cooked_get_q()   {    return q->digits(256);
134: Inside #if constant(Gmp.mpz)
   int len;       len = size - 3 - sizeof(message); -  /* write(sprintf("%d, %d, %d, %s", len, size, sizeof(message), message)); */ +     if (len < 8)    error( "Block too large. (%d,%d)\n", sizeof(message), size-3 );   
215: Inside #if constant(Gmp.mpz)
     // end of _rsa    - //! @fixme - //! Document this function. + //! Signs the @[message] with a PKCS-1 signature using hash algorithm + //! @[h].   Gmp.mpz sign(string message, .Hash h)   {    return raw_sign(Standards.PKCS.Signature.build_digestinfo(message, h));   }    - //! @fixme - //! Document this function. + //! Verify PKCS-1 signature @[sign] of message @[msg] using hash + //! algorithm @[h].   int(0..1) verify(string msg, .Hash h, Gmp.mpz sign)   {    string s = Standards.PKCS.Signature.build_digestinfo(msg, h);
266: Inside #if constant(Gmp.mpz)
   return raw_verify(s, Gmp.mpz(signature, 256));   }    - //! @fixme - //! Document this function. + //! Generate a prime with @[bits] number of bits using random function + //! @[r].   Gmp.mpz get_prime(int bits, function(int:string) r)   {    int len = (bits + 7) / 8;
334: Inside #if constant(Gmp.mpz)
     static int encrypt_mode; // For block cipher compatible functions    - //! @fixme - //! Document this function. + //! Sets the public key to @[key] and the mode to encryption.   //! @seealso   //! @[set_decrypt_key], @[crypt]   this_program set_encrypt_key(array(Gmp.mpz) key)
345: Inside #if constant(Gmp.mpz)
   return this;   }    - //! @fixme - //! Document this function. + //! Sets the public key to @[key]and the mod to decryption.   //! @seealso   //! @[set_encrypt_key], @[crypt]   this_program set_decrypt_key(array(Gmp.mpz) key)
357: Inside #if constant(Gmp.mpz)
   return this;   }    - //! @fixme - //! Document this function. + //! Encrypt or decrypt depending on set mode.   //! @seealso   //! @[set_encrypt_key], @[set_decrypt_key]   string crypt(string s)