RSA Security 5.2.2 Projection Television User Manual


 
Chapter 7 Public-Key Operations 217
Performing RSA Operations
generates a candidate and tests to see if it is prime. If the candidate passes the test,
Crypto-C has one of the primes; if not, Crypto-C builds a new number. If you are
lucky, two early numbers Crypto-C creates will pass the test. Sometimes, though,
Crypto-C has to try many numbers before it finds a pair.
Note: The numbers Crypto-C produces are not provably prime. They are numbers
for which the probability is very low that they are not prime. This does not
affect the accuracy of the algorithm and will not appreciably decrease
security.
When you generate a key pair, it can look as if your program has stopped or as if the
machine has frozen up. To help allay fears of disaster, use the surrender function
outlined in The Surrender Context on page 118. It will print out a dot every second
to let you know the program is running properly. If the dots do not appear, then you
know something is wrong:
Step 6: Destroy
When you are done with your objects, remember to destroy them:
B_KEY_OBJ publicKey = (B_KEY_OBJ)NULL_PTR;
B_KEY_OBJ privateKey = (B_KEY_OBJ)NULL_PTR;
if ((status = B_CreateKeyObject (&publicKey)) != 0)
break;
if ((status = B_CreateKeyObject (&privateKey)) != 0)
break;
/* generalFlag is for the surrender function. */
generalFlag = 0;
if ((status = B_GenerateKeypair
(keypairGenerator, publicKey, privateKey,
randomAlgorithm, &generalSurrenderContext)) != 0)
break;
B_DestroyAlgorithmObject (&randomAlgorithm);
B_DestroyAlgorithmObject (&keypairGenerator);
B_DestroyKeyObject (&publicKey);
B_DestroyKeyObject (&privateKey);