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));
        }
        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 (null == digAlg)
                {
                    throw new CmpException("cannot find algorithm for digest from signature");
                }

                byte[] digest = DigestUtilities.CalculateDigest(digAlg.Algorithm, cert.GetEncoded());

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

            return(new CertificateConfirmationContent(CertConfirmContent.GetInstance(new DerSequence(v)),
                                                      digestAlgFinder));
        }
        public bool IsVerified(X509Certificate cert)
        {
            AlgorithmIdentifier digAlg = digestAlgFinder.find(sigAlgFinder.Find(cert.SigAlgName));

            if (null == digAlg)
            {
                throw new CmpException("cannot find algorithm for digest from signature " + cert.SigAlgName);
            }

            byte[] digest = DigestUtilities.CalculateDigest(digAlg.Algorithm, cert.GetEncoded());

            return(Arrays.ConstantTimeAreEqual(certStatus.CertHash.GetOctets(), digest));
        }
Beispiel #4
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));
        }