diff options
author | Megan Woods <megan@flygfisk.com> | 2019-01-14 17:07:22 +1100 |
---|---|---|
committer | Megan Woods <megan@flygfisk.com> | 2019-01-14 17:07:22 +1100 |
commit | ecc8edb622f0f42d43f72ae388fa4c4274e51c5f (patch) | |
tree | 9091e5bf1fe54dde31ee786956139b0fb54b0ba3 /crypto/src/asn1/cmp/CertificateStatus.cs | |
parent | minor tweaks (diff) | |
download | BouncyCastle.NET-ed25519-ecc8edb622f0f42d43f72ae388fa4c4274e51c5f.tar.xz |
Initial CMP
Diffstat (limited to 'crypto/src/asn1/cmp/CertificateStatus.cs')
-rw-r--r-- | crypto/src/asn1/cmp/CertificateStatus.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/crypto/src/asn1/cmp/CertificateStatus.cs b/crypto/src/asn1/cmp/CertificateStatus.cs new file mode 100644 index 000000000..d16c8e006 --- /dev/null +++ b/crypto/src/asn1/cmp/CertificateStatus.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Org.BouncyCastle.Asn1.X509; +using Org.BouncyCastle.Cms; +using Org.BouncyCastle.Crypto.IO; +using Org.BouncyCastle.Math; +using Org.BouncyCastle.Security; +using Org.BouncyCastle.Utilities; +using Org.BouncyCastle.X509; + +namespace Org.BouncyCastle.Asn1.Cmp +{ + public class CertificateStatus + { + private DefaultSignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder(); + private DefaultDigestAlgorithmIdentifierFinder digestAlgFinder; + private CertStatus certStatus; + + public CertificateStatus(DefaultDigestAlgorithmIdentifierFinder digestAlgFinder, CertStatus certStatus) + { + this.digestAlgFinder = digestAlgFinder; + this.certStatus = certStatus; + } + + public PkiStatusInfo PkiStatusInfo + { + get { return certStatus.StatusInfo; } + } + + public BigInteger CertRequestId + { + get { return certStatus.CertReqID.Value; } + } + + public bool IsVerified(X509Certificate cert) + { + + AlgorithmIdentifier digAlg = digestAlgFinder.find( sigAlgFinder.Find(cert.SigAlgName)); + if (digAlg == null) + { + throw new CmpException("cannot find algorithm for digest from signature "+cert.SigAlgName); + } + + DigestSink digestSink = new DigestSink(DigestUtilities.GetDigest(digAlg.Algorithm)); + + digestSink.Write(cert.GetEncoded()); + + byte[] digest = new byte[digestSink.Digest.GetDigestSize()]; + digestSink.Digest.DoFinal(digest, 0); + return Arrays.ConstantTimeAreEqual(certStatus.CertHash.GetOctets(), digest); + } + } +} |