diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-05 13:30:09 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-05 13:30:09 +0700 |
commit | a216f62bd14a9962eccb5ce7daf7820ccadadc23 (patch) | |
tree | 15aa2bd6aec9a20caf54eb0f1a5c691f9725f33e /crypto/src/x509/X509Certificate.cs | |
parent | Refactor SendSignatureInput and callers (diff) | |
download | BouncyCastle.NET-ed25519-a216f62bd14a9962eccb5ce7daf7820ccadadc23.tar.xz |
Avoid intermediate allocations
Diffstat (limited to 'crypto/src/x509/X509Certificate.cs')
-rw-r--r-- | crypto/src/x509/X509Certificate.cs | 6 |
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"); } |