5 instantiations of CngKey
System.Security.Cryptography (5)
System\Security\Cryptography\CngKey.Create.cs (1)
61CngKey key = new CngKey(providerHandle, keyHandle);
System\Security\Cryptography\CngKey.Import.cs (2)
98CngKey key = new CngKey(providerHandle, keyHandle); 153CngKey key = new CngKey(providerHandle, keyHandle);
System\Security\Cryptography\CngKey.Open.cs (1)
48return new CngKey(providerHandle, keyHandle);
System\Security\Cryptography\CngKey.OpenHandle.cs (1)
55var key = new CngKey(providerHandle, keyHandle);
222 references to CngKey
NuGet.Packaging (8)
Signing\Authoring\SignPackageRequest.cs (1)
48public System.Security.Cryptography.CngKey? PrivateKey { get; set; }
Signing\Authoring\X509SignatureProvider.cs (2)
119private static PrimarySignature CreatePrimarySignature(CmsSigner cmsSigner, byte[] signingData, CngKey privateKey) 152private static PrimarySignature CreateRepositoryCountersignature(CmsSigner cmsSigner, PrimarySignature primarySignature, CngKey privateKey)
Signing\Cms\ICms.cs (1)
20void AddCountersignature(CmsSigner cmsSigner, CngKey privateKey);
Signing\Cms\ManagedCmsWrapper.cs (1)
56public void AddCountersignature(CmsSigner cmsSigner, CngKey privateKey)
Signing\Cms\NativeCms.cs (1)
267internal unsafe void AddCountersignature(CmsSigner cmsSigner, CngKey privateKey)
Signing\Cms\NativeUtility.cs (2)
29internal static SignedCms NativeSign(CmsSigner cmsSigner, byte[] data, CngKey privateKey) 112CngKey privateKey,
System.Core (1)
System.Core.cs (1)
204[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.CngKey))]
System.Security.Cryptography (210)
src\runtime\src\libraries\Common\src\Microsoft\Win32\SafeHandles\SafeCertContextHandleWithKeyContainerDeletion.cs (2)
62using (CngKey cngKey = CngKey.Open(keyContainerName, new CngProvider(providerName), openOpts))
src\runtime\src\libraries\Common\src\System\Security\Cryptography\CngHelpers.cs (2)
342internal static CngKey Duplicate(this SafeNCryptKeyHandle keyHandle, bool isEphemeral) 344return CngKey.Open(keyHandle, isEphemeral ? CngKeyHandleOpenOptions.EphemeralKey : CngKeyHandleOpenOptions.None);
src\runtime\src\libraries\Common\src\System\Security\Cryptography\CngPkcs8.Shared.cs (1)
8internal static bool AllowsOnlyEncryptedExport(CngKey key)
src\runtime\src\libraries\Common\src\System\Security\Cryptography\CompositeMLDsaCng.cs (7)
24/// Initializes a new instance of the <see cref="CompositeMLDsaCng"/> class by using the specified <see cref="CngKey"/>. 39public CompositeMLDsaCng(CngKey key) 45private static CompositeMLDsaAlgorithm AlgorithmFromHandle(CngKey key) => 49/// Gets a new <see cref="CngKey" /> representing the key used by the current instance. 55/// This <see cref="CngKey"/> object is not the same as the one passed to <see cref="CompositeMLDsaCng(CngKey)"/>, 58public partial CngKey GetKey();
src\runtime\src\libraries\Common\src\System\Security\Cryptography\CompositeMLDsaCng.Windows.cs (1)
8public partial CngKey GetKey() =>
src\runtime\src\libraries\Common\src\System\Security\Cryptography\ECCng.ImportExport.cs (2)
353CngKey.EcdsaCurveNameToAlgorithm(name).Algorithm switch 378CngKey.EcdhCurveNameToAlgorithm(name).Algorithm switch
src\runtime\src\libraries\Common\src\System\Security\Cryptography\MLDsaCng.cs (12)
26private CngKey _key; 29/// Initializes a new instance of the <see cref="MLDsaCng"/> class by using the specified <see cref="CngKey"/>. 44public MLDsaCng(CngKey key) 45: base(AlgorithmFromHandleWithPlatformCheck(key, out CngKey duplicateKey)) 58private static MLDsaAlgorithm AlgorithmFromHandleWithPlatformCheck(CngKey key, out CngKey duplicateKey) 68private static partial MLDsaAlgorithm AlgorithmFromHandle(CngKey key, out CngKey duplicateKey); 71/// Gets a new <see cref="CngKey" /> representing the key used by the current instance. 77/// This <see cref="CngKey"/> object is not the same as the one passed to <see cref="MLDsaCng(CngKey)"/>, 80public partial CngKey GetKey();
src\runtime\src\libraries\Common\src\System\Security\Cryptography\MLDsaCng.Windows.cs (9)
29internal MLDsaCng(CngKey key, bool transferOwnership) 40private static partial MLDsaAlgorithm AlgorithmFromHandle(CngKey key, out CngKey duplicateKey) 61private static MLDsaAlgorithm AlgorithmFromHandleNoDuplicate(CngKey key) 73private static MLDsaAlgorithm AlgorithmFromHandleImpl(CngKey key) 97public partial CngKey GetKey() 110internal CngKey KeyNoDuplicate => _key; 386CngKey key; 396key = CngKey.Import(pkcs8Source, CngKeyBlobFormat.Pkcs8PrivateBlob);
src\runtime\src\libraries\Common\src\System\Security\Cryptography\MLDsaImplementation.CreateCng.cs (3)
13internal CngKey CreateEphemeralCng() 25CngKey key = Interop.BCrypt.BCryptExportKey( 29(ReadOnlySpan<byte> keyMaterial) => CngKey.Import(keyMaterial, cngBlobFormat));
src\runtime\src\libraries\Common\src\System\Security\Cryptography\MLKemCng.cs (12)
26private CngKey _key; 29/// Initializes a new instance of the <see cref="MLKemCng"/> class by using the specified <see cref="CngKey"/>. 45public MLKemCng(CngKey key) : base(AlgorithmFromHandleWithPlatformCheck(key, out CngKey duplicateKey)) 50private static MLKemAlgorithm AlgorithmFromHandleWithPlatformCheck(CngKey key, out CngKey duplicateKey) 60private static partial MLKemAlgorithm AlgorithmFromHandle(CngKey key, out CngKey duplicateKey); 63/// Gets a new <see cref="CngKey" /> representing the key used by the current instance. 69/// This <see cref="CngKey"/> object is not the same as the one passed to <see cref="MLKemCng(CngKey)"/>, 72public partial CngKey GetKey();
src\runtime\src\libraries\Common\src\System\Security\Cryptography\MLKemCng.Windows.cs (6)
22internal MLKemCng(CngKey key, bool transferOwnership) : base(AlgorithmFromHandleNoDuplicate(key)) 32private static partial MLKemAlgorithm AlgorithmFromHandle(CngKey key, out CngKey duplicateKey) 53private static MLKemAlgorithm AlgorithmFromHandleNoDuplicate(CngKey key) 65private static MLKemAlgorithm AlgorithmFromHandleImpl(CngKey key) 89public partial CngKey GetKey()
src\runtime\src\libraries\Common\src\System\Security\Cryptography\SlhDsaCng.cs (6)
28/// Initializes a new instance of the <see cref="SlhDsaCng"/> class by using the specified <see cref="CngKey"/>. 43public SlhDsaCng(CngKey key) : base(SlhDsaAlgorithm.SlhDsaShake256f) // We need to pass something to the base so we can throw PNSE. 50/// Gets a new <see cref="CngKey" /> representing the key used by the current instance. 56/// This <see cref="CngKey"/> object is not the same as the one passed to <see cref="SlhDsaCng(CngKey)"/>, 59public CngKey GetKey()
src\runtime\src\libraries\Common\src\System\Security\Cryptography\X509Certificates\CertificateHelpers.Windows.cs (10)
37CngKey key = mldsaCng.KeyNoDuplicate; 49using (CngKey clonedKey = mldsaImplementation.CreateEphemeralCng()) 64CngKey clonedCngKey = clonedKey.KeyNoDuplicate; 77internal static T? GetPrivateKey<T>(TCertificate certificate, Func<CspParameters, T> createCsp, Func<CngKey, T?> createCng) 86CngKey cngKey = CngKey.OpenNoDuplicate(ncryptKey, cngHandleOptions); 112CngKey cngKey = CngKey.Open(keyName, new CngProvider(keyStorageProvider)); 254internal static unsafe TCertificate? CopyWithPersistedCngKey(TCertificate certificate, CngKey cngKey) 300internal static TCertificate CopyWithEphemeralKey(TCertificate certificate, CngKey cngKey)
src\runtime\src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.Pkcs12.cs (2)
739CngKey? cngKey = null; 747cngKey = CngKey.Create(
System\Security\Cryptography\AesCng.Windows.cs (4)
19private CngKey? _key; 46/// Initializes a new instance of the <see cref="AesCng"/> class with the specified <see cref="CngKey"/>. 67public AesCng(CngKey key) 71CngKey duplicate = CngHelpers.Duplicate(key.HandleNoDuplicate, key.IsEphemeral);
System\Security\Cryptography\BasicSymmetricCipherLiteNCrypt.cs (2)
26private CngKey _key; 32Func<CngKey> cngKeyFactory,
System\Security\Cryptography\BasicSymmetricCipherNCrypt.cs (1)
18public BasicSymmetricCipherNCrypt(Func<CngKey> cngKeyFactory, CipherMode cipherMode, int blockSizeInBytes, byte[]? iv, bool encrypting, int paddingSizeInBytes)
System\Security\Cryptography\CngAlgorithmCore.cs (10)
19private CngKey? _lazyKey; 27public static CngKey Duplicate(CngKey key) 29return CngKey.Open(key.HandleNoDuplicate, key.IsEphemeral ? CngKeyHandleOpenOptions.EphemeralKey : CngKeyHandleOpenOptions.None); 47public unsafe CngKey GetOrGenerateKey(int keySize, CngAlgorithm algorithm) 73_lazyKey = CngKey.Create(algorithm, null, creationParameters); 79public CngKey GetOrGenerateKey(ECCurve? curve) 98creationParameters.Parameters.Add(CngKey.GetPropertyFromNamedCurve(curve.Value)); 117_lazyKey = CngKey.Create(DefaultKeyType ?? CngAlgorithm.ECDsa, null, creationParameters); 135public void SetKey(CngKey key)
System\Security\Cryptography\CngHelpers.cs (1)
65internal static byte[] GetSymmetricKeyDataIfExportable(this CngKey cngKey, string algorithm)
System\Security\Cryptography\CngKey.Create.cs (4)
23public static CngKey Create(CngAlgorithm algorithm) 29public static CngKey Create(CngAlgorithm algorithm, string? keyName) 35public static CngKey Create(CngAlgorithm algorithm, string? keyName, CngKeyCreationParameters? creationParameters) 61CngKey key = new CngKey(providerHandle, keyHandle);
System\Security\Cryptography\CngKey.Import.cs (10)
20internal static CngKey Import(ReadOnlySpan<byte> keyBlob, CngKeyBlobFormat format) 26public static CngKey Import(byte[] keyBlob, CngKeyBlobFormat format) 31internal static CngKey Import(byte[] keyBlob, string? curveName, CngKeyBlobFormat format) 37public static CngKey Import(byte[] keyBlob, CngKeyBlobFormat format, CngProvider provider) 42internal static CngKey ImportEncryptedPkcs8( 49internal static unsafe CngKey ImportEncryptedPkcs8( 98CngKey key = new CngKey(providerHandle, keyHandle); 103internal static CngKey Import( 114internal static CngKey Import( 153CngKey key = new CngKey(providerHandle, keyHandle);
System\Security\Cryptography\CngKey.Open.cs (3)
21public static CngKey Open(string keyName) 27public static CngKey Open(string keyName, CngProvider provider) 33public static CngKey Open(string keyName, CngProvider provider, CngKeyOpenOptions openOptions)
System\Security\Cryptography\CngKey.OpenHandle.cs (3)
19public static CngKey Open(SafeNCryptKeyHandle keyHandle, CngKeyHandleOpenOptions keyHandleOpenOptions) 30internal static CngKey OpenNoDuplicate(SafeNCryptKeyHandle keyHandle, CngKeyHandleOpenOptions keyHandleOpenOptions) 55var key = new CngKey(providerHandle, keyHandle);
System\Security\Cryptography\CngPkcs8.cs (5)
10internal CngKey Key; 25CngKey key = CngKey.Import(keyBlob, CngKeyBlobFormat.Pkcs8PrivateBlob); 38CngKey key = CngKey.ImportEncryptedPkcs8(keyBlob, password);
System\Security\Cryptography\CngSymmetricAlgorithmCore.cs (8)
41using (CngKey cngKey = ProduceCngKey()) 53public CngSymmetricAlgorithmCore(ICngSymmetricAlgorithm outer, CngKey key) 85using (CngKey cngKey = ProduceCngKey()) 233Func<CngKey> cngKeyFactory, 252private UniversalCryptoTransform CreatePersistedCryptoTransformCore(Func<CngKey> cngKeyFactory, byte[]? iv, bool encrypting, PaddingMode padding, CipherMode mode, int feedbackSizeInBits) 270private readonly CngKey ProduceCngKey() 276return CngKey.Open(_keyName!, _provider!, _optionOptions); 339private CngKey? _key;
System\Security\Cryptography\DSACng.cs (3)
16/// <see cref="CngKey.AlgorithmGroup" /> must be Dsa. This constructor 24public DSACng(CngKey key) 44internal DSACng(CngKey key, bool transferOwnership)
System\Security\Cryptography\DSACng.ImportExport.cs (2)
25CngKey newKey = CngKey.Import(dsaBlob, blobFormat);
System\Security\Cryptography\DSACng.Key.cs (3)
20public CngKey Key 24CngKey key = _core.GetOrGenerateKey(KeySize, _dsnCng); 30CngKey key = value;
System\Security\Cryptography\ECCng.ImportExport.cs (12)
11internal static CngKey ImportKeyBlob(byte[] ecBlob, string curveName, bool includePrivateParameters) 14CngKey newKey = CngKey.Import(ecBlob, curveName, blobFormat); 20internal static CngKey ImportFullKeyBlob(byte[] ecBlob, bool includePrivateParameters) 23CngKey newKey = CngKey.Import(ecBlob, blobFormat); 29internal static byte[] ExportKeyBlob(CngKey key, bool includePrivateParameters) 35internal static byte[] ExportFullKeyBlob(CngKey key, bool includePrivateParameters) 42CngKey key, 81internal static ECParameters ExportExplicitParameters(CngKey key, bool includePrivateParameters) 96internal static ECParameters ExportParameters(CngKey key, bool includePrivateParameters) 139private static ECParameters ExportPrivateExplicitParameters(CngKey key)
System\Security\Cryptography\ECDiffieHellmanCng.cs (4)
24public ECDiffieHellmanCng(CngKey key) 35internal ECDiffieHellmanCng(CngKey key, bool transferOwnership) 158CngKey newKey = ECCng.ImportFullKeyBlob(ecfullKeyBlob, includePrivateParameters); 172CngKey newKey = ECCng.ImportKeyBlob(ecfullKeyBlob, curveName, includePrivateParameters);
System\Security\Cryptography\ECDiffieHellmanCng.Derive.cs (6)
17using (CngKey import = otherKey.Import()) 35using (CngKey importedKey = otherKey.Import()) 42public byte[] DeriveKeyMaterial(CngKey otherPartyPublicKey) 104using (CngKey importedKey = otherKey.Import()) 117using (CngKey importedKey = otherKey.Import()) 127public SafeNCryptSecretHandle DeriveSecretAgreementHandle(CngKey otherPartyPublicKey)
System\Security\Cryptography\ECDiffieHellmanCng.Key.cs (7)
30public CngKey Key 62CngAlgorithm alg = CngKey.EcdhCurveNameToAlgorithm(curve.Oid.FriendlyName); 63if (CngKey.IsECNamedCurve(alg.Algorithm)) 65CngKey key = _core.GetOrGenerateKey(curve); 89CngKey key = _core.GetOrGenerateKey(curve); 98private CngKey GetKey() 100CngKey key;
System\Security\Cryptography\ECDiffieHellmanCngPublicKey.cs (7)
72using (CngKey imported = CngKey.Import(publicKeyBlob, format)) 83internal static ECDiffieHellmanCngPublicKey FromKey(CngKey key) 95public CngKey Import() 100return CngKey.Import(ToByteArray(), _curveName, BlobFormat); 116using (CngKey key = Import()) 136using (CngKey key = Import())
System\Security\Cryptography\ECDsaCng.cs (5)
34/// <see cref="CngKey.AlgorithmGroup" /> must be ECDsa. This constructor 42public ECDsaCng(CngKey key) 62internal ECDsaCng(CngKey key, bool transferOwnership) 103CngKey key = ECCng.ImportFullKeyBlob(ecfullKeyBlob, includePrivateParameters); 117CngKey key = ECCng.ImportKeyBlob(ecfullKeyBlob, curveName, includePrivateParameters);
System\Security\Cryptography\ECDsaCng.Key.cs (7)
19public CngKey Key 51CngAlgorithm alg = CngKey.EcdsaCurveNameToAlgorithm(curve.Oid.FriendlyName); 52if (CngKey.IsECNamedCurve(alg.Algorithm)) 54CngKey key = _core.GetOrGenerateKey(curve); 78CngKey key = _core.GetOrGenerateKey(curve); 87private CngKey GetKey() 89CngKey key;
System\Security\Cryptography\RSACng.cs (3)
16/// <see cref="CngKey.AlgorithmGroup" /> must be Rsa. This constructor 24public RSACng(CngKey key) 44internal RSACng(CngKey key, bool transferOwnership)
System\Security\Cryptography\RSACng.ImportExport.cs (2)
22CngKey newKey = CngKey.Import(rsaBlob, blobFormat);
System\Security\Cryptography\RSACng.Key.cs (3)
20public CngKey Key 24CngKey key = _core.GetOrGenerateKey(KeySize, CngAlgorithm.Rsa); 30CngKey key = value;
System\Security\Cryptography\X25519DiffieHellmanCng.cs (6)
26/// by using the specified <see cref="CngKey"/>. 41public partial X25519DiffieHellmanCng(CngKey key); 44/// Gets a new <see cref="CngKey" /> representing the key used by the current instance. 50/// This <see cref="CngKey"/> object is not the same as the one passed to <see cref="X25519DiffieHellmanCng(CngKey)"/>, 53public partial CngKey GetKey();
System\Security\Cryptography\X25519DiffieHellmanCng.Windows.cs (4)
16private CngKey _key; 19public partial X25519DiffieHellmanCng(CngKey key) 34public partial CngKey GetKey() 159private static void ExportKeyFromBlob(CngKey key, bool privateKey, Span<byte> destination)
System\Security\Cryptography\X509Certificates\CertificateHelpers.Windows.cs (1)
39using (CngKey.Open(keyName, provider, options))
System\Security\Cryptography\X509Certificates\CertificatePal.Windows.PrivateKey.cs (7)
28delegate (CngKey cngKey) 42delegate (CngKey cngKey) 56delegate (CngKey cngKey) 65static ECDiffieHellmanCng? FromCngKey(CngKey cngKey) 285private T? GetPrivateKey<T>(Func<CspParameters, T> createCsp, Func<CngKey, T?> createCng) 291private CertificatePal? CopyWithPersistedCngKey(CngKey cngKey) => CertificateHelpers.CopyWithPersistedCngKey(this, cngKey); 293private CertificatePal CopyWithEphemeralKey(CngKey cngKey) => CertificateHelpers.CopyWithEphemeralKey(this, cngKey);
System\Security\Cryptography\X509Certificates\X509Pal.Windows.PublicKey.cs (2)
75Func<CngKey, TAlgorithm> factory, 102key = factory(CngKey.Import(keyBlob, blobFormat));
System.Security.Cryptography.Cng (1)
System.Security.Cryptography.Cng.cs (1)
12[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.CngKey))]
System.Security.Cryptography.Pkcs (2)
Internal\Cryptography\Pal\Windows\PkcsPalWindows.cs (2)
145using (CngKey cngKey = CngKey.Open(keyHandle, options))