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 }
static string Cryptography_InvalidDsaParameters_QRestriction_LargeKey