summary refs log tree commit diff
path: root/crypto/src/x509
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-09-20 15:19:15 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-09-20 15:19:15 +0700
commitd438290428230551ff568329478b0e45e5085b44 (patch)
tree423683961e53d42c709660dc4838d1bfb02f4a07 /crypto/src/x509
parentUpdate Asn1.Cmp from bc-java (diff)
downloadBouncyCastle.NET-ed25519-d438290428230551ff568329478b0e45e5085b44.tar.xz
Give IStreamCalculator a generic type
Diffstat (limited to 'crypto/src/x509')
-rw-r--r--crypto/src/x509/X509Certificate.cs6
-rw-r--r--crypto/src/x509/X509Crl.cs9
-rw-r--r--crypto/src/x509/X509V1CertificateGenerator.cs4
-rw-r--r--crypto/src/x509/X509V2AttributeCertificate.cs9
-rw-r--r--crypto/src/x509/X509V2AttributeCertificateGenerator.cs4
-rw-r--r--crypto/src/x509/X509V2CRLGenerator.cs4
-rw-r--r--crypto/src/x509/X509V3CertificateGenerator.cs4
7 files changed, 16 insertions, 24 deletions
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index 75efdfbb1..627903e1f 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -682,7 +682,7 @@ namespace Org.BouncyCastle.X509
 
             Asn1Encodable parameters = c.SignatureAlgorithm.Parameters;
 
-            IStreamCalculator streamCalculator = verifier.CreateCalculator();
+            IStreamCalculator<IVerifier> streamCalculator = verifier.CreateCalculator();
 
             byte[] b = this.GetTbsCertificate();
 
@@ -690,10 +690,8 @@ namespace Org.BouncyCastle.X509
 
             Platform.Dispose(streamCalculator.Stream);
 
-            if (!((IVerifier)streamCalculator.GetResult()).IsVerified(this.GetSignature()))
-            {
+            if (!streamCalculator.GetResult().IsVerified(this.GetSignature()))
                 throw new InvalidKeyException("Public key presented not for certificate signature");
-            }
         }
 
         private CachedEncoding GetCachedEncoding()
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs
index 60660aab0..265c2293c 100644
--- a/crypto/src/x509/X509Crl.cs
+++ b/crypto/src/x509/X509Crl.cs
@@ -126,14 +126,13 @@ namespace Org.BouncyCastle.X509
         protected virtual void CheckSignature(
             IVerifierFactory verifier)
         {
+            // TODO Compare IsAlgIDEqual in X509Certificate.CheckSignature
             if (!c.SignatureAlgorithm.Equals(c.TbsCertList.Signature))
-            {
                 throw new CrlException("Signature algorithm on CertificateList does not match TbsCertList.");
-            }
 
             Asn1Encodable parameters = c.SignatureAlgorithm.Parameters;
 
-            IStreamCalculator streamCalculator = verifier.CreateCalculator();
+            IStreamCalculator<IVerifier> streamCalculator = verifier.CreateCalculator();
 
             byte[] b = this.GetTbsCertList();
 
@@ -141,10 +140,8 @@ namespace Org.BouncyCastle.X509
 
             Platform.Dispose(streamCalculator.Stream);
 
-            if (!((IVerifier)streamCalculator.GetResult()).IsVerified(this.GetSignature()))
-            {
+            if (!streamCalculator.GetResult().IsVerified(this.GetSignature()))
                 throw new InvalidKeyException("CRL does not verify with supplied public key.");
-            }
         }
 
         public virtual int Version
diff --git a/crypto/src/x509/X509V1CertificateGenerator.cs b/crypto/src/x509/X509V1CertificateGenerator.cs
index 01c155b5d..d95f522e8 100644
--- a/crypto/src/x509/X509V1CertificateGenerator.cs
+++ b/crypto/src/x509/X509V1CertificateGenerator.cs
@@ -124,13 +124,13 @@ namespace Org.BouncyCastle.X509
 
 			TbsCertificateStructure tbsCert = tbsGen.GenerateTbsCertificate();
 
-			IStreamCalculator streamCalculator = signatureFactory.CreateCalculator();
+			IStreamCalculator<IBlockResult> streamCalculator = signatureFactory.CreateCalculator();
 			using (Stream sigStream = streamCalculator.Stream)
 			{
 				tbsCert.EncodeTo(sigStream, Asn1Encodable.Der);
 			}
 
-			var signature = ((IBlockResult)streamCalculator.GetResult()).Collect();
+			var signature = streamCalculator.GetResult().Collect();
 
 			return new X509Certificate(
 				new X509CertificateStructure(tbsCert, sigAlgID, new DerBitString(signature)));
