summary refs log tree commit diff
path: root/crypto/src/ocsp
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-29 20:55:57 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-29 20:55:57 +0700
commite049cab36e9e68adff298acc24acdaa2551f72ef (patch)
treee772d623791461cba50b1eba3bbd4f833f893ae9 /crypto/src/ocsp
parentAdd Objects class (diff)
downloadBouncyCastle.NET-ed25519-e049cab36e9e68adff298acc24acdaa2551f72ef.tar.xz
Refactoring around Stream signers
Diffstat (limited to 'crypto/src/ocsp')
-rw-r--r--crypto/src/ocsp/BasicOCSPRespGenerator.cs21
-rw-r--r--crypto/src/ocsp/OCSPReqGenerator.cs4
2 files changed, 10 insertions, 15 deletions
diff --git a/crypto/src/ocsp/BasicOCSPRespGenerator.cs b/crypto/src/ocsp/BasicOCSPRespGenerator.cs
index 147bd7839..d4ec3df80 100644
--- a/crypto/src/ocsp/BasicOCSPRespGenerator.cs
+++ b/crypto/src/ocsp/BasicOCSPRespGenerator.cs
@@ -206,20 +206,19 @@ namespace Org.BouncyCastle.Ocsp
 				}
 			}
 
-			ResponseData tbsResp = new ResponseData(responderID.ToAsn1Object(), new DerGeneralizedTime(producedAt), new DerSequence(responses), responseExtensions);
-			DerBitString bitSig = null;
+			ResponseData tbsResp = new ResponseData(responderID.ToAsn1Object(), new DerGeneralizedTime(producedAt),
+				new DerSequence(responses), responseExtensions);
+			DerBitString bitSig;
 
 			try
 			{
                 IStreamCalculator streamCalculator = signatureCalculator.CreateCalculator();
+				using (Stream sigStream = streamCalculator.Stream)
+				{
+					tbsResp.EncodeTo(sigStream, Asn1Encodable.Der);
+				}
 
-				byte[] encoded = tbsResp.GetDerEncoded();
-
-                streamCalculator.Stream.Write(encoded, 0, encoded.Length);
-
-                Platform.Dispose(streamCalculator.Stream);
-
-                bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Collect());
+				bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Collect());
 			}
 			catch (Exception e)
 			{
@@ -236,9 +235,7 @@ namespace Org.BouncyCastle.Ocsp
 				{
 					for (int i = 0; i != chain.Length; i++)
 					{
-						v.Add(
-							X509CertificateStructure.GetInstance(
-								Asn1Object.FromByteArray(chain[i].GetEncoded())));
+						v.Add(chain[i].CertificateStructure);
 					}
 				}
 				catch (IOException e)
diff --git a/crypto/src/ocsp/OCSPReqGenerator.cs b/crypto/src/ocsp/OCSPReqGenerator.cs
index 52890ae30..dda1625e5 100644
--- a/crypto/src/ocsp/OCSPReqGenerator.cs
+++ b/crypto/src/ocsp/OCSPReqGenerator.cs
@@ -165,9 +165,7 @@ namespace Org.BouncyCastle.Ocsp
 					{
 						for (int i = 0; i != chain.Length; i++)
 						{
-							v.Add(
-								X509CertificateStructure.GetInstance(
-									Asn1Object.FromByteArray(chain[i].GetEncoded())));
+							v.Add(chain[i].CertificateStructure);
 						}
 					}
 					catch (IOException e)