summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Hook <dgh@bouncycastle.org>2021-05-31 08:05:22 +1000
committerDavid Hook <dgh@bouncycastle.org>2021-05-31 08:05:22 +1000
commitdb06bfa3adaf3c54692e4ed6c175470d8594f318 (patch)
tree6a8c1d421f48844bae972470bc995ed6e39469fa
parentgithub #262 added settable digest to OpenSSL PBE generator (diff)
downloadBouncyCastle.NET-ed25519-db06bfa3adaf3c54692e4ed6c175470d8594f318.tar.xz
github #83 - correct digest name fetch to check enc oid
-rw-r--r--crypto/src/cms/SignerInformation.cs19
1 files changed, 12 insertions, 7 deletions
diff --git a/crypto/src/cms/SignerInformation.cs b/crypto/src/cms/SignerInformation.cs
index f6cfd8602..2bb808ae2 100644
--- a/crypto/src/cms/SignerInformation.cs
+++ b/crypto/src/cms/SignerInformation.cs
@@ -319,11 +319,16 @@ namespace Org.BouncyCastle.Cms
 		private bool DoVerify(
 			AsymmetricKeyParameter	key)
 		{
-			string digestName = Helper.GetDigestAlgName(this.DigestAlgOid);
-			IDigest digest = Helper.GetDigestInstance(digestName);
-
-            DerObjectIdentifier sigAlgOid = this.encryptionAlgorithm.Algorithm;
+			DerObjectIdentifier sigAlgOid = this.encryptionAlgorithm.Algorithm;
 			Asn1Encodable sigParams = this.encryptionAlgorithm.Parameters;
+			string digestName = Helper.GetDigestAlgName(this.EncryptionAlgOid);
+
+			if (digestName.Equals(sigAlgOid.Id))
+			{
+				digestName = Helper.GetDigestAlgName(this.DigestAlgOid);
+			}
+			
+			IDigest digest = Helper.GetDigestInstance(digestName);
 			ISigner sig;
 
 			if (sigAlgOid.Equals(Asn1.Pkcs.PkcsObjectIdentifiers.IdRsassaPss))
@@ -374,10 +379,10 @@ namespace Org.BouncyCastle.Cms
 			else
 			{
 				// TODO Probably too strong a check at the moment
-//				if (sigParams != null)
-//					throw new CmsException("unrecognised signature parameters provided");
+				//				if (sigParams != null)
+				//					throw new CmsException("unrecognised signature parameters provided");
 
-                string signatureName = digestName + "with" + Helper.GetEncryptionAlgName(this.EncryptionAlgOid);
+				string signatureName = digestName + "with" + Helper.GetEncryptionAlgName(this.EncryptionAlgOid);
 
                 sig = Helper.GetSignatureInstance(signatureName);