35 protected override void Dispose(
bool disposing)
41 base.Dispose(disposing);
51 string blobType = (includePrivateParameters ?
"ECCFULLPRIVATEBLOB" :
"ECCFULLPUBLICBLOB");
57 private void ImportKeyBlob(
byte[] ecKeyBlob,
string curveName,
bool includePrivateParameters)
59 string blobType = (includePrivateParameters ?
"ECCPRIVATEBLOB" :
"ECCPUBLICBLOB");
67 string blobType = (includePrivateParameters ?
"ECCPRIVATEBLOB" :
"ECCPUBLICBLOB");
74 string blobType = (includePrivateParameters ?
"ECCFULLPRIVATEBLOB" :
"ECCFULLPUBLICBLOB");
159 bool flag = parameters.D !=
null;
160 bool flag2 = parameters.Q.X !=
null && parameters.Q.Y !=
null;
165 byte[]
array =
new byte[parameters.
D.Length];
167 parameters2.Q.X =
array;
168 parameters2.Q.Y =
array;
187 byte[] array2 =
new byte[parameters.
D.Length];
189 parameters3.Q.X = array2;
190 parameters3.Q.Y = array2;
217 if (
string.IsNullOrEmpty(curveName))
237 bytesRead = bytesRead2;
246 bytesRead = bytesRead2;
255 bytesRead = bytesRead2;
260 string algorithmGroup = response.GetAlgorithmGroup();
261 if (algorithmGroup ==
"ECDSA" || algorithmGroup ==
"ECDH")
272 if (pbeParameters ==
null)
281 if (pbeParameters ==
null)
295 if (pbeParameters ==
null)
305 if (pbeParameters ==
null)
317 public unsafe
override byte[]
SignHash(
byte[] hash)
323 int estimatedSize =
KeySize switch
331 return keyHandle.SignHash(hash, global::Interop.NCrypt.AsymmetricPaddingMode.None,
null, estimatedSize);
343 if (!keyHandle.TrySignHash(hash,
destination, global::Interop.NCrypt.AsymmetricPaddingMode.None,
null, out bytesWritten))
349 return signatureFormat
switch
351 DSASignatureFormat.IeeeP1363FixedFieldConcatenation =>
true,
357 public override bool VerifyHash(
byte[] hash,
byte[] signature)
363 if (signature ==
null)
377 if (signatureFormat != 0)
379 signature = this.ConvertSignatureToIeeeP1363(signatureFormat, signature);
382 return keyHandle.VerifyHash(hash, signature, global::Interop.NCrypt.AsymmetricPaddingMode.None,
null);
static bool TryConvertIeee1363ToDer(ReadOnlySpan< byte > input, Span< byte > destination, out int bytesWritten)
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_UnknownSignatureFormat
static string Cryptography_InvalidCurveOid
static bool TryExportPkcs8KeyBlob(SafeNCryptKeyHandle keyHandle, ReadOnlySpan< char > password, int kdfCount, Span< byte > destination, out int bytesWritten)
static byte[] ExportPkcs8KeyBlob(SafeNCryptKeyHandle keyHandle, ReadOnlySpan< char > password, int kdfCount)
static unsafe SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, bool encrypted=false, ReadOnlySpan< char > password=default(ReadOnlySpan< char >))
static byte[] ExportKeyBlob(SafeNCryptKeyHandle keyHandle, string blobType)
static unsafe string GetPropertyAsString(SafeNCryptHandle ncryptHandle, string propertyName, CngPropertyOptions options)
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)
void GenerateKey(ECCurve curve)
string GetCurveName(int callerKeySizeProperty, out string oidValue)
void SetHandle(SafeNCryptKeyHandle keyHandle, string algorithmName)
SafeNCryptKeyHandle GetDuplicatedKeyHandle(int callerKeySizeProperty)
static unsafe byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
static unsafe void ExportNamedCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
static string EcdsaCurveNameToAlgorithm(string algorithm)
static unsafe byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
static unsafe void ExportPrimeCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters)
override ECParameters ExportParameters(bool includePrivateParameters)
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
override void ImportParameters(ECParameters parameters)
override bool VerifyHash(byte[] hash, byte[] signature)
override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
override KeySizes[] LegalKeySizes
unsafe override bool TrySignHashCore(ReadOnlySpan< byte > hash, Span< byte > destination, DSASignatureFormat signatureFormat, out int bytesWritten)
override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
unsafe override byte[] SignHash(byte[] hash)
override void GenerateKey(ECCurve curve)
SafeNCryptKeyHandle GetDuplicatedKeyHandle()
byte[] ExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount)
override void Dispose(bool disposing)
void AcceptImport(CngPkcs8.Pkcs8Response response)
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, ReadOnlySpan< byte > source, out int bytesRead)
override void ImportPkcs8PrivateKey(ReadOnlySpan< byte > source, out int bytesRead)
byte[] ExportFullKeyBlob(bool includePrivateParameters)
void ProcessPkcs8Response(CngPkcs8.Pkcs8Response response)
void ImportKeyBlob(byte[] ecKeyBlob, string curveName, bool includePrivateParameters)
byte[] ExportKeyBlob(bool includePrivateParameters)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
bool TryExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount, Span< byte > destination, out int bytesWritten)
void ForceSetKeySize(int newKeySize)
string GetCurveName(out string oidValue)
override bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
override bool VerifyHash(ReadOnlySpan< byte > hash, ReadOnlySpan< byte > signature)
void ImportFullKeyBlob(byte[] ecfullKeyBlob, bool includePrivateParameters)
override bool TrySignHash(ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
unsafe override bool VerifyHashCore(ReadOnlySpan< byte > hash, ReadOnlySpan< byte > signature, DSASignatureFormat signatureFormat)
override ECParameters ExportExplicitParameters(bool includePrivateParameters)
static void ValidatePbeParameters(PbeParameters pbeParameters, ReadOnlySpan< char > password, ReadOnlySpan< byte > passwordBytes)
static ECCurve CreateFromOid(Oid curveOid)