Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DSAImplementation.cs
Go to the documentation of this file.
2using System.IO;
5
7
8internal static class DSAImplementation
9{
10 public sealed class DSACng : DSA
11 {
13
14 private int _lastKeySize;
15
16 private bool _disposed;
17
18 private static readonly KeySizes[] s_legalKeySizes = new KeySizes[1]
19 {
20 new KeySizes(512, 3072, 64)
21 };
22
23 private static readonly int s_defaultKeySize = (Supports2048KeySize() ? 2048 : 1024);
24
25 public override KeySizes[] LegalKeySizes => base.LegalKeySizes;
26
27 public override string SignatureAlgorithm => "DSA";
28
29 public override string KeyExchangeAlgorithm => null;
30
31 private void ThrowIfDisposed()
32 {
33 if (_disposed)
34 {
35 throw new ObjectDisposedException("RSA");
36 }
37 }
38
40 {
42 int keySize = KeySize;
43 if (_lastKeySize != keySize)
44 {
45 if (_keyHandle != null)
46 {
48 }
50 _lastKeySize = keySize;
51 }
53 }
54
55 private byte[] ExportKeyBlob(bool includePrivateParameters)
56 {
57 string blobType = (includePrivateParameters ? "PRIVATEBLOB" : "PUBLICBLOB");
59 return CngKeyLite.ExportKeyBlob(keyHandle, blobType);
60 }
61
62 private byte[] ExportEncryptedPkcs8(ReadOnlySpan<char> pkcs8Password, int kdfCount)
63 {
65 return CngKeyLite.ExportPkcs8KeyBlob(keyHandle, pkcs8Password, kdfCount);
66 }
67
68 private bool TryExportEncryptedPkcs8(ReadOnlySpan<char> pkcs8Password, int kdfCount, Span<byte> destination, out int bytesWritten)
69 {
71 return CngKeyLite.TryExportPkcs8KeyBlob(keyHandle, pkcs8Password, kdfCount, destination, out bytesWritten);
72 }
73
74 private void ImportKeyBlob(byte[] dsaBlob, bool includePrivate)
75 {
77 string blobType = (includePrivate ? "PRIVATEBLOB" : "PUBLICBLOB");
78 SafeNCryptKeyHandle keyHandle = CngKeyLite.ImportKeyBlob(blobType, dsaBlob);
79 SetKeyHandle(keyHandle);
80 }
81
82 private void SetKeyHandle(SafeNCryptKeyHandle keyHandle)
83 {
84 _keyHandle = keyHandle;
85 int keyLength = CngKeyLite.GetKeyLength(keyHandle);
86 ForceSetKeySize(keyLength);
87 _lastKeySize = keyLength;
88 }
89
90 protected override void Dispose(bool disposing)
91 {
92 if (disposing)
93 {
95 _keyHandle = null;
96 _disposed = true;
97 }
98 base.Dispose(disposing);
99 }
100
101 public DSACng()
102 : this(s_defaultKeySize)
103 {
104 }
105
106 public DSACng(int keySize)
107 {
109 KeySize = keySize;
110 }
111
112 protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
113 {
114 return CngCommon.HashData(data, offset, count, hashAlgorithm);
115 }
116
117 protected override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
118 {
119 return CngCommon.HashData(data, hashAlgorithm);
120 }
121
122 protected override bool TryHashData(ReadOnlySpan<byte> source, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
123 {
124 return CngCommon.TryHashData(source, destination, hashAlgorithm, out bytesWritten);
125 }
126
127 private void ForceSetKeySize(int newKeySize)
128 {
129 KeySizeValue = newKeySize;
130 }
131
132 private static bool Supports2048KeySize()
133 {
134 Version version = Environment.OSVersion.Version;
135 return version.Major > 6 || (version.Major == 6 && version.Minor >= 2);
136 }
137
138 public override void ImportParameters(DSAParameters parameters)
139 {
140 if (parameters.P == null || parameters.Q == null || parameters.G == null || parameters.Y == null)
141 {
143 }
144 if (parameters.J != null && parameters.J.Length >= parameters.P.Length)
145 {
147 }
148 bool flag = parameters.X != null;
149 int num = parameters.P.Length;
150 int num2 = num * 8;
151 if (parameters.G.Length != num || parameters.Y.Length != num)
152 {
154 }
155 if (flag && parameters.X.Length != parameters.Q.Length)
156 {
158 }
159 byte[] blob;
160 if (num2 <= 1024)
161 {
162 GenerateV1DsaBlob(out blob, parameters, num, flag);
163 }
164 else
165 {
166 GenerateV2DsaBlob(out blob, parameters, num, flag);
167 }
168 ImportKeyBlob(blob, flag);
169 }
170
171 public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead)
172 {
174 base.ImportEncryptedPkcs8PrivateKey(passwordBytes, source, out bytesRead);
175 }
176
177 public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead)
178 {
180 base.ImportEncryptedPkcs8PrivateKey(password, source, out bytesRead);
181 }
182
183 public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters)
184 {
185 if (pbeParameters == null)
186 {
187 throw new ArgumentNullException("pbeParameters");
188 }
189 return CngPkcs8.ExportEncryptedPkcs8PrivateKey(this, passwordBytes, pbeParameters);
190 }
191
192 public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters)
193 {
194 if (pbeParameters == null)
195 {
196 throw new ArgumentNullException("pbeParameters");
197 }
199 if (CngPkcs8.IsPlatformScheme(pbeParameters))
200 {
201 return ExportEncryptedPkcs8(password, pbeParameters.IterationCount);
202 }
203 return CngPkcs8.ExportEncryptedPkcs8PrivateKey(this, password, pbeParameters);
204 }
205
206 public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)
207 {
208 if (pbeParameters == null)
209 {
210 throw new ArgumentNullException("pbeParameters");
211 }
213 return CngPkcs8.TryExportEncryptedPkcs8PrivateKey(this, passwordBytes, pbeParameters, destination, out bytesWritten);
214 }
215
216 public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)
217 {
218 if (pbeParameters == null)
219 {
220 throw new ArgumentNullException("pbeParameters");
221 }
223 if (CngPkcs8.IsPlatformScheme(pbeParameters))
224 {
225 return TryExportEncryptedPkcs8(password, pbeParameters.IterationCount, destination, out bytesWritten);
226 }
227 return CngPkcs8.TryExportEncryptedPkcs8PrivateKey(this, password, pbeParameters, destination, out bytesWritten);
228 }
229
230 private unsafe static void GenerateV1DsaBlob(out byte[] blob, DSAParameters parameters, int cbKey, bool includePrivate)
231 {
232 int num = sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB) + cbKey + cbKey + cbKey;
233 if (includePrivate)
234 {
235 num += 20;
236 }
237 blob = new byte[num];
238 fixed (byte* ptr = &blob[0])
239 {
240 global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB*)ptr;
241 ptr2->Magic = (includePrivate ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PRIVATE_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PUBLIC_MAGIC);
242 ptr2->cbKey = cbKey;
243 int offset = 8;
244 if (parameters.Seed != null)
245 {
246 if (parameters.Seed.Length != 20)
247 {
249 }
250 global::Interop.BCrypt.EmitBigEndian(blob, ref offset, parameters.Counter);
251 global::Interop.BCrypt.Emit(blob, ref offset, parameters.Seed);
252 }
253 else
254 {
255 global::Interop.BCrypt.EmitByte(blob, ref offset, byte.MaxValue, 24);
256 }
257 if (parameters.Q.Length != 20)
258 {
260 }
261 global::Interop.BCrypt.Emit(blob, ref offset, parameters.Q);
262 global::Interop.BCrypt.Emit(blob, ref offset, parameters.P);
263 global::Interop.BCrypt.Emit(blob, ref offset, parameters.G);
264 global::Interop.BCrypt.Emit(blob, ref offset, parameters.Y);
265 if (includePrivate)
266 {
267 global::Interop.BCrypt.Emit(blob, ref offset, parameters.X);
268 }
269 }
270 }
271
272 private unsafe static void GenerateV2DsaBlob(out byte[] blob, DSAParameters parameters, int cbKey, bool includePrivateParameters)
273 {
274 int num = sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2) + ((parameters.Seed == null) ? parameters.Q.Length : parameters.Seed.Length) + parameters.Q.Length + parameters.P.Length + parameters.G.Length + parameters.Y.Length + (includePrivateParameters ? parameters.X.Length : 0);
275 blob = new byte[num];
276 fixed (byte* ptr = &blob[0])
277 {
278 global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2* ptr2 = (global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2*)ptr;
279 ptr2->Magic = (includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PRIVATE_MAGIC_V2 : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PUBLIC_MAGIC_V2);
280 ptr2->cbKey = cbKey;
281 ptr2->hashAlgorithm = parameters.Q.Length switch
282 {
283 20 => global::Interop.BCrypt.HASHALGORITHM_ENUM.DSA_HASH_ALGORITHM_SHA1,
284 32 => global::Interop.BCrypt.HASHALGORITHM_ENUM.DSA_HASH_ALGORITHM_SHA256,
285 64 => global::Interop.BCrypt.HASHALGORITHM_ENUM.DSA_HASH_ALGORITHM_SHA512,
287 };
288 ptr2->standardVersion = global::Interop.BCrypt.DSAFIPSVERSION_ENUM.DSA_FIPS186_3;
289 int offset = sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2) - 4;
290 if (parameters.Seed != null)
291 {
292 global::Interop.BCrypt.EmitBigEndian(blob, ref offset, parameters.Counter);
293 ptr2->cbSeedLength = parameters.Seed.Length;
294 ptr2->cbGroupSize = parameters.Q.Length;
295 global::Interop.BCrypt.Emit(blob, ref offset, parameters.Seed);
296 }
297 else
298 {
299 global::Interop.BCrypt.EmitByte(blob, ref offset, byte.MaxValue, 4);
300 int count = (ptr2->cbSeedLength = parameters.Q.Length);
301 ptr2->cbGroupSize = parameters.Q.Length;
302 global::Interop.BCrypt.EmitByte(blob, ref offset, byte.MaxValue, count);
303 }
304 global::Interop.BCrypt.Emit(blob, ref offset, parameters.Q);
305 global::Interop.BCrypt.Emit(blob, ref offset, parameters.P);
306 global::Interop.BCrypt.Emit(blob, ref offset, parameters.G);
307 global::Interop.BCrypt.Emit(blob, ref offset, parameters.Y);
308 if (includePrivateParameters)
309 {
310 global::Interop.BCrypt.Emit(blob, ref offset, parameters.X);
311 }
312 }
313 }
314
315 public unsafe override DSAParameters ExportParameters(bool includePrivateParameters)
316 {
317 byte[] array = ExportKeyBlob(includePrivateParameters);
318 global::Interop.BCrypt.KeyBlobMagicNumber keyBlobMagicNumber = (global::Interop.BCrypt.KeyBlobMagicNumber)BitConverter.ToInt32(array, 0);
319 CheckMagicValueOfKey(keyBlobMagicNumber, includePrivateParameters);
320 DSAParameters result = default(DSAParameters);
321 fixed (byte* ptr = array)
322 {
323 if (keyBlobMagicNumber == global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PUBLIC_MAGIC || keyBlobMagicNumber == global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PRIVATE_MAGIC)
324 {
325 if (array.Length < sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB))
326 {
327 throw global::Interop.NCrypt.ErrorCode.E_FAIL.ToCryptographicException();
328 }
329 global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB*)ptr;
330 int offset = 8;
331 result.Counter = BinaryPrimitives.ReadInt32BigEndian(global::Interop.BCrypt.Consume(array, ref offset, 4));
332 result.Seed = global::Interop.BCrypt.Consume(array, ref offset, 20);
333 result.Q = global::Interop.BCrypt.Consume(array, ref offset, 20);
334 result.P = global::Interop.BCrypt.Consume(array, ref offset, ptr2->cbKey);
335 result.G = global::Interop.BCrypt.Consume(array, ref offset, ptr2->cbKey);
336 result.Y = global::Interop.BCrypt.Consume(array, ref offset, ptr2->cbKey);
337 if (includePrivateParameters)
338 {
339 result.X = global::Interop.BCrypt.Consume(array, ref offset, 20);
340 }
341 }
342 else
343 {
344 if (array.Length < sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2))
345 {
346 throw global::Interop.NCrypt.ErrorCode.E_FAIL.ToCryptographicException();
347 }
348 global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2* ptr3 = (global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2*)ptr;
349 int offset = sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2) - 4;
350 result.Counter = BinaryPrimitives.ReadInt32BigEndian(global::Interop.BCrypt.Consume(array, ref offset, 4));
351 result.Seed = global::Interop.BCrypt.Consume(array, ref offset, ptr3->cbSeedLength);
352 result.Q = global::Interop.BCrypt.Consume(array, ref offset, ptr3->cbGroupSize);
353 result.P = global::Interop.BCrypt.Consume(array, ref offset, ptr3->cbKey);
354 result.G = global::Interop.BCrypt.Consume(array, ref offset, ptr3->cbKey);
355 result.Y = global::Interop.BCrypt.Consume(array, ref offset, ptr3->cbKey);
356 if (includePrivateParameters)
357 {
358 result.X = global::Interop.BCrypt.Consume(array, ref offset, ptr3->cbGroupSize);
359 }
360 }
361 if (result.Counter == -1)
362 {
363 result.Counter = 0;
364 result.Seed = null;
365 }
366 return result;
367 }
368 }
369
370 private static void CheckMagicValueOfKey(global::Interop.BCrypt.KeyBlobMagicNumber magic, bool includePrivateParameters)
371 {
372 if (includePrivateParameters)
373 {
374 if (magic != global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PRIVATE_MAGIC && magic != global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PRIVATE_MAGIC_V2)
375 {
377 }
378 }
379 else if (magic != global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PUBLIC_MAGIC && magic != global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PUBLIC_MAGIC_V2)
380 {
382 }
383 }
384
385 public unsafe override byte[] CreateSignature(byte[] rgbHash)
386 {
387 if (rgbHash == null)
388 {
389 throw new ArgumentNullException("rgbHash");
390 }
391 Span<byte> stackBuf = stackalloc byte[32];
392 ReadOnlySpan<byte> hash = AdjustHashSizeIfNecessary(rgbHash, stackBuf);
394 return keyHandle.SignHash(hash, global::Interop.NCrypt.AsymmetricPaddingMode.None, null, hash.Length * 2);
395 }
396
397 protected unsafe override bool TryCreateSignatureCore(ReadOnlySpan<byte> hash, Span<byte> destination, DSASignatureFormat signatureFormat, out int bytesWritten)
398 {
399 Span<byte> stackBuf = stackalloc byte[32];
400 ReadOnlySpan<byte> hash2 = AdjustHashSizeIfNecessary(hash, stackBuf);
401 using (SafeNCryptKeyHandle keyHandle = GetDuplicatedKeyHandle())
402 {
403 if (!keyHandle.TrySignHash(hash2, destination, global::Interop.NCrypt.AsymmetricPaddingMode.None, null, out bytesWritten))
404 {
405 bytesWritten = 0;
406 return false;
407 }
408 }
409 return signatureFormat switch
410 {
411 DSASignatureFormat.IeeeP1363FixedFieldConcatenation => true,
412 DSASignatureFormat.Rfc3279DerSequence => AsymmetricAlgorithmHelpers.TryConvertIeee1363ToDer(destination.Slice(0, bytesWritten), destination, out bytesWritten),
413 _ => throw new CryptographicException(System.SR.Cryptography_UnknownSignatureFormat, signatureFormat.ToString()),
414 };
415 }
416
417 public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
418 {
419 if (rgbHash == null)
420 {
421 throw new ArgumentNullException("rgbHash");
422 }
423 if (rgbSignature == null)
424 {
425 throw new ArgumentNullException("rgbSignature");
426 }
427 return VerifySignatureCore(rgbHash, rgbSignature, DSASignatureFormat.IeeeP1363FixedFieldConcatenation);
428 }
429
430 protected unsafe override bool VerifySignatureCore(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, DSASignatureFormat signatureFormat)
431 {
432 Span<byte> stackBuf = stackalloc byte[32];
433 ReadOnlySpan<byte> hash2 = AdjustHashSizeIfNecessary(hash, stackBuf);
434 switch (signatureFormat)
435 {
436 case DSASignatureFormat.Rfc3279DerSequence:
437 {
438 int fieldSizeBits = hash2.Length * 8;
439 signature = this.ConvertSignatureToIeeeP1363(signatureFormat, signature, fieldSizeBits);
440 break;
441 }
442 default:
443 throw new CryptographicException(System.SR.Cryptography_UnknownSignatureFormat, signatureFormat.ToString());
444 case DSASignatureFormat.IeeeP1363FixedFieldConcatenation:
445 break;
446 }
448 return keyHandle.VerifyHash(hash2, signature, global::Interop.NCrypt.AsymmetricPaddingMode.None, null);
449 }
450
452 {
453 int num = ComputeQLength();
454 if (num == hash.Length)
455 {
456 return hash;
457 }
458 if (num < hash.Length)
459 {
460 return hash.Slice(0, num);
461 }
462 int num2 = num - hash.Length;
463 stackBuf.Slice(0, num2).Clear();
464 hash.CopyTo(stackBuf.Slice(num2));
465 return stackBuf.Slice(0, num);
466 }
467
468 private unsafe int ComputeQLength()
469 {
470 byte[] array;
471 using (GetDuplicatedKeyHandle())
472 {
473 array = ExportKeyBlob(includePrivateParameters: false);
474 }
475 if (array.Length < sizeof(global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2))
476 {
477 return 20;
478 }
479 fixed (byte* ptr = array)
480 {
481 global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2* ptr2 = (global::Interop.BCrypt.BCRYPT_DSA_KEY_BLOB_V2*)ptr;
482 if (ptr2->Magic != global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PUBLIC_MAGIC_V2 && ptr2->Magic != global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_DSA_PRIVATE_MAGIC_V2)
483 {
484 return 20;
485 }
486 return ptr2->cbGroupSize;
487 }
488 }
489 }
490}
static bool TryConvertIeee1363ToDer(ReadOnlySpan< byte > input, Span< byte > destination, out int bytesWritten)
static byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm)
Definition CngCommon.cs:10
static bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
Definition CngCommon.cs:17
static int ToInt32(byte[] value, int startIndex)
static int ReadInt32BigEndian(ReadOnlySpan< byte > source)
static OperatingSystem OSVersion
static string Cryptography_InvalidDsaParameters_MismatchedPJ
Definition SR.cs:76
static string Cryptography_NotValidPrivateKey
Definition SR.cs:120
static string Cryptography_InvalidDsaParameters_QRestriction_ShortKey
Definition SR.cs:80
static string Cryptography_InvalidDsaParameters_QRestriction_LargeKey
Definition SR.cs:82
static string Cryptography_NotValidPublicOrPrivateKey
Definition SR.cs:122
static string Cryptography_InvalidDsaParameters_MismatchedQX
Definition SR.cs:74
static string Cryptography_UnknownSignatureFormat
Definition SR.cs:156
static string Cryptography_InvalidDsaParameters_MismatchedPGY
Definition SR.cs:72
static string Cryptography_InvalidDsaParameters_MissingFields
Definition SR.cs:70
static string Cryptography_InvalidDsaParameters_SeedRestriction_ShortKey
Definition SR.cs:78
Definition SR.cs:7
static bool TryExportPkcs8KeyBlob(SafeNCryptKeyHandle keyHandle, ReadOnlySpan< char > password, int kdfCount, Span< byte > destination, out int bytesWritten)
Definition CngKeyLite.cs:93
static byte[] ExportPkcs8KeyBlob(SafeNCryptKeyHandle keyHandle, ReadOnlySpan< char > password, int kdfCount)
Definition CngKeyLite.cs:85
static unsafe SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, bool encrypted=false, ReadOnlySpan< char > password=default(ReadOnlySpan< char >))
Definition CngKeyLite.cs:14
static byte[] ExportKeyBlob(SafeNCryptKeyHandle keyHandle, string blobType)
Definition CngKeyLite.cs:58
static int GetKeyLength(SafeNCryptKeyHandle keyHandle)
static SafeNCryptKeyHandle GenerateNewExportableKey(string algorithm, int keySize)
static bool IsPlatformScheme(PbeParameters pbeParameters)
Definition CngPkcs8.cs:44
static byte[] ExportEncryptedPkcs8PrivateKey(AsymmetricAlgorithm key, ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
Definition CngPkcs8.cs:53
static bool TryExportEncryptedPkcs8PrivateKey(AsymmetricAlgorithm key, ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
Definition CngPkcs8.cs:68
override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters)
static void CheckMagicValueOfKey(global::Interop.BCrypt.KeyBlobMagicNumber magic, bool includePrivateParameters)
static unsafe void GenerateV1DsaBlob(out byte[] blob, DSAParameters parameters, int cbKey, bool includePrivate)
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, ReadOnlySpan< byte > source, out int bytesRead)
byte[] ExportKeyBlob(bool includePrivateParameters)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
override byte[] HashData(Stream data, HashAlgorithmName hashAlgorithm)
override bool TryHashData(ReadOnlySpan< byte > source, Span< byte > destination, HashAlgorithmName hashAlgorithm, 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)
bool TryExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount, Span< byte > destination, out int bytesWritten)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
unsafe override bool TryCreateSignatureCore(ReadOnlySpan< byte > hash, Span< byte > destination, DSASignatureFormat signatureFormat, out int bytesWritten)
void ImportKeyBlob(byte[] dsaBlob, bool includePrivate)
ReadOnlySpan< byte > AdjustHashSizeIfNecessary(ReadOnlySpan< byte > hash, Span< byte > stackBuf)
override void ImportParameters(DSAParameters parameters)
unsafe override byte[] CreateSignature(byte[] rgbHash)
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
unsafe override DSAParameters ExportParameters(bool includePrivateParameters)
byte[] ExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount)
unsafe override bool VerifySignatureCore(ReadOnlySpan< byte > hash, ReadOnlySpan< byte > signature, DSASignatureFormat signatureFormat)
static unsafe void GenerateV2DsaBlob(out byte[] blob, DSAParameters parameters, int cbKey, bool includePrivateParameters)
static void ValidatePbeParameters(PbeParameters pbeParameters, ReadOnlySpan< char > password, ReadOnlySpan< byte > passwordBytes)
void CopyTo(Span< T > destination)
ReadOnlySpan< T > Slice(int start)
Span< T > Slice(int start)
Definition Span.cs:271