summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2024-03-27 17:24:04 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2024-03-27 17:24:04 +0700
commitd1a2782503a4eb67da62527ff08132d0cc87ab77 (patch)
treed73e841f96f422e9f78aab238cd60795c605661e
parentRework SIgnedPublicKeyAndChallenge (diff)
downloadBouncyCastle.NET-ed25519-d1a2782503a4eb67da62527ff08132d0cc87ab77.tar.xz
Refactoring
-rw-r--r--crypto/src/bcpg/Packet.cs1
-rw-r--r--crypto/src/cms/SignerInformation.cs12
-rw-r--r--crypto/src/x509/X509Certificate.cs1
-rw-r--r--crypto/src/x509/X509Crl.cs1
-rw-r--r--crypto/src/x509/X509V2AttributeCertificate.cs2
5 files changed, 11 insertions, 6 deletions
diff --git a/crypto/src/bcpg/Packet.cs b/crypto/src/bcpg/Packet.cs
index 83f6d1f74..964102a71 100644
--- a/crypto/src/bcpg/Packet.cs
+++ b/crypto/src/bcpg/Packet.cs
@@ -1,5 +1,6 @@
 namespace Org.BouncyCastle.Bcpg
 {
+    // TODO Add packet tag at this level (see bc-java), and IsCritical property
     public class Packet
         //: PacketTag
     {
diff --git a/crypto/src/cms/SignerInformation.cs b/crypto/src/cms/SignerInformation.cs
index 9b8884cdb..df6624f99 100644
--- a/crypto/src/cms/SignerInformation.cs
+++ b/crypto/src/cms/SignerInformation.cs
@@ -318,7 +318,7 @@ namespace Org.BouncyCastle.Cms
 			return signedAttributeSet?.GetEncoded(Asn1Encodable.Der);
 		}
 
-		private bool DoVerify(AsymmetricKeyParameter key)
+		private bool DoVerify(AsymmetricKeyParameter publicKey)
 		{
 			DerObjectIdentifier sigAlgOid = this.encryptionAlgorithm.Algorithm;
 			Asn1Encodable sigParams = this.encryptionAlgorithm.Parameters;
@@ -482,7 +482,7 @@ namespace Org.BouncyCastle.Cms
 
 			try
 			{
-				sig.Init(false, key);
+				sig.Init(false, publicKey);
 
 				if (signedAttributeSet == null)
 				{
@@ -495,7 +495,7 @@ namespace Org.BouncyCastle.Cms
 						else
 						{
 							// need to decrypt signature and check message bytes
-							return VerifyDigest(resultDigest, key, this.GetSignature());
+							return VerifyDigest(resultDigest, publicKey, GetSignature());
 						}
 					}
 					else if (content != null)
@@ -559,7 +559,7 @@ namespace Org.BouncyCastle.Cms
 			return digInfo;
 		}
 
-		private bool VerifyDigest(byte[] digest, AsymmetricKeyParameter key, byte[] signature)
+		private bool VerifyDigest(byte[] digest, AsymmetricKeyParameter publicKey, byte[] signature)
 		{
 			string algorithm = CmsSignedHelper.GetEncryptionAlgName(encryptionAlgorithm.Algorithm);
 
@@ -569,7 +569,7 @@ namespace Org.BouncyCastle.Cms
 				{
 					IBufferedCipher c = CipherUtilities.GetCipher(Asn1.Pkcs.PkcsObjectIdentifiers.RsaEncryption);
 
-					c.Init(false, key);
+					c.Init(false, publicKey);
 
 					byte[] decrypt = c.DoFinal(signature);
 
@@ -593,7 +593,7 @@ namespace Org.BouncyCastle.Cms
 				{
 					ISigner sig = CmsSignedHelper.GetSignatureInstance("NONEwithDSA");
 
-					sig.Init(false, key);
+					sig.Init(false, publicKey);
 
 					sig.BlockUpdate(digest, 0, digest.Length);
 
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index 572acb2c7..ef50dd763 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -679,6 +679,7 @@ namespace Org.BouncyCastle.X509
         /// <param name="key">An appropriate public key parameter object, RsaPublicKeyParameters, DsaPublicKeyParameters or ECDsaPublicKeyParameters</param>
         /// <returns>True if the signature is valid.</returns>
         /// <exception cref="Exception">If key submitted is not of the above nominated types.</exception>
+        // TODO[api] Rename 'key' to 'publicKey'
         public virtual void Verify(AsymmetricKeyParameter key)
         {
             CheckSignature(new Asn1VerifierFactory(c.SignatureAlgorithm, key));
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs
index fec33f09c..0e9565da4 100644
--- a/crypto/src/x509/X509Crl.cs
+++ b/crypto/src/x509/X509Crl.cs
@@ -103,6 +103,7 @@ namespace Org.BouncyCastle.X509
 				:	null;
 		}
 
+        // TODO[api] Rename 'key' to 'publicKey'
         public virtual bool IsSignatureValid(AsymmetricKeyParameter key)
         {
             return CheckSignatureValid(new Asn1VerifierFactory(c.SignatureAlgorithm, key));
diff --git a/crypto/src/x509/X509V2AttributeCertificate.cs b/crypto/src/x509/X509V2AttributeCertificate.cs
index 84bf0db54..626d14572 100644
--- a/crypto/src/x509/X509V2AttributeCertificate.cs
+++ b/crypto/src/x509/X509V2AttributeCertificate.cs
@@ -161,6 +161,7 @@ namespace Org.BouncyCastle.X509
             return cert.GetSignatureOctets();
 		}
 
+        // TODO[api] Rename 'key' to 'publicKey'
         public virtual bool IsSignatureValid(AsymmetricKeyParameter key)
         {
             return CheckSignatureValid(new Asn1VerifierFactory(cert.SignatureAlgorithm, key));
@@ -171,6 +172,7 @@ namespace Org.BouncyCastle.X509
             return CheckSignatureValid(verifierProvider.CreateVerifierFactory(cert.SignatureAlgorithm));
         }
 
+        // TODO[api] Rename 'key' to 'publicKey'
         public virtual void Verify(AsymmetricKeyParameter key)
         {
             CheckSignature(new Asn1VerifierFactory(cert.SignatureAlgorithm, key));