MultiPrime
226 RSA BSAFE Crypto-C Developers Guide
send it off.
Remember to free any memory you allocated:
Note: The conversion into BER or DER is known as BER-encoding or DER-
encoding; the conversion between binary to ASCII is known as encoding and
decoding. In general, the word encoding without BER in front of it means
binary to ASCII. If the encoding is BER- or DER-encoding, the BER or DER
should be explicitly stated.
RSA Public-Key Encryption
Follow Steps 1 through 6 to encrypt the following using an RSA public key:
Step 1: Creating An Algorithm Object
Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in
Chapter 4 of the Reference Manual, its address is the argument for
B_CreateAlgorithmObject:
Step 2: Setting The Algorithm Object
There are a number of RSA AIs, described in Table 4-7 on page 107. For this example,
use AI_PKCS_RSAPublic. This AI encrypts and decrypts data according to the Public-
Key Cryptography Standard #1 (PKCS#1 v1.5). See the PKCS document [1] for more
information.
The Chapter2 entry in the Reference Manual states that AI_PKCS_RSAPublic supplies
T_free (myPublicKeyBER.data);
static unsigned char dataToEncryptWithRSA[8] = {
0x4a, 0x72, 0x55, 0x36, 0xda, 0x2f, 0xb9, 0x51
};
B_ALGORITHM_OBJ rsaEncryptor = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&rsaEncryptor)) != 0)
break;