# pike.git/lib/modules/Crypto.pmod/RSA.pike

Branch: Tag:

## 2013-11-29

#### 2013-11-29 16:05:18 by Martin Nilsson <nilsson@opera.com>

• c49a3206cf99856baff3eb29b2dc602bbcd16057 (13 lines) (+12/-1) [ Show | Annotate ]
Branch: 8.0
Some fixes to the Pike key generation. Check that e is usable. Have the test message be short enough to actually work for small key sizes. Don't depend on MD5.

163: Inside #if constant(Crypto.Hash)
{    if (bits < 128)    error( "Ridiculously small key.\n" ); +  if( e ) +  { +  if(!(e&1)) error("e needs to be odd.\n"); +  if(e<3) error("e is too small.\n"); +  if(e->size()>bits) error("e has to be smaller in size than the key.\n"); +  }       /* NB: When multiplying two n-bit integers,    * you're most likely to get an (2n - 1)-bit result.
174: Inside #if constant(Crypto.Hash)
int s1 = bits / 2; /* Size of the first prime */    int s2 = 1 + bits - s1;    -  string msg = "This is a valid RSA key pair\n"; +  string msg = "A" * (bits/8-3-8);       do    {
444:      // (RSA/SHA-1 SIG is in RFC 3110)    + #if constant(Crypto.MD5) +    __deprecated__ string md5_sign(string message, mixed|void r)   {    string s = Crypto.MD5->hash(message);
458:    return raw_verify(s, Gmp.mpz(signature, 256));   }    + #endif +    __deprecated__ string sha_sign(string message, mixed|void r)   {    string s = sprintf("%c%s%1H", 4, "sha1", Crypto.SHA1->hash(message));