MultiPrime

Crypto-C Format

publicKey is a key object that was set by the Crypto-C function B_GenerateKeypair. Its key info type (KI) is KI_RSAPublic. In the Reference Manual Chapter 3 entry on KI_RSAPublic, the section titled “Format of info returned by B_GetKeyInfo” tells you that the function returns a pointer to an A_RSA_KEY struct:

typedef struct {

 

ITEM modulus;

/* modulus */

ITEM exponent;

/* exponent */

} A_RSA_KEY;

 

 

 

So you need to declare a variable to be a pointer to such a struct and pass this variable’s address as the argument.

Using the prototype in Chapter 4 of the Reference Manual for B_GetKeyInfo as a guide, write the following:

A_RSA_KEY *getPublicKey = (A_RSA_KEY *)NULL_PTR;

if ((status = B_GetKeyInfo

((POINTER *)&getPublicKey, publicKey, KI_RSAPublic)) != 0) break;

If you looked at the elements of the struct:

getPublicKey->modulus.data getPublicKey->modulus.len getPublicKey->exponent.data getPublicKey->exponent.len

You could see the public key that Crypto-C generated. This is the information you would make public.

Note: If you want to e-mail the information, you will not be able to send the information over most e-mail systems because the data is in binary form, not ASCII. Crypto-C offers encoding and decoding functions to convert between binary and ASCII. See “Converting Data Between Binary and ASCII” on page 172 for more information.

BER/DER Encoding

There is a problem with distributing the key in the above struct: it is not standard; it

2 2 4

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 246
Image 246
RSA Security 5.2.2 manual Crypto-C Format, BER/DER Encoding, If you looked at the elements of the struct