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