From e049cab36e9e68adff298acc24acdaa2551f72ef Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 29 Jun 2022 20:55:57 +0700 Subject: Refactoring around Stream signers --- crypto/src/pkcs/Pkcs10CertificationRequest.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crypto/src/pkcs/Pkcs10CertificationRequest.cs') diff --git a/crypto/src/pkcs/Pkcs10CertificationRequest.cs b/crypto/src/pkcs/Pkcs10CertificationRequest.cs index d462fb4db..be4cbb570 100644 --- a/crypto/src/pkcs/Pkcs10CertificationRequest.cs +++ b/crypto/src/pkcs/Pkcs10CertificationRequest.cs @@ -282,12 +282,10 @@ namespace Org.BouncyCastle.Pkcs this.reqInfo = new CertificationRequestInfo(subject, pubInfo, attributes); IStreamCalculator streamCalculator = signatureFactory.CreateCalculator(); - - byte[] reqInfoData = reqInfo.GetDerEncoded(); - - streamCalculator.Stream.Write(reqInfoData, 0, reqInfoData.Length); - - Platform.Dispose(streamCalculator.Stream); + using (Stream sigStream = streamCalculator.Stream) + { + reqInfo.EncodeTo(sigStream, Der); + } // Generate Signature. sigBits = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Collect()); -- cgit 1.4.1