Blame SOURCES/opencryptoki-3.12.1-23956d1b87bcd75b598b95328445c2d662a050ae.patch

a95140
commit 23956d1b87bcd75b598b95328445c2d662a050ae
a95140
Author: Ingo Franzki <ifranzki@linux.ibm.com>
a95140
Date:   Mon Jun 8 17:04:12 2020 +0200
a95140
a95140
    TESTCASE: DH tests: remove key size checks
a95140
    
a95140
    Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
a95140
a95140
diff --git a/testcases/crypto/dh_func.c b/testcases/crypto/dh_func.c
a95140
index 9214dd24..9a4ecfd2 100644
a95140
--- a/testcases/crypto/dh_func.c
a95140
+++ b/testcases/crypto/dh_func.c
a95140
@@ -260,15 +260,8 @@ CK_RV do_DeriveDHKey(CK_BBOOL do_import)
a95140
             testcase_error("C_GetAttributeValue #1: rc = %s", p11_get_ckr(rc));
a95140
             goto testcase_cleanup;
a95140
         }
a95140
-        // Make sure peer's key is the right size
a95140
-        if ((extr1_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME)) &&
a95140
-            (extr1_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME) - 1)) {
a95140
-            testcase_fail("ERROR:size error peer's key %ld",
a95140
-                          extr1_tmpl[0].ulValueLen);
a95140
-            goto testcase_cleanup;
a95140
-        } else {
a95140
-            testcase_pass("Successfully generated DH keys");
a95140
-        }
a95140
+
a95140
+        testcase_pass("Successfully generated DH keys");
a95140
     } else {
a95140
         // First, import the DH key Pair for Party A
a95140
 
a95140
@@ -320,15 +313,8 @@ CK_RV do_DeriveDHKey(CK_BBOOL do_import)
a95140
             testcase_error("C_GetAttributeValue #1: rc = %s", p11_get_ckr(rc));
a95140
             goto testcase_cleanup;
a95140
         }
a95140
-        // Make sure peer's key is the right size
a95140
-        if ((extr1_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME)) &&
a95140
-            (extr1_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME) - 1)) {
a95140
-            testcase_fail("ERROR:size error peer's key %ld",
a95140
-                          extr1_tmpl[0].ulValueLen);
a95140
-            goto testcase_cleanup;
a95140
-        } else {
a95140
-            testcase_pass("Successfully imported DH keys");
a95140
-        }
a95140
+
a95140
+        testcase_pass("Successfully imported DH keys");
a95140
     }
a95140
 
a95140
     // Testcase #2 - Now derive the secrets...
a95140
@@ -358,13 +344,6 @@ CK_RV do_DeriveDHKey(CK_BBOOL do_import)
a95140
             testcase_error("C_GetAttributeValue #2: rc = %s", p11_get_ckr(rc));
a95140
             goto testcase_cleanup;
a95140
         }
a95140
-        // Make sure party A's key is the right size
a95140
-        if ((extr2_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME)) &&
a95140
-            (extr2_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME) - 1)) {
a95140
-            testcase_fail("ERROR:size error party A's key %ld",
a95140
-                          extr2_tmpl[0].ulValueLen);
a95140
-            goto testcase_cleanup;
a95140
-        }
a95140
         // Now, derive a generic secret key using peer's private key
a95140
         // and A's public key
a95140
         mech.mechanism = CKM_DH_PKCS_DERIVE;
a95140
@@ -388,13 +367,6 @@ CK_RV do_DeriveDHKey(CK_BBOOL do_import)
a95140
             goto testcase_cleanup;
a95140
         }
a95140
 
a95140
-        if (extr1_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME) ||
a95140
-            *((int *) extr1_tmpl[0].pValue) == 0) {
a95140
-            testcase_fail("ERROR:derived key #1 length or value %ld",
a95140
-                          extr1_tmpl[0].ulValueLen);
a95140
-            goto testcase_cleanup;
a95140
-        }
a95140
-
a95140
         memset(key2_value, 0, sizeof(key2_value));
a95140
         extr2_tmpl[0].ulValueLen = sizeof(key2_value);
a95140
 
a95140
@@ -405,14 +377,8 @@ CK_RV do_DeriveDHKey(CK_BBOOL do_import)
a95140
             goto testcase_cleanup;
a95140
         }
a95140
 
a95140
-        if (extr2_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME) ||
a95140
-            *((int *) extr2_tmpl[0].pValue) == 0) {
a95140
-            testcase_fail("ERROR:derived key #2 length or value %ld",
a95140
-                          extr2_tmpl[0].ulValueLen);
a95140
-            goto testcase_cleanup;
a95140
-        }
a95140
-
a95140
-        if (memcmp(key1_value, key2_value, sizeof(DH_PUBL_PRIME)) != 0) {
a95140
+        if (extr1_tmpl[0].ulValueLen != extr2_tmpl[0].ulValueLen ||
a95140
+            memcmp(key1_value, key2_value, extr1_tmpl[0].ulValueLen) != 0) {
a95140
             testcase_fail("ERROR:derived key mismatch");
a95140
             goto testcase_cleanup;
a95140
         }
a95140
@@ -453,13 +419,6 @@ CK_RV do_DeriveDHKey(CK_BBOOL do_import)
a95140
             testcase_error("C_GetAttributeValue #2: rc = %s", p11_get_ckr(rc));
a95140
             goto testcase_cleanup;
a95140
         }
a95140
-        // Make sure party A's key is the right size
a95140
-        if ((extr2_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME)) &&
a95140
-            (extr2_tmpl[0].ulValueLen != sizeof(DH_PUBL_PRIME) - 1)) {
a95140
-            testcase_fail("ERROR:size error party A's key %ld",
a95140
-                          extr2_tmpl[0].ulValueLen);
a95140
-            goto testcase_cleanup;
a95140
-        }
a95140
         // Now, derive a generic secret key using peer's private key
a95140
         // and A's public key
a95140
         mech.mechanism = CKM_DH_PKCS_DERIVE;