summary refs log tree commit diff
path: root/crypto/src/x509/X509Certificate.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-01-05 13:30:09 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-01-05 13:30:09 +0700
commita216f62bd14a9962eccb5ce7daf7820ccadadc23 (patch)
tree15aa2bd6aec9a20caf54eb0f1a5c691f9725f33e /crypto/src/x509/X509Certificate.cs
parentRefactor SendSignatureInput and callers (diff)
downloadBouncyCastle.NET-ed25519-a216f62bd14a9962eccb5ce7daf7820ccadadc23.tar.xz
Avoid intermediate allocations
Diffstat (limited to 'crypto/src/x509/X509Certificate.cs')
-rw-r--r--crypto/src/x509/X509Certificate.cs6
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index 5b800efe5..b6749d505 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -680,15 +680,13 @@ namespace Org.BouncyCastle.X509
             if (!IsAlgIDEqual(c.SignatureAlgorithm, c.TbsCertificate.Signature))
                 throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
 
-            byte[] b = GetTbsCertificate();
-
             IStreamCalculator<IVerifier> streamCalculator = verifier.CreateCalculator();
             using (var stream = streamCalculator.Stream)
             {
-                stream.Write(b, 0, b.Length);
+                c.TbsCertificate.EncodeTo(stream, Asn1Encodable.Der);
             }
 
-            if (!streamCalculator.GetResult().IsVerified(this.GetSignature()))
+            if (!streamCalculator.GetResult().IsVerified(GetSignature()))
                 throw new InvalidKeyException("Public key presented not for certificate signature");
         }