10 DefaultKeyType = CngAlgorithm.ECDiffieHellman
154 base.KeySize =
value;
179 protected override void Dispose(
bool disposing)
204 private void ImportKeyBlob(
byte[] ecfullKeyBlob,
string curveName,
bool includePrivateParameters)
241 if (otherPartyPublicKey ==
null)
247 using CngKey otherPartyPublicKey2 = eCDiffieHellmanCngPublicKey.
Import();
252 eCDiffieHellmanCng.ImportParameters(parameters);
256 using CngKey otherPartyPublicKey3 = eCDiffieHellmanCngPublicKey2.
Import();
263 if (otherPartyPublicKey ==
null)
275 global::Interop.NCrypt.SecretAgreementFlags flags = (
UseSecretAgreementAsHmacKey ? global::Interop.NCrypt.SecretAgreementFlags.UseSecretAsHmacKey : global::Interop.NCrypt.SecretAgreementFlags.None);
288 return global::Interop.NCrypt.DeriveKeyMaterialTls(secretAgreement,
_label,
_seed, flags);
294 if (otherPartyPublicKey ==
null)
300 using CngKey otherPartyPublicKey2 = eCDiffieHellmanCngPublicKey.
Import();
305 eCDiffieHellmanCng.ImportParameters(parameters);
309 using CngKey otherPartyPublicKey3 = eCDiffieHellmanCngPublicKey2.
Import();
316 if (otherPartyPublicKey ==
null)
330 return global::Interop.NCrypt.DeriveSecretAgreement(privateKey, otherPartyPublicKey2);
431 if (otherPartyPublicKey ==
null)
435 if (
string.IsNullOrEmpty(hashAlgorithm.
Name))
440 return global::Interop.NCrypt.DeriveKeyMaterialHash(secretAgreement, hashAlgorithm.
Name, secretPrepend, secretAppend, global::Interop.NCrypt.SecretAgreementFlags.None);
445 if (otherPartyPublicKey ==
null)
449 if (
string.IsNullOrEmpty(hashAlgorithm.
Name))
454 global::Interop.NCrypt.SecretAgreementFlags flags = ((hmacKey ==
null) ? global::Interop.NCrypt.SecretAgreementFlags.UseSecretAsHmacKey : global::Interop.NCrypt.SecretAgreementFlags.None);
455 return global::Interop.NCrypt.DeriveKeyMaterialHmac(secretAgreement, hashAlgorithm.
Name, hmacKey, secretPrepend, secretAppend, flags);
460 if (otherPartyPublicKey ==
null)
464 if (prfLabel ==
null)
473 return global::Interop.NCrypt.DeriveKeyMaterialTls(secretAgreement, prfLabel, prfSeed, global::Interop.NCrypt.SecretAgreementFlags.None);
481 bool flag = parameters.D !=
null;
482 bool flag2 = parameters.Q.X !=
null && parameters.Q.Y !=
null;
487 byte[]
array =
new byte[parameters.
D.Length];
489 parameters2.Q.X =
array;
490 parameters2.Q.Y =
array;
509 byte[] array2 =
new byte[parameters.
D.Length];
511 parameters3.Q.X = array2;
512 parameters3.Q.Y = array2;
549 if (
string.IsNullOrEmpty(curveName))
577 bytesRead = bytesRead2;
586 bytesRead = bytesRead2;
595 bytesRead = bytesRead2;
600 if (response.GetAlgorithmGroup() !=
"ECDH")
610 if (pbeParameters ==
null)
619 if (pbeParameters ==
null)
633 if (pbeParameters ==
null)
643 if (pbeParameters ==
null)
static unsafe void Clear(Array array)
static string Cryptography_TlsRequiresLabelAndSeed
static string Cryptography_CurveNotSupported
static string Cryptography_ArgECDHRequiresECDHKey
static string Format(string resourceFormat, object p1)
static string Cryptography_NotValidPublicOrPrivateKey
static string Cryptography_ArgECDHKeySizeMismatch
static string Cryptography_InvalidCurveOid
static string Cryptography_InvalidKeySize
static string Cryptography_HashAlgorithmNameNullOrEmpty
static CngAlgorithmGroup ECDiffieHellman
static CngAlgorithm ECDiffieHellmanP256
static CngAlgorithm Sha256
static CngAlgorithm ECDiffieHellmanP384
static CngAlgorithm ECDiffieHellmanP521
bool TryExportKeyBlob(string blobType, Span< byte > destination, out int bytesWritten)
static CngAlgorithm EcdhCurveNameToAlgorithm(string name)
string GetCurveName(out string oidValue)
byte[] ExportPkcs8KeyBlob(ReadOnlySpan< char > password, int kdfCount)
static CngKey Import(ReadOnlySpan< byte > keyBlob, CngKeyBlobFormat format)
bool TryExportPkcs8KeyBlob(ReadOnlySpan< char > password, int kdfCount, Span< byte > destination, out int bytesWritten)
SafeNCryptKeyHandle Handle
CngAlgorithmGroup? AlgorithmGroup
static bool IsPlatformScheme(PbeParameters pbeParameters)
static unsafe Pkcs8Response ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
static byte[] ExportEncryptedPkcs8PrivateKey(AsymmetricAlgorithm key, ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
static Pkcs8Response ImportPkcs8PrivateKey(ReadOnlySpan< byte > source, out int bytesRead)
static bool TryExportEncryptedPkcs8PrivateKey(AsymmetricAlgorithm key, ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
static SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, string curveName, SafeNCryptProviderHandle provider)
static unsafe byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
static CngKey ImportFullKeyBlob(byte[] ecBlob, bool includePrivateParameters)
static unsafe void ExportNamedCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
static byte[] ExportKeyBlob(CngKey key, bool includePrivateParameters)
static unsafe byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
static unsafe void ExportPrimeCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
static byte[] ExportFullKeyBlob(CngKey key, bool includePrivateParameters)
static ECDiffieHellmanCngPublicKey FromKey(CngKey key)
override void ImportParameters(ECParameters parameters)
CngAlgorithm _hashAlgorithm
byte[] ExportKeyBlob(bool includePrivateParameters)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
override ECParameters ExportParameters(bool includePrivateParameters)
SafeNCryptSecretHandle DeriveSecretAgreementHandle(ECDiffieHellmanPublicKey otherPartyPublicKey)
bool UseSecretAgreementAsHmacKey
ECDiffieHellmanKeyDerivationFunction KeyDerivationFunction
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
override void Dispose(bool disposing)
override byte[] DeriveKeyFromHash(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? secretPrepend, byte[]? secretAppend)
override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
string GetCurveName(out string oidValue)
ECDiffieHellmanCng(int keySize)
void ForceSetKeySize(int newKeySize)
override ECParameters ExportExplicitParameters(bool includePrivateParameters)
override void GenerateKey(ECCurve curve)
string ToXmlString(ECKeyXmlFormat format)
byte[] ExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount)
byte[] DeriveKeyMaterial(CngKey otherPartyPublicKey)
override KeySizes[] LegalKeySizes
void ImportFullKeyBlob(byte[] ecfullKeyBlob, bool includePrivateParameters)
void ImportKeyBlob(byte[] ecfullKeyBlob, string curveName, bool includePrivateParameters)
ECDiffieHellmanCng(ECCurve curve)
void ProcessPkcs8Response(System.Security.Cryptography.CngPkcs8.Pkcs8Response response)
override byte[] DeriveKeyMaterial(ECDiffieHellmanPublicKey otherPartyPublicKey)
SafeNCryptSecretHandle DeriveSecretAgreementHandle(CngKey otherPartyPublicKey)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
override void ImportPkcs8PrivateKey(ReadOnlySpan< byte > source, out int bytesRead)
override byte[] DeriveKeyFromHmac(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? hmacKey, byte[]? secretPrepend, byte[]? secretAppend)
override bool TryExportPkcs8PrivateKey(Span< byte > destination, out int bytesWritten)
bool TryExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount, Span< byte > destination, out int bytesWritten)
byte[] ExportFullKeyBlob(bool includePrivateParameters)
ECDiffieHellmanCng(CngKey key)
void AcceptImport(System.Security.Cryptography.CngPkcs8.Pkcs8Response response)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters)
ECDiffieHellmanKeyDerivationFunction _kdf
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, ReadOnlySpan< byte > source, out int bytesRead)
void FromXmlString(string xml, ECKeyXmlFormat format)
override ECDiffieHellmanPublicKey PublicKey
virtual ECParameters ExportParameters()
static void ValidatePbeParameters(PbeParameters pbeParameters, ReadOnlySpan< char > password, ReadOnlySpan< byte > passwordBytes)
ECDiffieHellmanKeyDerivationFunction
bool IsKeyGeneratedNamedCurve()
CngKey GetOrGenerateKey(int keySize, CngAlgorithm algorithm)
static CngKey Duplicate(CngKey key)
static ECCurve CreateFromOid(Oid curveOid)