81 protected override void Dispose(
bool disposing)
115 private void ImportKeyBlob(
byte[] ecfullKeyBlob,
string curveName,
bool includePrivateParameters)
248 cngAlgorithm = num
switch
268 bool flag = parameters.D !=
null;
269 bool flag2 = parameters.Q.X !=
null && parameters.Q.Y !=
null;
274 byte[]
array =
new byte[parameters.
D.Length];
276 parameters2.Q.X =
array;
277 parameters2.Q.Y =
array;
296 byte[] array2 =
new byte[parameters.
D.Length];
298 parameters3.Q.X = array2;
299 parameters3.Q.Y = array2;
326 if (
string.IsNullOrEmpty(curveName))
346 bytesRead = bytesRead2;
355 bytesRead = bytesRead2;
364 bytesRead = bytesRead2;
369 string algorithmGroup = response.GetAlgorithmGroup();
370 if (algorithmGroup ==
"ECDSA" || algorithmGroup ==
"ECDH")
381 if (pbeParameters ==
null)
390 if (pbeParameters ==
null)
404 if (pbeParameters ==
null)
414 if (pbeParameters ==
null)
461 public unsafe
override byte[]
SignHash(
byte[] hash)
467 int estimatedSize =
KeySize switch
475 return keyHandle.SignHash(hash, global::Interop.NCrypt.AsymmetricPaddingMode.None,
null, estimatedSize);
482 if (!keyHandle.TrySignHash(
source,
destination, global::Interop.NCrypt.AsymmetricPaddingMode.None,
null, out bytesWritten))
491 public override bool VerifyHash(
byte[] hash,
byte[] signature)
497 if (signature ==
null)
507 return keyHandle.VerifyHash(hash, signature, global::Interop.NCrypt.AsymmetricPaddingMode.None,
null);
static byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
static bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
static string Cryptography_CurveNotSupported
static string Format(string resourceFormat, object p1)
static string Cryptography_NotValidPublicOrPrivateKey
static string Cryptography_ArgECDsaRequiresECDsaKey
static string Cryptography_InvalidCurveOid
static string Cryptography_InvalidKeySize
static CngAlgorithmGroup ECDsa
static CngAlgorithmGroup ECDiffieHellman
static CngAlgorithm Sha256
static CngAlgorithm ECDsaP256
static CngAlgorithm ECDsaP384
static CngAlgorithm ECDsaP521
bool TryExportKeyBlob(string blobType, Span< byte > destination, out int bytesWritten)
static CngAlgorithm EcdsaCurveNameToAlgorithm(string name)
string GetCurveName(out string oidValue)
byte[] ExportPkcs8KeyBlob(ReadOnlySpan< char > password, int kdfCount)
bool TryExportPkcs8KeyBlob(ReadOnlySpan< char > password, int kdfCount, Span< byte > destination, out int bytesWritten)
SafeNCryptKeyHandle Handle
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 bool IsEccAlgorithmGroup(CngAlgorithmGroup algorithmGroup)
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
SafeNCryptKeyHandle GetDuplicatedKeyHandle()
unsafe override bool VerifyHash(ReadOnlySpan< byte > hash, ReadOnlySpan< byte > signature)
byte[] ExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount)
override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters)
bool TryExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount, Span< byte > destination, out int bytesWritten)
void ProcessPkcs8Response(System.Security.Cryptography.CngPkcs8.Pkcs8Response response)
bool VerifyData(byte[] data, byte[] signature)
override ECParameters ExportParameters(bool includePrivateParameters)
bool VerifyData(byte[] data, int offset, int count, byte[] signature)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
unsafe override bool TrySignHash(ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, ReadOnlySpan< byte > source, out int bytesRead)
void ImportFullKeyBlob(byte[] ecfullKeyBlob, bool includePrivateParameters)
byte[] SignData(Stream data)
override void ImportPkcs8PrivateKey(ReadOnlySpan< byte > source, out int bytesRead)
byte[] ExportFullKeyBlob(bool includePrivateParameters)
unsafe override byte[] SignHash(byte[] hash)
override void ImportParameters(ECParameters parameters)
override ECParameters ExportExplicitParameters(bool includePrivateParameters)
void ImportKeyBlob(byte[] ecfullKeyBlob, string curveName, bool includePrivateParameters)
bool VerifyData(Stream data, byte[] signature)
void AcceptImport(System.Security.Cryptography.CngPkcs8.Pkcs8Response response)
byte[] ExportKeyBlob(bool includePrivateParameters)
override bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
void FromXmlString(string xml, ECKeyXmlFormat format)
byte[] SignData(byte[] data)
override KeySizes[] LegalKeySizes
override void Dispose(bool disposing)
override void GenerateKey(ECCurve curve)
CngAlgorithm _hashAlgorithm
string ToXmlString(ECKeyXmlFormat format)
override bool TryExportPkcs8PrivateKey(Span< byte > destination, out int bytesWritten)
override bool VerifyHash(byte[] hash, byte[] signature)
string GetCurveName(out string oidValue)
void ForceSetKeySize(int newKeySize)
byte[] SignData(byte[] data, int offset, int count)
static void ValidatePbeParameters(PbeParameters pbeParameters, ReadOnlySpan< char > password, ReadOnlySpan< byte > passwordBytes)
bool IsKeyGeneratedNamedCurve()
CngKey GetOrGenerateKey(int keySize, CngAlgorithm algorithm)
static CngKey Duplicate(CngKey key)
static ECCurve CreateFromOid(Oid curveOid)