Skip to content

Commit

Permalink
Fix CNG persisted symmetric key operations
Browse files Browse the repository at this point in the history
During a code cleanup the encoding changed from UTF-16LE
to UTF-8, which is not valid for the P/Invoke.
  • Loading branch information
bartonjs authored Jul 23, 2020
1 parent 7de187a commit e8c4169
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ private void Reset()
private readonly bool _encrypting;

private static readonly CngProperty s_ECBMode =
new CngProperty(Interop.NCrypt.NCRYPT_CHAINING_MODE_PROPERTY, Encoding.UTF8.GetBytes(Interop.BCrypt.BCRYPT_CHAIN_MODE_ECB + "\0"), CngPropertyOptions.None);
new CngProperty(Interop.NCrypt.NCRYPT_CHAINING_MODE_PROPERTY, Encoding.Unicode.GetBytes(Interop.BCrypt.BCRYPT_CHAIN_MODE_ECB + "\0"), CngPropertyOptions.None);
private static readonly CngProperty s_CBCMode =
new CngProperty(Interop.NCrypt.NCRYPT_CHAINING_MODE_PROPERTY, Encoding.UTF8.GetBytes(Interop.BCrypt.BCRYPT_CHAIN_MODE_CBC + "\0"), CngPropertyOptions.None);
new CngProperty(Interop.NCrypt.NCRYPT_CHAINING_MODE_PROPERTY, Encoding.Unicode.GetBytes(Interop.BCrypt.BCRYPT_CHAIN_MODE_CBC + "\0"), CngPropertyOptions.None);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static class AesCngTests

private static readonly CngAlgorithm s_cngAlgorithm = new CngAlgorithm("AES");

[ActiveIssue("https://github.com/dotnet/runtime/issues/31092")]
[OuterLoop(/* Creates/Deletes a persisted key, limit exposure to key leaking */)]
[ConditionalTheory(nameof(SupportsPersistedSymmetricKeys))]
// AES128-ECB-NoPadding 2 blocks.
Expand Down Expand Up @@ -48,7 +47,6 @@ public static void GetKey_NonExportable()
keyName => new AesCng(keyName));
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/31092")]
[OuterLoop(/* Creates/Deletes a persisted key, limit exposure to key leaking */)]
[ConditionalFact(nameof(SupportsPersistedSymmetricKeys))]
public static void SetKey_DetachesFromPersistedKey()
Expand All @@ -75,7 +73,6 @@ public static void LoadWrongKeyType()
}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/31092")]
[OuterLoop(/* Creates/Deletes a persisted key, limit exposure to key leaking */)]
[ConditionalFact(nameof(SupportsPersistedSymmetricKeys), nameof(IsAdministrator))]
public static void VerifyMachineKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static class TripleDESCngTests

private static readonly CngAlgorithm s_cngAlgorithm = new CngAlgorithm("3DES");

[ActiveIssue("https://github.com/dotnet/runtime/issues/31092")]
[OuterLoop(/* Creates/Deletes a persisted key, limit exposure to key leaking */)]
[ConditionalTheory(nameof(SupportsPersistedSymmetricKeys))]
// 3DES192-ECB-NoPadding 2 blocks.
Expand Down Expand Up @@ -46,7 +45,6 @@ public static void GetKey_NonExportable()
keyName => new TripleDESCng(keyName));
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/31092")]
[OuterLoop(/* Creates/Deletes a persisted key, limit exposure to key leaking */)]
[ConditionalFact(nameof(SupportsPersistedSymmetricKeys))]
public static void SetKey_DetachesFromPersistedKey()
Expand All @@ -73,7 +71,6 @@ public static void LoadWrongKeyType()
}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/31092")]
[OuterLoop(/* Creates/Deletes a persisted key, limit exposure to key leaking */)]
[ConditionalFact(nameof(SupportsPersistedSymmetricKeys), nameof(IsAdministrator))]
public static void VerifyMachineKey()
Expand Down

0 comments on commit e8c4169

Please sign in to comment.