316 {
318 global::Interop.BCrypt.KeyBlobMagicNumber keyBlobMagicNumber = (global::Interop.BCrypt.KeyBlobMagicNumber)BitConverter.ToInt32(
array, 0);
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;
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;
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 }
static int ReadInt32BigEndian(ReadOnlySpan< byte > source)
static void CheckMagicValueOfKey(global::Interop.BCrypt.KeyBlobMagicNumber magic, bool includePrivateParameters)
byte[] ExportKeyBlob(bool includePrivateParameters)