# CVE-2024-30096 — ncryptprov.dll patch diff

`ncryptprov.dll` 10.0.22621.3672 -> 10.0.22621.3733 (ghidriff).

## `FinalizeEccKeyFull`  (modified)

```diff
--- FinalizeEccKeyFull
+++ FinalizeEccKeyFull
@@ -1,384 +1,384 @@
 

+/* WARNING: Function: _guard_xfg_dispatch_icall_nop replaced with injection: guard_dispatch_icall */

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-/* WARNING: Possible PIC construction at 0x00018001025b: Changing call to branch */

-/* WARNING: Possible PIC construction at 0x00018000ff6c: Changing call to branch */

-/* WARNING: Removing unreachable block (ram,0x00018001025b) */

-/* WARNING: Removing unreachable block (ram,0x00018000ff6c) */

+/* WARNING: Function: __chkstk replaced with injection: alloca_probe */

+/* WARNING: Type propagation algorithm not settling */

 

-ulonglong FinalizeEccKeyFull(longlong param_1)

+ulonglong FinalizeEccKeyFull(longlong param_1,uint param_2)

 

 {

-  uint uVar1;

-  short *psVar2;

-  undefined8 *puVar3;

-  undefined *puVar4;

-  undefined **ppuVar5;

-  DWORD DVar6;

-  undefined4 uVar7;

-  int iVar8;

-  char *in_RAX;

-  ulonglong uVar9;

-  undefined8 uVar10;

-  undefined4 uVar11;

-  longlong *plVar12;

-  undefined **ppuVar13;

-  uint uVar14;

-  uint uVar15;

-  undefined **in_RDX;

-  char *pcVar16;

-  undefined8 *unaff_RBP;

-  int unaff_ESI;

-  longlong lVar17;

-  undefined8 *unaff_RDI;

-  uint *pbOutput;

-  undefined **ppuVar18;

-  ulonglong uVar19;

-  undefined **unaff_R12;

-  wchar_t *pwVar20;

-  undefined **ppuVar21;

-  longlong unaff_R13;

-  undefined **unaff_R15;

-  undefined8 in_stack_00000020;

-  ULONG *pUVar22;

-  int *piVar23;

-  int in_stack_00000060;

-  int in_stack_00000064;

-  undefined **in_stack_00000068;

-  uint in_stack_00000074;

-  LPCWSTR in_stack_00000078;

+  longlong *plVar1;

+  code *pcVar2;

+  BCRYPT_ALG_HANDLE pvVar3;

+  longlong lVar4;

+  wchar_t *pwVar5;

+  uint uVar6;

+  undefined8 uVar7;

+  ulonglong uVar8;

+  undefined4 *puVar9;

+  undefined4 uVar10;

+  uint *puVar11;

+  ulonglong uVar12;

+  undefined1 *puVar13;

+  undefined1 *puVar14;

+  uint *puVar15;

+  uint *puVar16;

+  uint *puVar17;

+  uint uVar18;

+  uint uVar19;

+  undefined1 auStack_88 [32];

+  undefined4 local_68;

+  uint *local_60;

+  uint local_58;

+  uint local_48 [2];

+  uint *local_40;

+  wchar_t *local_38;

+  ulonglong local_30;

   

-  uVar11 = (undefined4)((ulonglong)in_stack_00000020 >> 0x20);

-  *in_RAX = *in_RAX + (char)in_RAX;

-  unaff_R15[0x13] = (undefined *)*unaff_RDI;

-  psVar2 = *(short **)(unaff_R15[8] + 0x50);

-  ppuVar21 = unaff_R12;

-  if ((psVar2 != (short *)0x0) && (*(int *)(unaff_R15[8] + 0x20) != 0x3000a)) {

-    in_RDX = unaff_R15 + 0x14;

-    uVar9 = CNG_GetBCryptHandle(psVar2,in_RDX);

-    iVar8 = (int)uVar9;

-    if (iVar8 == 0) goto LAB_0;

-    DebugTraceError(iVar8,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c");

-    DebugTraceError(iVar8,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c");

-LAB_1:

-    uVar19 = uVar9 & 0xffffffff;

-    pcVar16 = "Status";

-    uVar14 = (uint)uVar9;

-    DebugTraceError(uVar14,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c")

-    ;

-    in_RDX = (undefined **)pcVar16;

-    if (unaff_R15 != (undefined **)0x0) {

-      DeleteKeyObject((undefined1 *)unaff_R15);

-      in_RDX = (undefined **)pcVar16;

+  puVar14 = auStack_88;

+  puVar13 = auStack_88;

+  local_30 = __security_cookie ^ (ulonglong)local_48;

+  puVar11 = (uint *)0x0;

+  local_40 = (uint *)0x0;

+  puVar16 = (uint *)0x0;

+  local_48[1] = 0;

+  plVar1 = (longlong *)(param_1 + 0xa8);

+  local_48[0] = 0;

+  if (*(longlong *)(param_1 + 0x228) == 0) {

+LAB_0:

+    uVar6 = (**(code **)(*plVar1 + 0x50))(*(undefined8 *)(param_1 + 0x70),param_2 & 3);

+    uVar8 = (ulonglong)uVar6;

+    if ((int)uVar6 < 0) goto LAB_1;

+    local_38 = L"ISOPROTECTEDBLOB";

+    puVar15 = puVar11;

+    if (*(int *)(param_1 + 0x90) != 0) {

+      if (*(longlong *)(param_1 + 0x78) != 0) goto LAB_2;

+LAB_3:

+      pcVar2 = *(code **)(*plVar1 + 0x78);

+      *(undefined4 *)(puVar14 + 0x30) = 0;

+      *(uint **)(puVar14 + 0x28) = local_48;

+      uVar7 = *(undefined8 *)(param_1 + 0x70);

+      *(undefined4 *)(puVar14 + 0x20) = 0;

+      *(undefined8 *)(puVar14 + -8) = 0x1800058a8;

+      uVar18 = (*pcVar2)(uVar7,0,L"ECCFULLPUBLICBLOB",0);

+      uVar8 = (ulonglong)uVar18;

+      puVar17 = puVar16;

+      if ((int)uVar18 < 0) goto LAB_4;

+      uVar8 = (ulonglong)local_48[0];

+      puVar13 = puVar14;

+      puVar17 = puVar11;

+      uVar6 = local_48[0];

+      if (((local_48[0] == 0) || (puVar17 = puVar16, g_ulMaxStackAllocSize < uVar8)) ||

+         (uVar12 = g_ulAdditionalProbeSize + 8 + uVar8, uVar12 < uVar8)) {

+LAB_5:

+        puVar14 = puVar13;

+        if (uVar6 + 8 < uVar6) {

+LAB_6:

+          if (puVar17 != (uint *)0x0) goto LAB_7;

+        }

+        else {

+          *(undefined8 *)(puVar14 + -8) = 0x1800059a7;

+          puVar17 = (uint *)(*g_pfnAllocate)(uVar6 + 8);

+          if (puVar17 != (uint *)0x0) {

+            *puVar17 = 0x70616548;

+            puVar17 = puVar17 + 2;

+            uVar6 = local_48[0];

+            goto LAB_6;

+          }

+        }

+        uVar8 = 0x8009000e;

+        uVar18 = 0x8009000e;

+LAB_4:

+        *(undefined8 *)(puVar14 + -8) = 0x180005601;

+        DebugTraceError(uVar18,"Status",

+                        "onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c");

+        puVar13 = puVar14;

+      }

+      else {

+        *(undefined8 *)(puVar14 + -8) = 0x1800058ed;

+        uVar7 = VerifyStackAvailable(uVar12);

+        uVar6 = local_48[0];

+        puVar17 = puVar11;

+        if ((int)uVar7 == 0) goto LAB_5;

+        uVar8 = (ulonglong)(local_48[0] + 8) + 0xf;

+        if (uVar8 <= local_48[0] + 8) {

+          uVar8 = 0xffffffffffffff0;

+        }

+        *(undefined8 *)(puVar14 + -8) = 0x180005919;

+        lVar4 = -(uVar8 & 0xfffffffffffffff0);

+        puVar13 = puVar14 + lVar4;

+        puVar17 = (uint *)0x0;

+        if ((undefined4 *)(puVar14 + lVar4 + 0x40) == (undefined4 *)0x0) goto LAB_5;

+        *(undefined4 *)(puVar14 + lVar4 + 0x40) = 0x6b637453;

+        puVar17 = (uint *)(puVar14 + lVar4 + 0x48);

+        puVar13 = puVar14 + lVar4;

+        puVar14 = puVar14 + lVar4;

+        uVar6 = local_48[0];

+        if (puVar17 == (uint *)0x0) goto LAB_5;

+LAB_7:

+        pcVar2 = *(code **)(*plVar1 + 0x78);

+        *(undefined4 *)(puVar14 + 0x30) = 0;

+        *(uint **)(puVar14 + 0x28) = local_48;

+        uVar7 = *(undefined8 *)(param_1 + 0x70);

+        *(uint *)(puVar14 + 0x20) = uVar6;

+        *(undefined8 *)(puVar14 + -8) = 0x18000596f;

+        uVar18 = (*pcVar2)(uVar7,0,L"ECCFULLPUBLICBLOB",puVar17);

+        uVar8 = (ulonglong)uVar18;

+        if ((int)uVar18 < 0) goto LAB_4;

+LAB_8:

+        uVar6 = local_48[0];

+        pvVar3 = *(BCRYPT_ALG_HANDLE *)(param_1 + 0x58);

+        *(undefined4 *)(puVar14 + 0x30) = 0;

+        *(uint *)(puVar14 + 0x28) = uVar6;

+        *(uint **)(puVar14 + 0x20) = puVar17;

+        *(undefined8 *)(puVar14 + -8) = 0x180005850;

+        uVar18 = BCryptImportKeyPair(pvVar3,(BCRYPT_KEY_HANDLE)0x0,L"ECCFULLPUBLICBLOB",

+                                     (BCRYPT_KEY_HANDLE *)(param_1 + 0x68),

+                                     *(PUCHAR *)(puVar14 + 0x20),*(ULONG *)(puVar14 + 0x28),

+                                     *(ULONG *)(puVar14 + 0x30));

+        uVar8 = (ulonglong)uVar18;

+        if (uVar18 != 0) goto LAB_4;

+        if (*(longlong *)(param_1 + 0x78) != 0) {

+          uVar6 = *puVar17;

+          if (uVar6 == 0x314b4345) {

+            uVar6 = 0x32534345;

+            uVar19 = 0x31534345;

+          }

+          else if (uVar6 == 0x334b4345) {

+            uVar6 = 0x34534345;

+            uVar19 = 0x33534345;

+          }

+          else {

+            if (uVar6 != 0x354b4345) {

+              uVar8 = 0x8009002d;

+              uVar18 = 0x8009002d;

+              goto LAB_4;

+            }

+            uVar6 = 0x36534345;

+            uVar19 = 0x35534345;

+          }

+          *local_40 = uVar6;

+          pwVar5 = local_38;

+          uVar6 = local_48[1];

+          pcVar2 = *(code **)(*plVar1 + 0x70);

+          *(undefined4 *)(puVar14 + 0x30) = 0;

+          *(uint *)(puVar14 + 0x28) = uVar6;

+          uVar7 = *(undefined8 *)(param_1 + 0xa0);

+          *(uint **)(puVar14 + 0x20) = puVar15;

+          *(undefined8 *)(puVar14 + -8) = 0x180005a7c;

+          uVar18 = (*pcVar2)(uVar7,0,pwVar5,param_1 + 0x88);

+          uVar8 = (ulonglong)uVar18;

+          if (uVar18 == 0) {

+            *puVar17 = uVar19;

+            uVar6 = local_48[0];

+            pvVar3 = *(BCRYPT_ALG_HANDLE *)(param_1 + 0x78);

+            *(undefined4 *)(puVar14 + 0x30) = 0;

+            *(uint *)(puVar14 + 0x28) = uVar6;

+            *(uint **)(puVar14 + 0x20) = puVar17;

+            *(undefined8 *)(puVar14 + -8) = 0x180005abf;

+            uVar18 = BCryptImportKeyPair(pvVar3,(BCRYPT_KEY_HANDLE)0x0,L"ECCFULLPUBLICBLOB",

+                                         (BCRYPT_KEY_HANDLE *)(param_1 + 0x80),

+                                         *(PUCHAR *)(puVar14 + 0x20),*(ULONG *)(puVar14 + 0x28),

+                                         *(ULONG *)(puVar14 + 0x30));

+            uVar8 = (ulonglong)uVar18;

+            if (uVar18 == 0) goto LAB_9;

+          }

+          goto LAB_4;

+        }

+LAB_9:

+        uVar8 = 0;

+        puVar13 = puVar14;

+      }

+      if ((puVar15 != (uint *)0x0) && (puVar15[-2] == 0x70616548)) {

+        *(undefined8 *)(puVar13 + -8) = 0x180005b01;

+        (*g_pfnFree)(puVar15 + -2);

+      }

+      if ((puVar17 != (uint *)0x0) && (puVar17[-2] == 0x70616548)) {

+        *(undefined8 *)(puVar13 + -8) = 0x180005b2a;

+        (*g_pfnFree)(puVar17 + -2);

+      }

+      goto LAB_10;

     }

-    unaff_ESI = in_stack_00000060;

-    ppuVar5 = in_stack_00000068;

-    if (uVar14 == 0) goto LAB_2;

-    goto LAB_3;

-  }

-LAB_0:

-  uVar14 = *(uint *)(unaff_RBP + 0x19);

-  unaff_R15[0xb] = unaff_R15[0x13];

-  unaff_R15[0xf] = unaff_R15[0x14];

-  ppuVar5 = unaff_R15;

-  if ((uVar14 & 0x30000) != 0) {

-    in_RDX = (undefined **)0x1;

-    uVar9 = FinishNewKeyObject_VirtualIso

-                      ((longlong)unaff_R15,(char *)0x1,(char *)(ulonglong)(uVar14 >> 0x12 & 1));

-    ppuVar5 = unaff_R15;

-    if ((int)uVar9 != 0) {

-      in_stack_00000060 = unaff_ESI;

-      if ((uVar14 >> 0x10 & 1) == 0) goto LAB_1;

-      in_RDX = &WPP_GLOBAL_Control;

-      ppuVar5 = unaff_R15;

-      if (((undefined **)WPP_GLOBAL_Control != &WPP_GLOBAL_Control) &&

-         (ppuVar5 = unaff_R15, (WPP_GLOBAL_Control[0x1c] & 2) != 0)) {

-        in_RDX = (undefined **)&DAT_4;

-        WPP_SF_D(*(undefined8 *)(WPP_GLOBAL_Control + 0x10),0xb,

-                 &WPP_2a92973c821e386a71dc9d2eb8ffd7d3_Traceguids,(int)uVar9);

-        ppuVar5 = unaff_R15;

-      }

+    local_38 = L"ECCFULLPRIVATEBLOB";

+LAB_2:

+    uVar18 = -(uint)(*(int *)(param_1 + 0x94) != 0) & 4;

+    local_60 = local_48 + 1;

+    local_68 = 0;

+    local_58 = uVar18;

+    uVar6 = (**(code **)(*plVar1 + 0x78))(*(undefined8 *)(param_1 + 0x70),0,local_38,0);

+    uVar8 = (ulonglong)uVar6;

+    if ((int)uVar6 < 0) goto LAB_1;

+    uVar8 = (ulonglong)local_48[1];

+    puVar13 = auStack_88;

+    if ((((local_48[1] != 0) &&

+         (puVar13 = auStack_88, puVar15 = (uint *)0x0, uVar8 <= g_ulMaxStackAllocSize)) &&

+        (uVar12 = g_ulAdditionalProbeSize + 8 + uVar8, puVar13 = auStack_88, uVar8 <= uVar12)) &&

+       (uVar7 = VerifyStackAvailable(uVar12), puVar13 = auStack_88, puVar15 = puVar11,

+       (int)uVar7 != 0)) {

+      uVar8 = (ulonglong)(local_48[1] + 8) + 0xf;

+      if (uVar8 <= local_48[1] + 8) {

+        uVar8 = 0xffffffffffffff0;

+      }

+      lVar4 = -(uVar8 & 0xfffffffffffffff0);

+      puVar14 = auStack_88 + lVar4;

+      puVar13 = auStack_88 + lVar4;

+      puVar15 = (uint *)0x0;

+      if ((undefined4 *)((longlong)local_48 + lVar4) == (undefined4 *)0x0) goto LAB_11;

+      *(undefined4 *)((longlong)local_48 + lVar4) = 0x6b637453;

+      puVar15 = (uint *)((longlong)&local_40 + lVar4);

+      puVar13 = auStack_88 + lVar4;

+      if (puVar15 == (uint *)0x0) goto LAB_11;

+LAB_12:

+      pwVar5 = local_38;

+      uVar6 = local_48[1];

+      pcVar2 = *(code **)(*plVar1 + 0x78);

+      *(uint *)(puVar14 + 0x30) = uVar18;

+      *(uint **)(puVar14 + 0x28) = local_48 + 1;

+      uVar7 = *(undefined8 *)(param_1 + 0x70);

+      *(uint *)(puVar14 + 0x20) = uVar6;

+      *(undefined8 *)(puVar14 + -8) = 0x1800055e0;

+      uVar18 = (*pcVar2)(uVar7,0,pwVar5,puVar15);

+      uVar6 = local_48[1];

+      uVar8 = (ulonglong)uVar18;

+      puVar17 = puVar11;

+      if (-1 < (int)uVar18) {

+        local_40 = puVar15;

+        if (*(int *)(param_1 + 0x90) != 0) goto LAB_3;

+        *(undefined8 *)(puVar14 + -8) = 0x18000567b;

+        uVar8 = VerifyEccPrivateBlobFull((int *)puVar15,uVar6,(int *)0x0);

+        uVar18 = (uint)uVar8;

+        uVar8 = uVar8 & 0xffffffff;

+        puVar17 = puVar16;

+        if (uVar18 != 0) goto LAB_4;

+        uVar6 = *puVar15;

+        if (uVar6 < 0x364b4346) {

+          if (uVar6 == 0x364b4345) {

+            uVar6 = 0x354b4345;

+          }

+          else if (uVar6 == 0x324b4345) {

+            uVar6 = 0x314b4345;

+          }

+          else if (uVar6 == 0x32534345) {

+            uVar6 = 0x31534345;

+          }

+          else if (uVar6 == 0x344b4345) {

+            uVar6 = 0x334b4345;

+          }

+          else {

+            if (uVar6 != 0x34534345) goto LAB_13;

+            uVar6 = 0x33534345;

+          }

+        }

+        else if (uVar6 == 0x36534345) {

+          uVar6 = 0x35534345;

+        }

+        else if (uVar6 == 0x56444345) {

+          uVar6 = 0x50444345;

+        }

+        else {

+          if (uVar6 != 0x564b4345) {

+LAB_13:

+            uVar8 = 0x8009002d;

+            uVar18 = 0x8009002d;

+            puVar17 = puVar11;

+            goto LAB_4;

+          }

+          uVar6 = 0x504b4345;

+        }

+        local_48[0] = puVar15[5] + 0x20 + puVar15[4] * 7 + puVar15[7] + puVar15[6];

+        puVar13 = puVar14;

+        puVar17 = puVar11;

+        uVar18 = local_48[0];

+        if (((local_48[0] == 0) || (puVar17 = puVar16, g_ulMaxStackAllocSize < local_48[0])) ||

+           (uVar8 = g_ulAdditionalProbeSize + 8 + (ulonglong)local_48[0], uVar8 < local_48[0])) {

+LAB_14:

+          puVar14 = puVar13;

+          if (uVar18 + 8 < uVar18) {

+LAB_15:

+            if (puVar17 != (uint *)0x0) goto LAB_16;

+          }

+          else {

+            *(undefined8 *)(puVar13 + -8) = 0x1800057b9;

+            puVar17 = (uint *)(*g_pfnAllocate)(uVar18 + 8);

+            if (puVar17 != (uint *)0x0) {

+              *puVar17 = 0x70616548;

+              puVar17 = puVar17 + 2;

+              goto LAB_15;

+            }

+          }

+          uVar8 = 0x8009000e;

+          uVar18 = 0x8009000e;

+          goto LAB_4;

+        }

+        *(undefined8 *)(puVar14 + -8) = 0x180005755;

+        uVar7 = VerifyStackAvailable(uVar8);

+        uVar18 = local_48[0];

+        puVar17 = puVar11;

+        if ((int)uVar7 == 0) goto LAB_14;

+        uVar8 = (ulonglong)(local_48[0] + 8) + 0xf;

+        if (uVar8 <= local_48[0] + 8) {

+          uVar8 = 0xffffffffffffff0;

+        }

+        *(undefined8 *)(puVar14 + -8) = 0x18000577d;

+        lVar4 = -(uVar8 & 0xfffffffffffffff0);

+        puVar13 = puVar14 + lVar4;

+        puVar17 = (uint *)0x0;

+        if ((undefined4 *)(puVar14 + lVar4 + 0x40) == (undefined4 *)0x0) goto LAB_14;

+        *(undefined4 *)(puVar14 + lVar4 + 0x40) = 0x6b637453;

+        puVar17 = (uint *)(puVar14 + lVar4 + 0x48);

+        puVar13 = puVar14 + lVar4;

+        puVar14 = puVar14 + lVar4;

+        uVar18 = local_48[0];

+        if (puVar17 == (uint *)0x0) goto LAB_14;

+LAB_16:

+        puVar17[4] = puVar15[4];

+        puVar17[1] = 1;

+        puVar17[2] = puVar15[2];

+        puVar17[3] = puVar15[3];

+        puVar17[5] = puVar15[5];

+        puVar17[6] = puVar15[6];

+        puVar17[7] = puVar15[7];

+        *puVar17 = uVar6;

+        uVar8 = (ulonglong)local_48[0];

+        *(undefined8 *)(puVar14 + -8) = 0x180005827;

+        memcpy(puVar17 + 8,puVar15 + 8,uVar8 - 0x20);

+        goto LAB_8;

+      }

+      goto LAB_4;

     }

-  }

-LAB_2:

-  in_stack_00000068 = ppuVar5;

-  ppuVar5 = in_stack_00000068;

-  uVar15 = (uint)unaff_R12;

-  pwVar20 = (wchar_t *)unaff_R12;

-  if (((((unaff_ESI - 0x3000aU < 2) &&

-        (pUVar22 = (ULONG *)unaff_RBP[-0x10], pUVar22 != (ULONG *)0x0)) && (*pUVar22 == uVar15)) &&

-      ((uVar14 = pUVar22[1], uVar14 != 0 && (*(longlong *)(pUVar22 + 2) != 0)))) && (uVar14 != 0)) {

-    uVar9 = (ulonglong)unaff_R12 & 0xffffffff;

-    pwVar20 = (wchar_t *)((ulonglong)unaff_R12 & 0xffffffff);

-    plVar12 = (longlong *)(*(longlong *)(pUVar22 + 2) + 8);

-    uVar19 = (ulonglong)uVar14;

-    do {

-      uVar14 = *(int *)((longlong)plVar12 + -4) - 0x3c;

-      in_RDX = (undefined **)(ulonglong)uVar14;

-      if (uVar14 == 0) {

-        ppuVar21 = (undefined **)*plVar12;

-        if ((ppuVar21 == (undefined **)0x0) || (uVar14 = *(uint *)(plVar12 + -1), uVar14 < 2)) {

-LAB_5:

-          in_RDX = (undefined **)*plVar12;

-          if ((in_RDX != (undefined **)0x0) && (*(uint *)(plVar12 + -1) != 0)) {

-            uVar9 = (ulonglong)*(uint *)(plVar12 + -1);

-            pwVar20 = L"ECCParameters";

-            unaff_R12 = in_RDX;

-          }

-        }

-        else {

-          in_RDX = (undefined **)(ulonglong)(uVar14 >> 1);

-          do {

-            uVar15 = (int)in_RDX - 1;

-            in_RDX = (undefined **)(ulonglong)uVar15;

-            if (*(short *)((longlong)ppuVar21 + (longlong)in_RDX * 2) == 0) {

-              uVar9 = (ulonglong)uVar14;

-              pwVar20 = L"ECCCurveName";

-              unaff_R12 = ppuVar21;

-              break;

-            }

-          } while (uVar15 != 0);

-        }

-      }

-      else if (uVar14 == 1) goto LAB_5;

-      plVar12 = plVar12 + 2;

-      uVar15 = (uint)uVar9;

-      uVar19 = uVar19 - 1;

-    } while (uVar19 != 0);

-    ppuVar21 = (undefined **)unaff_RBP[-5];

-    unaff_RBP[-0xf] = unaff_R12;

-    if (unaff_R12 != (undefined **)0x0) {

-      in_RDX = in_stack_00000068;

-      uVar19 = SPCryptSetKeyProperty

-                         ((uint *)unaff_RBP[-4],(uint *)in_stack_00000068,(char *)pwVar20,

-                          (ulonglong *)unaff_R12,uVar15,0x80000000);

-      uVar14 = (uint)uVar19;

-      uVar19 = uVar19 & 0xffffffff;

-      unaff_RBP[-0xf] = unaff_R12;

-      if (uVar14 != 0) goto LAB_3;

+LAB_11:

+    uVar6 = local_48[1] + 8;

+    if (uVar6 < local_48[1]) {

+LAB_17:

+      puVar14 = puVar13;

+      if (puVar15 != (uint *)0x0) goto LAB_12;

     }

-  }

-  ppuVar18 = in_stack_00000068;

-  if (in_stack_00000064 == 0) {

-    uVar1 = *(uint *)(unaff_RBP + 0x19);

-    if ((uVar1 & 0x706a0) == 0) {

-      if (unaff_R12 == (undefined **)0x0) {

-LAB_6:

-        ppuVar13 = (undefined **)in_stack_00000068[0xb];

-      }

-      else {

-        puVar3 = (undefined8 *)in_stack_00000068[8];

-        unaff_RBP[-0x10] = 0;

-        uVar14 = BCryptOpenAlgorithmProvider

-                           ((BCRYPT_ALG_HANDLE *)(unaff_RBP + -0x10),(LPCWSTR)*puVar3,

-                            L"Microsoft Primitive Provider",0);

-        if ((uVar14 != 0) ||

-           (uVar14 = BCryptSetProperty((BCRYPT_HANDLE)unaff_RBP[-0x10],pwVar20,

-                                       (PUCHAR)unaff_RBP[-0xf],uVar15,0), uVar14 != 0)) {

-          uVar19 = (ulonglong)uVar14;

-          DebugTraceError(uVar14,"Status",

-                          "onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\property.c");

-          if ((BCRYPT_ALG_HANDLE)unaff_RBP[-0x10] != (BCRYPT_ALG_HANDLE)0x0) {

-            BCryptCloseAlgorithmProvider((BCRYPT_ALG_HANDLE)unaff_RBP[-0x10],0);

-          }

-          if (uVar14 != 0) goto LAB_3;

-          goto LAB_6;

-        }

-        ppuVar13 = (undefined **)unaff_RBP[-0x10];

-        unaff_RBP[-0x10] = 0;

-        ppuVar21 = ppuVar13;

-        if (ppuVar13 == (undefined **)0x0) goto LAB_6;

-      }

-      uVar14 = BCryptImportKeyPair(ppuVar13,(BCRYPT_KEY_HANDLE)0x0,in_stack_00000078,

-                                   in_stack_00000068 + 0xd,(PUCHAR)unaff_RBP[-0xe],

-                                   *(ULONG *)(unaff_RBP + 0x18),*(ULONG *)(unaff_RBP + -0xb));

-      uVar19 = (ulonglong)uVar14;

-      if (uVar14 == 0) {

-        pUVar22 = (ULONG *)(unaff_RBP + -6);

-        pbOutput = (uint *)((longlong)in_stack_00000068 + 0x1c);

-        uVar14 = BCryptGetProperty(in_stack_00000068[0xd],L"KeyStrength",(PUCHAR)pbOutput,4,pUVar22,

-                                   0);

-        uVar11 = (undefined4)((ulonglong)pUVar22 >> 0x20);

-        uVar19 = (ulonglong)uVar14;

-        if (uVar14 == 0) goto LAB_7;

-      }

-      goto LAB_3;

+    else {

+      *(undefined8 *)(puVar13 + -8) = 0x180005629;

+      puVar9 = (undefined4 *)(*g_pfnAllocate)(uVar6);

+      if (puVar9 != (undefined4 *)0x0) {

+        *puVar9 = 0x70616548;

+        puVar15 = puVar9 + 2;

+        goto LAB_17;

+      }

     }

-    uVar19 = 0x80090009;

-    uVar11 = 0x80090009;

-LAB_8:

-    pcVar16 = "Status";

-    DebugTraceError(uVar11,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c")

-    ;

+    uVar8 = 0x8009000e;

+    uVar10 = 0x8009000e;

   }

   else {

-    if (unaff_RBP[-10] == 0) {

-      uVar1 = *(uint *)(unaff_RBP + 0x19);

-    }

-    else {

-      ppuVar13 = in_stack_00000068 + 9;

-      uVar14 = GetUserStorageArea((ulonglong)*(uint *)(in_stack_00000068 + 4),in_RDX,

-                                  *(int *)(in_stack_00000068 + 0x42),*(void **)unaff_RBP[-3],

-                                  (longlong *)ppuVar13);

-      uVar11 = (undefined4)((ulonglong)ppuVar13 >> 0x20);

-      uVar19 = (ulonglong)uVar14;

-      if (uVar14 != 0) goto LAB_3;

-      uVar1 = *(uint *)(unaff_RBP + 0x19);

-      if (-1 < (char)uVar1) {

-        uVar14 = KspCheckKeyDoesNotExist((longlong)in_stack_00000068);

-        uVar19 = (ulonglong)uVar14;

-        if (uVar14 != 0) goto LAB_3;

-        uVar1 = *(uint *)(unaff_RBP + 0x19);

-      }

-    }

-    pbOutput = (uint *)unaff_RBP[-0xe];

-    uVar9 = SetPrivateKeyProperty

-                      ((longlong)in_stack_00000068,in_stack_00000078,pbOutput,

-                       *(uint *)(unaff_RBP + 0x18));

-    if ((int)uVar9 != 0) {

-      uVar19 = 0x80090029;

-      uVar11 = 0x80090029;

-      goto LAB_8;

-    }

-    if ((uVar1 & 0x400) != 0) {

-LAB_7:

-      if ((uVar1 & 0x400) == 0) goto LAB_9;

-      uVar7 = 0;

+    local_68 = 0;

+    uVar6 = (**(code **)(*plVar1 + 0x18))

+                      (*(undefined8 *)(param_1 + 0x70),L"ECCParameters",

+                       *(longlong *)(param_1 + 0x228),*(undefined4 *)(param_1 + 0x230));

+    uVar8 = (ulonglong)uVar6;

+    if (uVar6 == 0) goto LAB_0;

+LAB_1:

+    uVar10 = (undefined4)uVar8;

+  }

+  *(undefined8 *)(puVar13 + -8) = 0x180005479;

+  DebugTraceError(uVar10,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c");

 LAB_10:

-      *(undefined4 *)((longlong)in_stack_00000068 + 0x2c) = uVar7;

-      in_stack_00000068 = (undefined **)0x0;

-      *(undefined ***)unaff_RBP[-7] = ppuVar5;

-      pwVar20 = L"UNKNOWN";

-      unaff_RBP[-2] = 0;

-      unaff_RBP[-1] = 0;

-      *unaff_RBP = 0;

-      unaff_RBP[1] = 0;

-      unaff_RBP[2] = 0;

-      unaff_RBP[3] = 0;

-      unaff_RBP[4] = 0;

-      unaff_RBP[5] = 0;

-      if (ppuVar5 != (undefined **)0x0) {

-        if ((undefined8 *)ppuVar5[8] != (undefined8 *)0x0) {

-          pwVar20 = *(wchar_t **)ppuVar5[8];

-        }

-        puVar4 = ppuVar5[1];

-        if (*(int *)(ppuVar5 + 4) == 0) {

-          uVar14 = 0x9c4;

-        }

-        else {

-          uVar14 = 0x9c3;

-        }

-        if (puVar4 != (undefined *)0x0) {

-          uVar10 = CryptAuditTranslateString(0x9a1,(STRSAFE_LPWSTR)(unaff_RBP + -2));

-          iVar8 = (int)uVar10;

-          if (-1 < iVar8) {

-            uVar10 = CryptAuditTranslateString(uVar14,(STRSAFE_LPWSTR)(unaff_RBP + 2));

-            iVar8 = (int)uVar10;

-            if (-1 < iVar8) {

-              uVar19 = 0;

-              if (((g_pAuditingFuncs != 0) && (*(longlong *)(g_pAuditingFuncs + 0x18) != 0)) &&

-                 (iVar8 = (*(code *)(undefined *)0x18000e7e0)

-                                    (1,L"Microsoft Software Key Storage Provider",pwVar20,puVar4,

-                                     unaff_RBP + 2), iVar8 < 0)) {

-                DebugTraceError(iVar8,"Status",

-                                "onecore\\ds\\security\\cryptoapi\\ncrypt\\common\\audit.c");

-              }

-              goto LAB_11;

-            }

-          }

-          DebugTraceError(iVar8,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\common\\audit.c"

-                         );

-          uVar19 = 0;

-          goto LAB_11;

-        }

-      }

-      uVar19 = 0;

-      if (((undefined **)WPP_GLOBAL_Control != &WPP_GLOBAL_Control) &&

-         ((WPP_GLOBAL_Control[0x1c] & 1) != 0)) {

-        WPP_SF_sDsd(*(undefined8 *)(WPP_GLOBAL_Control + 0x10),

-                    "onecore\\ds\\security\\cryptoapi\\ncrypt\\common\\audit.c",pbOutput,"Status",

-                    CONCAT44(uVar11,0xc000000d),

-                    "onecore\\ds\\security\\cryptoapi\\ncrypt\\common\\audit.c");

-      }

-      goto LAB_11;

-    }

-    uVar9 = ImportKey((longlong)in_stack_00000068,*(uint *)(unaff_RBP + -0xb));

-    if ((int)uVar9 != 0) {

-      uVar19 = 0x80090029;

-      uVar11 = 0x80090029;

-      goto LAB_8;

-    }

-    pbOutput = &stack0x00000074;

-    uVar19 = CheckIfLegacyStorageRequired((longlong)in_stack_00000068,uVar1,pbOutput);

-    uVar14 = (uint)uVar19;

-    uVar19 = uVar19 & 0xffffffff;

-    if (-1 < (int)uVar14) {

-      if (ppuVar18[1] != (undefined *)0x0) {

-        pbOutput = (uint *)0x5;

-        uVar14 = WriteKeyToStore((longlong)ppuVar18,1,5);

-        uVar19 = (ulonglong)uVar14;

-        if (uVar14 != 0) goto LAB_3;

-        ppuVar18 = in_stack_00000068;

-        if (in_stack_00000074 != 0) {

-          piVar23 = (int *)&stack0x00000070;

-          DVar6 = ReadLegacyKeyFile(unaff_R13,(longlong)in_stack_00000068,0,in_stack_00000068[9],

-                                    piVar23,(char *)(unaff_RBP + -0xc),&stack0x00000074);

-          uVar11 = (undefined4)((ulonglong)piVar23 >> 0x20);

-          if (DVar6 == 0) {

-            pbOutput = (uint *)(ulonglong)in_stack_00000074;

-            lVar17 = unaff_RBP[-0xc];

-          }

-          else {

-            lVar17 = 0;

-            unaff_RBP[-0xc] = 0;

-            pbOutput = (uint *)0x0;

-          }

-          if (*(int *)(in_stack_00000068[8] + 0x20) == 0x30001) {

-            DVar6 = WriteRsaKeyToLegacyStore((longlong)in_stack_00000068,lVar17,(uint)pbOutput);

-            if (((DVar6 != 0) && ((undefined **)WPP_GLOBAL_Control != &WPP_GLOBAL_Control)) &&

-               ((WPP_GLOBAL_Control[0x1c] & 2) != 0)) {

-              pbOutput = (uint *)&WPP_2a92973c821e386a71dc9d2eb8ffd7d3_Traceguids;

-              WPP_SF_D(*(undefined8 *)(WPP_GLOBAL_Control + 0x10),0x13,

-                       &WPP_2a92973c821e386a71dc9d2eb8ffd7d3_Traceguids,DVar6);

-            }

-          }

-          else if (((undefined **)WPP_GLOBAL_Control != &WPP_GLOBAL_Control) &&

-                  ((WPP_GLOBAL_Control[0x1c] & 2) != 0)) {

-            pbOutput = (uint *)&WPP_2a92973c821e386a71dc9d2eb8ffd7d3_Traceguids;

-            WPP_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x10),0x14,

-                    &WPP_2a92973c821e386a71dc9d2eb8ffd7d3_Traceguids);

-          }

-        }

-      }

-LAB_9:

-      uVar7 = 1;

-      in_stack_00000068 = ppuVar18;

-      goto LAB_10;

-    }

-LAB_3:

-    pcVar16 = "Status";

-    DebugTraceError(uVar14,"Status","onecore\\ds\\security\\cryptoapi\\ncrypt\\storage\\provider.c")

-    ;

-    if ((int)uVar19 == -0x7ff6ffd2) goto LAB_11;

-  }

-  if (in_stack_00000068 != (undefined **)0x0) {

-    KspCryptAuditKeyMigrationOperation(0,pcVar16,(longlong)in_stack_00000068,0x9a1,(int)uVar19);

-  }

-LAB_11:

-  if (unaff_RBP[-0xc] != 0) {

-    RtlFreeHeap(*(undefined8 *)((longlong)ProcessEnvironmentBlock + 0x30),0,unaff_RBP[-0xc]);

-  }

-  if (unaff_RBP[-8] != 0) {

-    RtlFreeHeap(*(undefined8 *)((longlong)ProcessEnvironmentBlock + 0x30),0,unaff_RBP[-8]);

-  }

-  if (in_stack_00000068 != (undefined **)0x0) {

-    DeleteKeyObject((undefined1 *)in_stack_00000068);

-  }

-  if (ppuVar21 != (undefined **)0x0) {

-    BCryptCloseAlgorithmProvider(ppuVar21,0);

-  }

-  if (unaff_R13 != 0) {

-    RtlReleaseResource(unaff_R13 + 0x40);

-  }

-  return uVar19;

+  *(undefined8 *)(puVar13 + -8) = 0x180005b38;

+  return uVar8;

 }
```
