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

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