summary refs log tree commit diff
path: root/crypto/src/crmf
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/crmf
parentUpdate Asn1.Cmp from bc-java (diff)
downloadBouncyCastle.NET-ed25519-d438290428230551ff568329478b0e45e5085b44.tar.xz
Give IStreamCalculator a generic type
Diffstat (limited to 'crypto/src/crmf')
-rw-r--r--crypto/src/crmf/CertificateRequestMessage.cs4
-rw-r--r--crypto/src/crmf/PKMacBuilder.cs6
-rw-r--r--crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs8
3 files changed, 9 insertions, 9 deletions
diff --git a/crypto/src/crmf/CertificateRequestMessage.cs b/crypto/src/crmf/CertificateRequestMessage.cs
index c733eecbb..0a246aaa4 100644
--- a/crypto/src/crmf/CertificateRequestMessage.cs
+++ b/crypto/src/crmf/CertificateRequestMessage.cs
@@ -190,7 +190,7 @@ namespace Org.BouncyCastle.Crmf
         private bool verifySignature(IVerifierFactoryProvider verifierFactoryProvider, PopoSigningKey signKey)
         {
             IVerifierFactory verifer;
-            IStreamCalculator calculator;
+            IStreamCalculator<IVerifier> calculator;
             try
             {
                 verifer = verifierFactoryProvider.CreateVerifierFactory(signKey.AlgorithmIdentifier);
@@ -212,7 +212,7 @@ namespace Org.BouncyCastle.Crmf
                 calculator.Stream.Write(b, 0, b.Length);
             }
 
-            DefaultVerifierResult result = (DefaultVerifierResult)calculator.GetResult();
+            IVerifier result = calculator.GetResult();
 
             return result.IsVerified(signKey.Signature.GetBytes());
         }
diff --git a/crypto/src/crmf/PKMacBuilder.cs b/crypto/src/crmf/PKMacBuilder.cs
index 9b483fbfb..bce26b825 100644
--- a/crypto/src/crmf/PKMacBuilder.cs
+++ b/crypto/src/crmf/PKMacBuilder.cs
@@ -15,7 +15,7 @@ using Org.BouncyCastle.Utilities;
 namespace Org.BouncyCastle.Crmf
 {
     internal class PKMacStreamCalculator
-        : IStreamCalculator
+        : IStreamCalculator<DefaultPKMacResult>
     {
         private readonly MacSink _stream;
 
@@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Crmf
             get { return _stream; }
         }
 
-        public object GetResult()
+        public DefaultPKMacResult GetResult()
         {
             return new DefaultPKMacResult(_stream.Mac);
         }
@@ -52,7 +52,7 @@ namespace Org.BouncyCastle.Crmf
             get { return new AlgorithmIdentifier(CmpObjectIdentifiers.passwordBasedMac, parameters); }
         }
 
-        public virtual IStreamCalculator CreateCalculator()
+        public virtual IStreamCalculator<IBlockResult> CreateCalculator()
         {
             IMac mac = MacUtilities.GetMac(parameters.Mac.Algorithm);
             mac.Init(new KeyParameter(key));
diff --git a/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs b/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
index 50c2ea65c..eed66b083 100644
--- a/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
+++ b/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
@@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Crmf
         {
             IMacFactory fact = generator.Build(password);
 
-            IStreamCalculator calc = fact.CreateCalculator();
+            IStreamCalculator<IBlockResult> calc = fact.CreateCalculator();
             byte[] d = _pubKeyInfo.GetDerEncoded();
             calc.Stream.Write(d, 0, d.Length);
             calc.Stream.Flush();
@@ -46,7 +46,7 @@ namespace Org.BouncyCastle.Crmf
 
             this._publicKeyMAC = new PKMacValue(
                 (AlgorithmIdentifier)fact.AlgorithmDetails,
-                new DerBitString(((IBlockResult)calc.GetResult()).Collect()));
+                new DerBitString(calc.GetResult().Collect()));
 
             return this;
         }
@@ -60,7 +60,7 @@ namespace Org.BouncyCastle.Crmf
 
             PopoSigningKeyInput popo;
 
-            IStreamCalculator calc = signer.CreateCalculator();
+            IStreamCalculator<IBlockResult> calc = signer.CreateCalculator();
             using (Stream sigStream = calc.Stream)
             {
                 if (_certRequest != null)
@@ -80,7 +80,7 @@ namespace Org.BouncyCastle.Crmf
                 }
             }
 
-            var signature = ((IBlockResult)calc.GetResult()).Collect();
+            var signature = calc.GetResult().Collect();
 
             return new PopoSigningKey(popo, (AlgorithmIdentifier)signer.AlgorithmDetails, new DerBitString(signature));
         }