public CertificateConfirmationContent Build()
        {
            Asn1EncodableVector v = new Asn1EncodableVector();

            for (int i = 0; i != acceptedCerts.Count; i++)
            {
                X509Certificate cert  = (X509Certificate)acceptedCerts[i];
                BigInteger      reqId = (BigInteger)acceptedReqIds[i];



                AlgorithmIdentifier algorithmIdentifier = sigAlgFinder.Find(cert.SigAlgName);

                AlgorithmIdentifier digAlg = digestAlgFinder.find(algorithmIdentifier);
                if (digAlg == null)
                {
                    throw new CmpException("cannot find algorithm for digest from signature");
                }

                DigestSink sink = new DigestSink(DigestUtilities.GetDigest(digAlg.Algorithm));

                sink.Write(cert.GetEncoded());

                byte[] dig = new byte[sink.Digest.GetDigestSize()];
                sink.Digest.DoFinal(dig, 0);

                v.Add(new CertStatus(dig, reqId));
            }

            return(new CertificateConfirmationContent(CertConfirmContent.GetInstance(new DerSequence(v)),
                                                      digestAlgFinder));
        }
Пример #2
0
        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));
        }
Пример #3
0
 public DfDigestStream(IDigest digest)
 {
     stream = new DigestSink(digest);
 }
 public DfDigestStream(IDigest digest)
 {
     this.mStream = new DigestSink(digest);
 }