Hi!
    Does anyone know how to use nss3.8 pkcs11 module to perform public key
encrypt via hardware?
    I use PK11_GenerateKeyPair generate a keypair in smartcard and use
PK11_ImportPublicKey import the public key in smartcard.Now I want use this
publickey to perform encryption via hardware,how can I do this?
    My code as follows:


privkey=PK11_GenerateKeyPair(slot,CKM_RSA_PKCS_KEY_PAIR_GEN,&rsaparm,&pubk,P
R_TRUE,PR_TRUE,NULL);
 if (privkey==NULL)
 {
  errcode=KEY_GEN_FAILED;
  goto cleanup;
 }

 /*CK_OBJECT_HANDLE PK11_ImportPublicKey(PK11SlotInfo *slot,
  SECKEYPublicKey *pubKey, PRBool isToken);*/

 hPub=PK11_ImportPublicKey(slot,pubk,PR_TRUE);
 if (hPub==NULL)
 {
  errcode=KEY_COPY_FAILED;
  goto cleanup;
 }

 printf ("set public key name is 'A public key'\n");
 s=PK11_SetPublicKeyNickname(pubk,"A public key");
 if (s!=SECSuccess)
 {
  errcode=KEY_SET_NAME;
  goto cleanup;
 }

 printf ("set private key name is 'A private key'\n");
 s=PK11_SetPrivateKeyNickname(privkey,"A private key");
 if (s!=SECSuccess)
 {
  errcode=KEY_SET_NAME;
  goto cleanup;
 }



Reply via email to