public virtual bool Check(CertificateAndContext cert)
        {
            if (cert is null)
            {
                throw new System.ArgumentNullException(nameof(cert));
            }

            Asn1OctetString qcStatement = cert.Certificate.GetExtensionValue(X509Extensions.QCStatements);

            if (qcStatement != null)
            {
                DerOctetString s       = (DerOctetString)qcStatement;
                byte[]         content = s.GetOctets();
                using (Asn1InputStream input = new Asn1InputStream(content))
                {
                    DerSequence seq = (DerSequence)input.ReadObject();
                    for (int i = 0; i < seq.Count; i++)
                    {
                        QCStatement statement = QCStatement.GetInstance(seq[i]);
                        if (statement.StatementId.Id.Equals(qcStatementId, System.StringComparison.OrdinalIgnoreCase))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
            }
            return(false);
        }
Example #2
0
        public override void PerformTest()
        {
            QCStatement mv = new QCStatement(Rfc3739QCObjectIdentifiers.IdQcsPkixQCSyntaxV1);

            CheckConstruction(mv, Rfc3739QCObjectIdentifiers.IdQcsPkixQCSyntaxV1, null);

            Asn1Encodable info = new SemanticsInformation(new DerObjectIdentifier("1.2"));

            mv = new QCStatement(Rfc3739QCObjectIdentifiers.IdQcsPkixQCSyntaxV1, info);

            CheckConstruction(mv, Rfc3739QCObjectIdentifiers.IdQcsPkixQCSyntaxV1, info);

            mv = QCStatement.GetInstance(null);

            if (mv != null)
            {
                Fail("null GetInstance() failed.");
            }

            try
            {
                QCStatement.GetInstance(new object());

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
Example #3
0
        public virtual bool Check(CertificateAndContext cert)
        {
            //TODO jbonilla - Validar
            //byte[] qcStatement = cert.GetCertificate().GetExtensionValue(X509Extensions.QCStatements);
            Asn1OctetString qcStatement = cert.GetCertificate().GetExtensionValue(X509Extensions.QCStatements);

            if (qcStatement != null)
            {
                try
                {
                    //Asn1InputStream input = new Asn1InputStream(qcStatement);
                    //DerOctetString s = (DerOctetString)input.ReadObject();
                    DerOctetString  s       = (DerOctetString)qcStatement;
                    byte[]          content = s.GetOctets();
                    Asn1InputStream input   = new Asn1InputStream(content);
                    DerSequence     seq     = (DerSequence)input.ReadObject();
                    for (int i = 0; i < seq.Count; i++)
                    {
                        QCStatement statement = QCStatement.GetInstance(seq[i]);
                        if (statement.StatementId.Id.Equals(qcStatementId))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
            }
            return(false);
        }
Example #4
0
        private void CheckConstruction(
            QCStatement mv,
            DerObjectIdentifier statementId,
            Asn1Encodable statementInfo)
        {
            CheckStatement(mv, statementId, statementInfo);

            mv = QCStatement.GetInstance(mv);

            CheckStatement(mv, statementId, statementInfo);

            Asn1Sequence seq = (Asn1Sequence)Asn1Object.FromByteArray(
                mv.ToAsn1Object().GetEncoded());

            mv = QCStatement.GetInstance(seq);

            CheckStatement(mv, statementId, statementInfo);
        }