public override void PerformTest()
        {
            RequestedCertificate.Choice type = RequestedCertificate.Choice.AttributeCertificate;
            X509CertificateStructure    cert = X509CertificateStructure.GetInstance(
                Asn1Object.FromByteArray(certBytes));

            byte[] certOctets = new byte[20];
            RequestedCertificate requested = new RequestedCertificate(type, certOctets);

            checkConstruction(requested, type, certOctets, null);

            requested = new RequestedCertificate(cert);

            checkConstruction(requested, RequestedCertificate.Choice.Certificate, null, cert);

            requested = RequestedCertificate.GetInstance(null);

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

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

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
        private void checkValues(
            RequestedCertificate requested,
            RequestedCertificate.Choice type,
            byte[]                                          certOctets,
            X509CertificateStructure cert)
        {
            checkMandatoryField("certType", (int)type, (int)requested.Type);

            if (requested.Type == RequestedCertificate.Choice.Certificate)
            {
                checkMandatoryField("certificate", cert.GetEncoded(), requested.GetCertificateBytes());
            }
            else
            {
                checkMandatoryField("certificateOctets", certOctets, requested.GetCertificateBytes());
            }
        }
        private void checkConstruction(
            RequestedCertificate requested,
            RequestedCertificate.Choice type,
            byte[]                                          certOctets,
            X509CertificateStructure cert)
        {
            checkValues(requested, type, certOctets, cert);

            requested = RequestedCertificate.GetInstance(requested);

            checkValues(requested, type, certOctets, cert);

            Asn1InputStream aIn = new Asn1InputStream(requested.ToAsn1Object().GetEncoded());

            object obj = aIn.ReadObject();

            requested = RequestedCertificate.GetInstance(obj);

            checkValues(requested, type, certOctets, cert);
        }
Beispiel #4
0
 public RequestedCertificate(RequestedCertificate.Choice type, byte[] certificateOctets) : this(new DerTaggedObject((int)type, new DerOctetString(certificateOctets)))
 {
 }