Cryptography Reference
In-Depth Information
int done;
seedBBS ((unsigned long)time (NULL));
do
{
done = RSAkey::makekey (bitlen);
}
while (!done);
}
// constructor, generates RSA keys of specified binary length to the
// optional public exponent PubExp. The initialization of random number
// generator randBBS() is carried out with the specified LINT argument rnd.
// If PubExp == 1 or it is absent, then the public exponent is chosen
// randomly. If PubExp is even, then an error status is generated
// via makekey(), which can be caught by try() and catch() if
// error handling is activated using Exceptions.
RSAkey::RSAkey (int bitlen, const LINT& rand, const LINT& PubExp)
{
int done;
seedBBS (rand);
do
{
done = RSAkey::makekey (bitlen, PubExp);
}
while (!done);
}
// export function for public key components
PKEYSTRUCT RSAkey::export_public (void) const
{
PKEYSTRUCT pktmp;
pktmp.pubexp = key.pubexp;
pktmp.mod = key.mod;
pktmp.bitlen_mod = key.bitlen_mod;
pktmp.bytelen_mod = key.bytelen_mod;
return pktmp;
}
// RSA decryption
UCHAR* RSAkey::decrypt (const LINT& Ciph, int* LenMess)
{
UCHAR* EB = lint2byte (fastdecrypt (Ciph), LenEB);
UCHAR* Mess = NULL;
// Parse decrypted encryption block, PKCS#1 formatted
if (BLOCKTYPE_ENCR != parse_pkcs1 (Mess, EB, LenEB, key.bytelen_mod))
{
Search WWH ::




Custom Search