diff --git a/crypto/src/x509/X509V2AttributeCertificate.cs b/crypto/src/x509/X509V2AttributeCertificate.cs
index 8c6ff0062..fbb4fe20f 100644
--- a/crypto/src/x509/X509V2AttributeCertificate.cs
+++ b/crypto/src/x509/X509V2AttributeCertificate.cs
@@ -182,12 +182,11 @@ namespace Org.BouncyCastle.X509
         protected virtual void CheckSignature(
             IVerifierFactory verifier)
         {
+            // TODO Compare IsAlgIDEqual in X509Certificate.CheckSignature
             if (!cert.SignatureAlgorithm.Equals(cert.ACInfo.Signature))
-			{
 				throw new CertificateException("Signature algorithm in certificate info not same as outer certificate");
-			}
 
-            IStreamCalculator streamCalculator = verifier.CreateCalculator();
+            IStreamCalculator<IVerifier> streamCalculator = verifier.CreateCalculator();
 
 			try
 			{
@@ -202,10 +201,8 @@ namespace Org.BouncyCastle.X509
 				throw new SignatureException("Exception encoding certificate info object", e);
 			}
 
-			if (!((IVerifier)streamCalculator.GetResult()).IsVerified(this.GetSignature()))
-			{
+			if (!streamCalculator.GetResult().IsVerified(this.GetSignature()))
 				throw new InvalidKeyException("Public key presented not for certificate signature");
-			}
 		}
 
 		public virtual byte[] GetEncoded()
diff --git a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
index 3e1a58e49..1cb239e87 100644
--- a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
+++ b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
@@ -119,13 +119,13 @@ namespace Org.BouncyCastle.X509
 
             AttributeCertificateInfo acInfo = acInfoGen.GenerateAttributeCertificateInfo();
 
-			IStreamCalculator streamCalculator = signatureFactory.CreateCalculator();
+			IStreamCalculator<IBlockResult> streamCalculator = signatureFactory.CreateCalculator();
 			using (Stream sigStream = streamCalculator.Stream)
 			{
 				acInfo.EncodeTo(sigStream, Asn1Encodable.Der);
 			}
 
-			var signature = ((IBlockResult)streamCalculator.GetResult()).Collect();
+			var signature = streamCalculator.GetResult().Collect();
 
 			return new X509V2AttributeCertificate(
 				new AttributeCertificate(acInfo, sigAlgID, new DerBitString(signature)));
diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs
index e386ee8f2..dc3f8c662 100644
--- a/crypto/src/x509/X509V2CRLGenerator.cs
+++ b/crypto/src/x509/X509V2CRLGenerator.cs
@@ -186,13 +186,13 @@ namespace Org.BouncyCastle.X509
 
 			TbsCertificateList tbsCertList = tbsGen.GenerateTbsCertList();
 
-            IStreamCalculator streamCalculator = signatureFactory.CreateCalculator();
+            IStreamCalculator<IBlockResult> streamCalculator = signatureFactory.CreateCalculator();
 			using (Stream sigStream = streamCalculator.Stream)
 			{
 				tbsCertList.EncodeTo(sigStream, Asn1Encodable.Der);
 			}
 
-			var signature = ((IBlockResult)streamCalculator.GetResult()).Collect();
+			var signature = streamCalculator.GetResult().Collect();
 
 			return new X509Crl(
 				CertificateList.GetInstance(new DerSequence(tbsCertList, sigAlgID, new DerBitString(signature))));
diff --git a/crypto/src/x509/X509V3CertificateGenerator.cs b/crypto/src/x509/X509V3CertificateGenerator.cs
index 50e3fc689..1854ac3b4 100644
--- a/crypto/src/x509/X509V3CertificateGenerator.cs
+++ b/crypto/src/x509/X509V3CertificateGenerator.cs
@@ -259,13 +259,13 @@ namespace Org.BouncyCastle.X509
 
             TbsCertificateStructure tbsCert = tbsGen.GenerateTbsCertificate();
 
-			IStreamCalculator streamCalculator = signatureFactory.CreateCalculator();
+			IStreamCalculator<IBlockResult> streamCalculator = signatureFactory.CreateCalculator();
 			using (Stream sigStream = streamCalculator.Stream)
             {
 				tbsCert.EncodeTo(sigStream, Asn1Encodable.Der);
 			}
 
-			var signature = ((IBlockResult)streamCalculator.GetResult()).Collect();
+			var signature = streamCalculator.GetResult().Collect();
 
 			return new X509Certificate(new X509CertificateStructure(tbsCert, sigAlgID, new DerBitString(signature)));
 		}