Blame SOURCES/nss-softokn-3.16-add_encrypt_derive.patch

ac153c
diff -up nss/lib/softoken/pkcs11.c.add_encrypt_derive nss/lib/softoken/pkcs11.c
358035
--- nss/lib/softoken/pkcs11.c.add_encrypt_derive	2018-02-27 15:47:47.000000000 +0100
358035
+++ nss/lib/softoken/pkcs11.c	2018-03-01 16:01:05.853165433 +0100
358035
@@ -426,6 +426,8 @@ static const struct mechanismList mechan
358035
     { CKM_CONCATENATE_DATA_AND_BASE, { 1, 32, CKF_DERIVE }, PR_FALSE },
358035
     { CKM_XOR_BASE_AND_DATA, { 1, 32, CKF_DERIVE }, PR_FALSE },
60ce18
     { CKM_EXTRACT_KEY_FROM_KEY, { 1, 32, CKF_DERIVE }, PR_FALSE },
60ce18
+    { CKM_DES_ECB_ENCRYPT_DATA, { 1, 32, CKF_DERIVE }, PR_FALSE },
60ce18
+    { CKM_DES_CBC_ENCRYPT_DATA, { 1, 32, CKF_DERIVE }, PR_FALSE },
358035
     { CKM_DES3_ECB_ENCRYPT_DATA, { 1, 32, CKF_DERIVE }, PR_FALSE },
358035
     { CKM_DES3_CBC_ENCRYPT_DATA, { 1, 32, CKF_DERIVE }, PR_FALSE },
358035
     { CKM_AES_ECB_ENCRYPT_DATA, { 1, 32, CKF_DERIVE }, PR_FALSE },
ac153c
diff -up nss/lib/softoken/pkcs11c.c.add_encrypt_derive nss/lib/softoken/pkcs11c.c
358035
--- nss/lib/softoken/pkcs11c.c.add_encrypt_derive	2018-02-27 15:47:47.000000000 +0100
358035
+++ nss/lib/softoken/pkcs11c.c	2018-03-01 16:01:18.468880916 +0100
358035
@@ -6935,6 +6935,43 @@ NSC_DeriveKey(CK_SESSION_HANDLE hSession
60ce18
             break;
60ce18
         }
6fbbf4
 
60ce18
+        case CKM_DES_ECB_ENCRYPT_DATA:
358035
+        case CKM_DES_CBC_ENCRYPT_DATA: {
358035
+            void *cipherInfo;
358035
+            CK_DES_CBC_ENCRYPT_DATA_PARAMS *desEncryptPtr;
358035
+            int mode;
358035
+            unsigned char *iv;
358035
+            unsigned char *data;
358035
+            CK_ULONG len;
358035
+
358035
+            if (mechanism == CKM_DES_ECB_ENCRYPT_DATA) {
358035
+                stringPtr = (CK_KEY_DERIVATION_STRING_DATA *)
60ce18
+                                pMechanism->pParameter;
358035
+                mode = NSS_DES;
358035
+                iv = NULL;
358035
+                data = stringPtr->pData;
358035
+                len = stringPtr->ulLen;
60ce18
+            } else {
358035
+                mode = NSS_DES_CBC;
358035
+                desEncryptPtr =
358035
+                    (CK_DES_CBC_ENCRYPT_DATA_PARAMS *)
358035
+                        pMechanism->pParameter;
358035
+                iv = desEncryptPtr->iv;
358035
+                data = desEncryptPtr->pData;
358035
+                len = desEncryptPtr->length;
60ce18
+            }
358035
+            cipherInfo = DES_CreateContext((unsigned char *)att->attrib.pValue, iv, mode, PR_TRUE);
60ce18
+            if (cipherInfo == NULL) {
60ce18
+                crv = CKR_HOST_MEMORY;
60ce18
+                break;
60ce18
+            }
358035
+            crv = sftk_DeriveEncrypt((SFTKCipher)DES_Encrypt,
358035
+                                     cipherInfo, 8, key, keySize,
358035
+                                     data, len);
60ce18
+            DES_DestroyContext(cipherInfo, PR_TRUE);
60ce18
+            break;
358035
+        }
6fbbf4
+
358035
         case CKM_DES3_ECB_ENCRYPT_DATA:
358035
         case CKM_DES3_CBC_ENCRYPT_DATA: {
358035
             void *cipherInfo;