Hello ,

I have an RSA-key pair with the corresponding certificate in a smartcard.

I wanted to retrieve the values of the public modulus and the public exponent of the
public key to assign the values in a search template , and then to use the search template
in the PKCS11-Methods
C_FindObjectsInit  and C_FindObjects to get a handle to the private key.

But something went wrong, it didn't find an object at all, it matched only when in my
search-template was just the the public modulus.

Does anyone has an idea?

thanx

nenad tomasic
 
 
 
 

 pN = publicKey->pkey.rsa->n;      /*public Modulus  as a *BIGNUM*/
 pE = publicKey->pkey.rsa->e;      /*public exponent  as a *BIGNUM*/
 
 pModulus = malloc(BN_num_bytes(pN));
 pExponent = malloc(BN_num_bytes(pE));
 
 template[0].pValue = pModulus;
 template[1].pValue = pExponent;

 template[0].ulValueLen = BN_bn2bin(pN, template[0].pValue);
 template[1].ulValueLen = BN_bn2bin(pE, template[1].pValue);
 
 rv = tokenInfo.pFunctionList->C_FindObjectsInit(hSession, template, 2);
 if(rv != CKR_OK) {
  return NULL;
 }
 
 rv = tokenInfo.pFunctionList->C_FindObjects(hSession, phPrivKey, 1, &ulObjectCount);
 if(rv != CKR_OK) {
  return NULL;
 }
 

==>   ulObjectCount == 0
 

-- 

+---------------------------------------------------------------------+
| Nenad Tomasic         Roentgenstr. 22         Phone: +41 1-272 6111 |
| AdNovum Informatik    CH-8005 Zuerich         Fax:   +41 1-272 6312 |
|                                                                     |
| AdNovum Software Inc. San Mateo, CA 94404     Voice: (650) 525-9322 |
|        1400 Fashion Island Boulevard #309     Fax:   (650) 525-9324 |
+---------------------------------------------------------------------+
| E-MAIL :            mailto:[EMAIL PROTECTED]                 |
|                          http://www.adnovum.ch                      |
+---------------------------------------------------------------------+
 


Reply via email to