-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CngKey PCP test key creation
- Loading branch information
Showing
6 changed files
with
80 additions
and
125 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/libraries/Common/tests/System/Security/Cryptography/CngPlatformProviderKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Security.Cryptography; | ||
|
||
namespace Test.Cryptography | ||
{ | ||
internal sealed class CngPlatformProviderKey : IDisposable | ||
{ | ||
public CngPlatformProviderKey( | ||
CngAlgorithm algorithm, | ||
string keySuffix = null, | ||
[CallerMemberName] string testName = null, | ||
params CngProperty[] additionalParameters) | ||
{ | ||
CngKeyCreationParameters cngCreationParameters = new CngKeyCreationParameters | ||
{ | ||
Provider = CngProvider.MicrosoftPlatformCryptoProvider, | ||
KeyCreationOptions = CngKeyCreationOptions.OverwriteExistingKey, | ||
}; | ||
|
||
foreach (CngProperty parameter in additionalParameters) | ||
{ | ||
cngCreationParameters.Parameters.Add(parameter); | ||
} | ||
|
||
Key = CngKey.Create(algorithm, $"{testName}{algorithm.Algorithm}{keySuffix}", cngCreationParameters); | ||
} | ||
|
||
internal CngKey Key { get; } | ||
|
||
public void Dispose() | ||
{ | ||
Key.Delete(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters