000025771 - How to creating a key from data in a Crypto-C struct

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000025771
Applies ToBSAFE/Micro Edition Suite
IssueHow to creating a key from data in a Crypto-C struct
Assume you have some code that creates a BSAFE CRYTPO-C key object from an object of type A_PKCS_RSA_PRIVATE_KEY:
typedef struct {
    ITEM modulus;
    ITEM publicExponent;
    ITEM privateExponent;
    ITEM prime[2]; /* prime factors */
    ITEM primeExponent[2]; /* exponents for prime factors */
    ITEM coefficient; /* CRT coefficient */

You have mapped the fields to these R_PKEY_set_info identifiers:
publicExponent - R_PKEY_INFO_ID_RSA_EXP
privateExponent - R_PKEY_INFO_ID_RSA_PRIV_EXP
prime[0] - R_PKEY_INFO_ID_RSA_Q
prime[1] - R_PKEY_INFO_ID_RSA_P
primeExponent[0] - R_PKEY_INFO_ID_RSA_DMQ1
primeExponent[1] - R_PKEY_INFO_ID_RSA_DMP1

But what mapping do you use for the coefficient?
NotesAccording to PKCS#1, the CRT coefficient qInv is a positive integer less than p satisfying:

q * qInv == 1 (mod p).

So, the ID he needs is R_PKEY_INFO_ID_RSA_IQMP.
Legacy Article IDa39116