rsakeygn.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
/* Copyright (C) RSA Data Security, Inc. created 1990, 1996. This is an
unpublished work protected as such under copyright law. This work
contains proprietary, confidential, and trade secret information of
RSA Data Security, Inc. Use, disclosure or reproduction without the
express written authorization of RSA Data Security, Inc. is
prohibited.
*/
#include "global.h"
#include "algae.h"
#include "bigmath.h"
#include "surrendr.h"
#include "prime.h"
#include "rsakeygn.h"
#define GENERATE_BREAK(type) { \
break; \
}
static int RSAParameters PROTO_LIST
unsigned int, unsigned int, A_SURRENDER_CTX *));
static void SetRSAKeyGenResult PROTO_LIST
{
/* Prezeroize big public exponent vector. */
sizeof (context->bigPublicExponent));
/* Copy public exponent into big vector */
if (CanonicalToBig
/* could not copy exponent into MAX_RSA_MODULUS_WORDS */
return (AE_EXPONENT_LEN);
/* Check that public exponent is in bounds and odd.
*/
return (AE_EXPONENT_LEN);
return (AE_EXPONENT_EVEN);
return (0);
}
/* This generates an RSA keypair of size modulusBits with the fixed
publicExponent, pointing result to the resulting integers. The
resulting integer data is in the context, so that the values must be
copied before the context is zeroized.
All integers are unsigned canonical bytes arrays with the most significant
byte first.
The randomBlock is of length randomBlockLen returned by RSAKeyGenQuery.
This assumes that the modulusBits size was checked by RSAKeyGenQuery.
*/
unsigned char *randomBlock;
{
int status;
/* Prezeroize all big word vectors. */
sizeof (context->bigPrivateExponent));
/* prime size is half modulus size */
/* Fish for bigPrime1 and bigPrime2 that are compatible with supplied
publicExponent.
The randomBlock holds random bytes for two primes.
*/
surrenderContext)) != 0)
return (status);
return (status);
/* Set bigPrimeP to the larger of bigPrime1 and bigPrime2 and set
bigPrimeQ to the smaller.
*/
}
else {
}
/* Calculate the rest of the key components */
if ((status = RSAParameters
return (status);
/* Copy key components into canonical buffers which are at the
end of the context. */
return (0);
}
/* Assumes ee, pp, qq are given, calculates other parameters.
Returns 0, AE_CANCEL.
*/
static int RSAParameters
unsigned int primeWords, modulusWords;
{
int status;
do {
/* N=P*Q */
break;
/* qm1=q-1 & pm1=p-1 */
/* t3=1 */
/*t1=phi (N) */
break;
/* compute decryption exponent */
break;
/* calc DP=inv (E)[mod (P-1)] & DQ=inv (e)[mod (Q-1)] */
break;
break;
/* calc CR = (inv (Q)[modP]) */
} while (0);
return (status);
}
{
unsigned int primeLen, modulusLen;
}