Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ VerifyHash() [2/2]

unsafe override bool System.Security.Cryptography.RSACng.VerifyHash ( ReadOnlySpan< byte > hash,
ReadOnlySpan< byte > signature,
HashAlgorithmName hashAlgorithm,
RSASignaturePadding padding )
inlinevirtual

Reimplemented from System.Security.Cryptography.RSA.

Definition at line 685 of file RSACng.cs.

686 {
687 string name = hashAlgorithm.Name;
688 if (string.IsNullOrEmpty(name))
689 {
691 }
692 if (padding == null)
693 {
694 throw new ArgumentNullException("padding");
695 }
697 if (hash.Length != GetHashSizeInBytes(hashAlgorithm))
698 {
699 return false;
700 }
702 try
703 {
704 switch (padding.Mode)
705 {
706 case RSASignaturePaddingMode.Pkcs1:
707 {
708 global::Interop.BCrypt.BCRYPT_PKCS1_PADDING_INFO bCRYPT_PKCS1_PADDING_INFO = default(global::Interop.BCrypt.BCRYPT_PKCS1_PADDING_INFO);
709 bCRYPT_PKCS1_PADDING_INFO.pszAlgId = intPtr;
710 global::Interop.BCrypt.BCRYPT_PKCS1_PADDING_INFO bCRYPT_PKCS1_PADDING_INFO2 = bCRYPT_PKCS1_PADDING_INFO;
711 return keyHandle.VerifyHash(hash, signature, global::Interop.NCrypt.AsymmetricPaddingMode.NCRYPT_PAD_PKCS1_FLAG, &bCRYPT_PKCS1_PADDING_INFO2);
712 }
714 {
715 global::Interop.BCrypt.BCRYPT_PSS_PADDING_INFO bCRYPT_PSS_PADDING_INFO = default(global::Interop.BCrypt.BCRYPT_PSS_PADDING_INFO);
716 bCRYPT_PSS_PADDING_INFO.pszAlgId = intPtr;
717 bCRYPT_PSS_PADDING_INFO.cbSalt = hash.Length;
718 global::Interop.BCrypt.BCRYPT_PSS_PADDING_INFO bCRYPT_PSS_PADDING_INFO2 = bCRYPT_PSS_PADDING_INFO;
719 return keyHandle.VerifyHash(hash, signature, global::Interop.NCrypt.AsymmetricPaddingMode.NCRYPT_PAD_PSS_FLAG, &bCRYPT_PSS_PADDING_INFO2);
720 }
721 default:
722 throw new CryptographicException(System.SR.Cryptography_UnsupportedPaddingMode);
723 }
724 }
725 finally
726 {
728 }
729 }
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static unsafe IntPtr StringToHGlobalUni(string? s)
Definition Marshal.cs:1310
static string Cryptography_UnsupportedPaddingMode
Definition SR.cs:160
static string Cryptography_HashAlgorithmNameNullOrEmpty
Definition SR.cs:60
Definition SR.cs:7
static int GetHashSizeInBytes(HashAlgorithmName hashAlgorithm)
Definition RSACng.cs:566
SafeNCryptKeyHandle GetDuplicatedKeyHandle()
Definition RSACng.cs:105

References System.SR.Cryptography_HashAlgorithmNameNullOrEmpty, System.SR.Cryptography_UnsupportedPaddingMode, System.Runtime.InteropServices.Marshal.FreeHGlobal(), System.Security.Cryptography.RSACng.GetDuplicatedKeyHandle(), System.Security.Cryptography.RSACng.GetHashSizeInBytes(), System.Security.Cryptography.RSASignaturePadding.Mode, System.Security.Cryptography.HashAlgorithmName.Name, and System.Runtime.InteropServices.Marshal.StringToHGlobalUni().