MultiPrime

send it off.

Remember to free any memory you allocated:

T_free (myPublicKeyBER.data);

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:

static unsigned char dataToEncryptWithRSA[8] = { 0x4a, 0x72, 0x55, 0x36, 0xda, 0x2f, 0xb9, 0x51

};

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:

B_ALGORITHM_OBJ rsaEncryptor = (B_ALGORITHM_OBJ)NULL_PTR;

if ((status = B_CreateAlgorithmObject (&rsaEncryptor)) != 0) break;

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

2 2 6

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 248
Image 248
RSA Security 5.2.2 manual RSA Public-Key Encryption, Send it off Remember to free any memory you allocated