376 {
377 if (parameters.Exponent == null || parameters.Modulus == null)
378 {
380 }
381 bool flag;
382 if (parameters.D == null)
383 {
384 flag = false;
385 if (parameters.P != null || parameters.DP != null || parameters.Q != null || parameters.DQ != null || parameters.InverseQ != null)
386 {
388 }
389 }
390 else
391 {
392 flag = true;
393 if (parameters.P == null || parameters.DP == null || parameters.Q == null || parameters.DQ == null || parameters.InverseQ == null)
394 {
396 }
397 int num = (parameters.Modulus.Length + 1) / 2;
398 if (parameters.D.Length != parameters.Modulus.Length || parameters.P.Length != num || parameters.Q.Length != num || parameters.DP.Length != num || parameters.DQ.Length != num || parameters.InverseQ.Length != num)
399 {
401 }
402 }
403 int num2 =
sizeof(global::Interop.BCrypt.BCRYPT_RSAKEY_BLOB) + parameters.Exponent.Length + parameters.Modulus.Length;
404 if (flag)
405 {
406 num2 += parameters.P.Length + parameters.Q.Length;
407 }
410 {
411 global::Interop.BCrypt.BCRYPT_RSAKEY_BLOB*
ptr2 = (global::Interop.BCrypt.BCRYPT_RSAKEY_BLOB*)
ptr;
412 ptr2->Magic = (flag ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_RSAPRIVATE_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_RSAPUBLIC_MAGIC);
413 ptr2->BitLength = parameters.Modulus.Length * 8;
414 ptr2->cbPublicExp = parameters.Exponent.Length;
415 ptr2->cbModulus = parameters.Modulus.Length;
416 if (flag)
417 {
418 ptr2->cbPrime1 = parameters.P.Length;
419 ptr2->cbPrime2 = parameters.Q.Length;
420 }
421 int offset =
sizeof(global::Interop.BCrypt.BCRYPT_RSAKEY_BLOB);
422 global::Interop.BCrypt.Emit(
array,
ref offset, parameters.Exponent);
423 global::Interop.BCrypt.Emit(
array,
ref offset, parameters.Modulus);
424 if (flag)
425 {
428 }
429 }
431 }
static string Cryptography_InvalidRsaParameters
void ImportKeyBlob(byte[] rsaBlob, bool includePrivate)