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

◆ VerifyHash() [2/2]

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

Reimplemented from System.Security.Cryptography.RSA.

Definition at line 684 of file RSAImplementation.cs.

685 {
686 string name = hashAlgorithm.Name;
687 if (string.IsNullOrEmpty(name))
688 {
690 }
691 if (padding == null)
692 {
693 throw new ArgumentNullException("padding");
694 }
696 if (hash.Length != GetHashSizeInBytes(hashAlgorithm))
697 {
698 return false;
699 }
701 try
702 {
703 switch (padding.Mode)
704 {
705 case RSASignaturePaddingMode.Pkcs1:
706 {
707 global::Interop.BCrypt.BCRYPT_PKCS1_PADDING_INFO bCRYPT_PKCS1_PADDING_INFO = default(global::Interop.BCrypt.BCRYPT_PKCS1_PADDING_INFO);
708 bCRYPT_PKCS1_PADDING_INFO.pszAlgId = intPtr;
709 global::Interop.BCrypt.BCRYPT_PKCS1_PADDING_INFO bCRYPT_PKCS1_PADDING_INFO2 = bCRYPT_PKCS1_PADDING_INFO;
710 return keyHandle.VerifyHash(hash, signature, global::Interop.NCrypt.AsymmetricPaddingMode.NCRYPT_PAD_PKCS1_FLAG, &bCRYPT_PKCS1_PADDING_INFO2);
711 }
713 {
714 global::Interop.BCrypt.BCRYPT_PSS_PADDING_INFO bCRYPT_PSS_PADDING_INFO = default(global::Interop.BCrypt.BCRYPT_PSS_PADDING_INFO);
715 bCRYPT_PSS_PADDING_INFO.pszAlgId = intPtr;
716 bCRYPT_PSS_PADDING_INFO.cbSalt = hash.Length;
717 global::Interop.BCrypt.BCRYPT_PSS_PADDING_INFO bCRYPT_PSS_PADDING_INFO2 = bCRYPT_PSS_PADDING_INFO;
718 return keyHandle.VerifyHash(hash, signature, global::Interop.NCrypt.AsymmetricPaddingMode.NCRYPT_PAD_PSS_FLAG, &bCRYPT_PSS_PADDING_INFO2);
719 }
720 default:
721 throw new CryptographicException(System.SR.Cryptography_UnsupportedPaddingMode);
722 }
723 }
724 finally
725 {
727 }
728 }
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)

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