[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3766 - in trunk/softHSM: . src/bin

Rickard Bellgrim rickard.bellgrim at iis.se
Fri Aug 20 13:41:33 CEST 2010


Author: rb
Date: 2010-08-20 13:41:33 +0200 (Fri, 20 Aug 2010)
New Revision: 3766

Modified:
   trunk/softHSM/NEWS
   trunk/softHSM/src/bin/softhsm.cpp
   trunk/softHSM/src/bin/softhsm.h
Log:
The softhsm command now import all parts of the RSA key. 
CKA_EXPONENT_1, CKA_EXPONENT_2, and CKA_COEFFICIENT is not needed 
by SoftHSM but might be needed by other HSM:s.


Modified: trunk/softHSM/NEWS
===================================================================
--- trunk/softHSM/NEWS	2010-08-20 11:14:57 UTC (rev 3765)
+++ trunk/softHSM/NEWS	2010-08-20 11:41:33 UTC (rev 3766)
@@ -8,6 +8,9 @@
   when verifying these signatures)
 * The softhsm command now have the option --module <path>
   To use a PKCS#11 library other than SoftHSM.
+* The softhsm command now import all parts of the RSA key.
+  CKA_EXPONENT_1, CKA_EXPONENT_2, and CKA_COEFFICIENT is not needed
+  by SoftHSM but might be needed by other HSM:s.
 * Ticket #163: softhsm-keyconv now support BIND format v1.3
 * Write message to stderr when the config file cannot be found
 * CKA_WRAP_WITH_TRUSTED was not handled correctly. But it has not

Modified: trunk/softHSM/src/bin/softhsm.cpp
===================================================================
--- trunk/softHSM/src/bin/softhsm.cpp	2010-08-20 11:14:57 UTC (rev 3765)
+++ trunk/softHSM/src/bin/softhsm.cpp	2010-08-20 11:41:33 UTC (rev 3766)
@@ -616,11 +616,14 @@
     { CKA_MODULUS,          keyMat->bigN, keyMat->sizeN },
     { CKA_PRIVATE_EXPONENT, keyMat->bigD, keyMat->sizeD },
     { CKA_PRIME_1,          keyMat->bigP, keyMat->sizeP },
-    { CKA_PRIME_2,          keyMat->bigQ, keyMat->sizeQ }
+    { CKA_PRIME_2,          keyMat->bigQ, keyMat->sizeQ },
+    { CKA_EXPONENT_1,       keyMat->bigDMP1, keyMat->sizeDMP1 },
+    { CKA_EXPONENT_2,       keyMat->bigDMQ1, keyMat->sizeDMQ1 },
+    { CKA_COEFFICIENT,      keyMat->bigIQMP, keyMat->sizeIQMP }
   };
 
   CK_OBJECT_HANDLE hKey1, hKey2;
-  rv = p11->C_CreateObject(hSession, privTemplate, 16, &hKey1);
+  rv = p11->C_CreateObject(hSession, privTemplate, 19, &hKey1);
   if(rv != CKR_OK) {
     freeKeyMaterial(keyMat);
     free(objID);
@@ -842,16 +845,25 @@
   keyMat->sizeD = ifKeyPriv->get_d().bytes();
   keyMat->sizeP = ifKeyPriv->get_p().bytes();
   keyMat->sizeQ = ifKeyPriv->get_q().bytes();
+  keyMat->sizeDMP1 = ifKeyPriv->get_d1().bytes();
+  keyMat->sizeDMQ1 = ifKeyPriv->get_d2().bytes();
+  keyMat->sizeIQMP = ifKeyPriv->get_c().bytes();
   keyMat->bigE = (CK_VOID_PTR)malloc(keyMat->sizeE);
   keyMat->bigN = (CK_VOID_PTR)malloc(keyMat->sizeN);
   keyMat->bigD = (CK_VOID_PTR)malloc(keyMat->sizeD);
   keyMat->bigP = (CK_VOID_PTR)malloc(keyMat->sizeP);
   keyMat->bigQ = (CK_VOID_PTR)malloc(keyMat->sizeQ);
+  keyMat->bigDMP1 = (CK_VOID_PTR)malloc(keyMat->sizeDMP1);
+  keyMat->bigDMQ1 = (CK_VOID_PTR)malloc(keyMat->sizeDMQ1);
+  keyMat->bigIQMP = (CK_VOID_PTR)malloc(keyMat->sizeIQMP);
   ifKeyPriv->get_e().binary_encode((byte *)keyMat->bigE);
   ifKeyPriv->get_n().binary_encode((byte *)keyMat->bigN);
   ifKeyPriv->get_d().binary_encode((byte *)keyMat->bigD);
   ifKeyPriv->get_p().binary_encode((byte *)keyMat->bigP);
   ifKeyPriv->get_q().binary_encode((byte *)keyMat->bigQ);
+  ifKeyPriv->get_d1().binary_encode((byte *)keyMat->bigDMP1);
+  ifKeyPriv->get_d2().binary_encode((byte *)keyMat->bigDMQ1);
+  ifKeyPriv->get_c().binary_encode((byte *)keyMat->bigIQMP);
   delete privKey;
 
   return keyMat;
@@ -876,6 +888,16 @@
     if(keyMaterial->bigQ != NULL) {
       free(keyMaterial->bigQ);
     }
+    if(keyMaterial->bigDMP1 != NULL) {
+      free(keyMaterial->bigDMP1);
+    }
+    if(keyMaterial->bigDMQ1 != NULL) {
+      free(keyMaterial->bigDMQ1);
+    }
+    if(keyMaterial->bigIQMP != NULL) {
+      free(keyMaterial->bigIQMP);
+    }
+
     free(keyMaterial);
   }
 }

Modified: trunk/softHSM/src/bin/softhsm.h
===================================================================
--- trunk/softHSM/src/bin/softhsm.h	2010-08-20 11:14:57 UTC (rev 3765)
+++ trunk/softHSM/src/bin/softhsm.h	2010-08-20 11:41:33 UTC (rev 3766)
@@ -48,22 +48,34 @@
   CK_ULONG sizeD;
   CK_ULONG sizeP;
   CK_ULONG sizeQ;
+  CK_ULONG sizeDMP1;
+  CK_ULONG sizeDMQ1;
+  CK_ULONG sizeIQMP;
   CK_VOID_PTR bigE;
   CK_VOID_PTR bigN;
   CK_VOID_PTR bigD;
   CK_VOID_PTR bigP;
   CK_VOID_PTR bigQ;
+  CK_VOID_PTR bigDMP1;
+  CK_VOID_PTR bigDMQ1;
+  CK_VOID_PTR bigIQMP;
   key_material_t() {
     sizeE = 0;
     sizeN = 0;
     sizeD = 0;
     sizeP = 0;
     sizeQ = 0;
+    sizeDMP1 = 0;
+    sizeDMQ1 = 0;
+    sizeIQMP = 0;
     bigE = NULL_PTR;
     bigN = NULL_PTR;
     bigD = NULL_PTR;
     bigP = NULL_PTR;
     bigQ = NULL_PTR;
+    bigDMP1 = NULL_PTR;
+    bigDMQ1 = NULL_PTR;
+    bigIQMP = NULL_PTR;
   }
 } key_material_t;
 




More information about the Opendnssec-commits mailing list