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

version» Context lines:

pike.git/lib/modules/Crypto.pmod/RSA.pike:395:    default:    error( "Unknown type.\n" );    }    return Gmp.mpz(sprintf("%c", type) + cookie + "\0" + message, 256);   }      //! Reverse the effect of @[rsa_pad].   string(8bit) rsa_unpad(Gmp.mpz block, int type)   {    string(8bit) s = block->digits(256); -  int i = search(s, "\0"); +     -  // Evaluate all error conditions for timing reasons. -  if ( `+( (i < 9), (sizeof(s) != (size - 1)), (s[0] != type) ) ) -  return 0; -  return s[i+1..]; +  // Content independent size information. Not timing sensitive. +  if( sizeof(s)!=(size-1) ) return 0; +  +  int i = Nettle.rsa_unpad(s, type); +  if( !i ) return 0; +  +  return s[i..];   }      //! Pads the @[digest] with @[rsa_pad] type 1 and signs it.   Gmp.mpz raw_sign(string(8bit) digest)   {    return rsa_pad(digest, 1, 0)->powm(d, n);   }      //! Verifies the @[digest] against the signature @[s], assuming pad   //! type 1.