示例#1
0
 /**
  * create an AuthorityInformationAccess with the oid and location provided.
  */
 public AuthorityInformationAccess(
     DERObjectIdentifier oid,
     GeneralName location)
 {
     accessMethod   = oid;
     accessLocation = location;
 }
示例#2
0
 public static CipherParameters generateCipherParameters(
     DERObjectIdentifier algorithmOID,
     char[]              password,
     ASN1Encodable pbeParameters)
 {
     return(generateCipherParameters(algorithmOID.getId(), password, pbeParameters));
 }
示例#3
0
 public AlgorithmIdentifier(
     DERObjectIdentifier objectId,
     ASN1Encodable parameters)
 {
     this.objectId   = objectId;
     this.parameters = parameters;
 }
示例#4
0
        /**
         * Apply default coversion for the given value depending on the oid
         * and the character range of the value.
         *
         * @param oid the object identifier for the DN entry
         * @param value the value associated with it
         * @return the ASN.1 equivalent for the string value.
         */
        public override ASN1Object getConvertedValue(
            DERObjectIdentifier oid,
            string value)
        {
            if (value.Length != 0 && value[0] == '#')
            {
                try
                {
                    return(convertHexEncoded(value, 1));
                }
                catch (IOException)
                {
                    throw new Exception("can't recode value for oid " + oid.getId());
                }
            }
            else if (oid.Equals(X509Name.EmailAddress))
            {
                return(new DERIA5String(value));
            }
            else if (canBePrintable(value))
            {
                return(new DERPrintableString(value));
            }
            else if (canBeUTF8(value))
            {
                return(new DERUTF8String(value));
            }

            return(new DERBMPString(value));
        }
示例#5
0
        /**
         * returns a vector with 0 or more objects of all the capabilities
         * matching the passed in capability OID. If the OID passed is null the
         * entire set is returned.
         */
        public ArrayList getCapabilities(
            DERObjectIdentifier capability)
        {
            IEnumerator e    = capabilities.getObjects();
            ArrayList   list = new ArrayList();

            if (capability == null)
            {
                while (e.MoveNext())
                {
                    SMIMECapability cap = SMIMECapability.getInstance(e.Current);

                    list.Add(cap);
                }
            }
            else
            {
                while (e.MoveNext())
                {
                    SMIMECapability cap = SMIMECapability.getInstance(e.Current);

                    if (capability.Equals(cap.getCapabilityID()))
                    {
                        list.Add(cap);
                    }
                }
            }

            return(list);
        }
示例#6
0
        /// <summary>
        /// Get any critical extensions.
        /// </summary>
        /// <returns>A sorted list of critical entension.</returns>
        public SortedList getCriticalExtensionOIDs()
        {
            if (xStruct.getVersion() == 3)
            {
                SortedList     set        = new SortedList();
                X509Extensions extensions = xStruct.getTBSCertificate().getExtensions();

                if (extensions != null)
                {
                    IEnumerator e = extensions.oids();

                    while (e.MoveNext())
                    {
                        DERObjectIdentifier oid = (DERObjectIdentifier)e.Current;;
                        X509Extension       ext = extensions.getExtension(oid);

                        if (ext.isCritical())
                        {
                            set.Add(oid.getId(), ext);
                        }
                    }

                    return(set);
                }
            }

            return(null);
        }
示例#7
0
 public OtherRecipientInfo(
     DERObjectIdentifier oriType,
     ASN1Encodable oriValue)
 {
     this.oriType  = oriType;
     this.oriValue = oriValue;
 }
示例#8
0
 public SMIMECapability(
     DERObjectIdentifier capabilityID,
     ASN1Encodable parameters)
 {
     this.capabilityID = capabilityID;
     this.parameters   = parameters;
 }
示例#9
0
 public Attribute(
     DERObjectIdentifier attrType,
     ASN1Set attrValues)
 {
     this.attrType   = attrType;
     this.attrValues = attrValues;
 }
示例#10
0
 public OtherKeyAttribute(
     DERObjectIdentifier keyAttrId,
     ASN1Encodable keyAttr)
 {
     this.keyAttrId = keyAttrId;
     this.keyAttr   = keyAttr;
 }
示例#11
0
        public override ASN1Object toASN1Object()
        {
            ASN1EncodableVector vec = new ASN1EncodableVector();
            IEnumerator         e   = ordering.GetEnumerator();

            while (e.MoveNext())
            {
                DERObjectIdentifier oid = (DERObjectIdentifier)e.Current;
                X509Extension       ext = (X509Extension)extensions[oid];
                ASN1EncodableVector v   = new ASN1EncodableVector();

                v.add(oid);

                if (ext.isCritical())
                {
                    v.add(new DERBoolean(true));
                }

                v.add(ext.getValue());

                vec.add(new DERSequence(v));
            }

            return(new DERSequence(vec));
        }
示例#12
0
 public KeySpecificInfo(
     DERObjectIdentifier algorithm,
     ASN1OctetString counter)
 {
     this.algorithm = algorithm;
     this.counter   = counter;
 }
示例#13
0
 public CertBag(
     ASN1Sequence seq)
 {
     this.seq       = seq;
     this.certId    = (DERObjectIdentifier)seq.getObjectAt(0);
     this.certValue = ((DERTaggedObject)seq.getObjectAt(1)).getObject();
 }
示例#14
0
        /**
         * Constructor from a table of extensions with ordering.
         * <p>
         * It's is assumed the table contains OID/String pairs.
         */
        public X509Extensions(
            ArrayList ordering,
            Hashtable extensions)
        {
            IEnumerator e;

            if (ordering == null)
            {
                e = extensions.Keys.GetEnumerator();
            }
            else
            {
                e = ordering.GetEnumerator();
            }

            while (e.MoveNext())
            {
                this.ordering.Add(e.Current);
            }

            e = this.ordering.GetEnumerator();

            while (e.MoveNext())
            {
                DERObjectIdentifier oid = (DERObjectIdentifier)e.Current;
                X509Extension       ext = (X509Extension)extensions[oid];

                this.extensions.Add(oid, ext);
            }
        }
示例#15
0
 public CertBag(
     DERObjectIdentifier certId,
     ASN1Object certValue)
 {
     this.certId    = certId;
     this.certValue = certValue;
 }
示例#16
0
 public X9FieldID(
     DERObjectIdentifier id,
     BigInteger primeP)
 {
     this.id         = id;
     this.parameters = new DERInteger(primeP);
 }
示例#17
0
 public PolicyInformation(
     DERObjectIdentifier policyIdentifier,
     ASN1Sequence policyQualifiers)
 {
     this.policyIdentifier = policyIdentifier;
     this.policyQualifiers = policyQualifiers;
 }
示例#18
0
 public static ASN1Encodable generateAlgorithmParameters(
     DERObjectIdentifier algorithmOID,
     byte[]              salt,
     int iterationCount)
 {
     return(generateAlgorithmParameters(algorithmOID.getId(), salt, iterationCount));
 }
示例#19
0
 public ContentInfo(
     DERObjectIdentifier contentType,
     ASN1Encodable content)
 {
     this.contentType = contentType;
     this.content     = content;
 }
示例#20
0
 public ResponseBytes(
     DERObjectIdentifier responseType,
     ASN1OctetString response)
 {
     this.responseType = responseType;
     this.response     = response;
 }
示例#21
0
 public SafeBag(
     DERObjectIdentifier oid,
     ASN1Object obj)
 {
     this.bagId         = oid;
     this.bagValue      = obj;
     this.bagAttributes = null;
 }
示例#22
0
 public SafeBag(
     DERObjectIdentifier oid,
     ASN1Object obj,
     ASN1Set bagAttributes)
 {
     this.bagId         = oid;
     this.bagValue      = obj;
     this.bagAttributes = bagAttributes;
 }
示例#23
0
 public EncryptedContentInfo(
     DERObjectIdentifier contentType,
     AlgorithmIdentifier contentEncryptionAlgorithm,
     ASN1OctetString encryptedContent)
 {
     this.contentType = contentType;
     this.contentEncryptionAlgorithm = contentEncryptionAlgorithm;
     this.encryptedContent           = encryptedContent;
 }
示例#24
0
 public static EncryptedPrivateKeyInfo createEncryptedPrivateKeyInfo(
     DERObjectIdentifier algorithm,
     char[] passPhrase,
     byte[] salt,
     int iterationCount,
     AsymmetricKeyParameter key)
 {
     return(createEncryptedPrivateKeyInfo(algorithm.getId(), passPhrase, salt, iterationCount, PrivateKeyInfoFactory.createPrivateKeyInfo(key)));
 }
示例#25
0
 /// <summary>
 /// Add and extension to this certificate.
 /// </summary>
 /// <param name="OID">The object identifier.</param>
 /// <param name="critical">Is it critical.</param>
 /// <param name="value">byte[] containing the value of this extension.</param>
 public void addExtension(DERObjectIdentifier OID, bool critical, byte[] value)
 {
     if (extensions == null)
     {
         extensions  = new Hashtable();
         extOrdering = new ArrayList();
     }
     extensions[OID] = new X509Extension(critical, new DEROctetString(value));
     extOrdering.Add(OID);
 }
示例#26
0
        /// <summary>
        /// Return the value for a given OID.
        /// </summary>
        /// <param name="ident">The oid of the entry.</param>
        /// <returns>The string representation of the value.</returns>
        public ASN1Object getRDN(DERObjectIdentifier ident)
        {
            int i = ordering.IndexOf(ident);

            if (i == -1)
            {
                return(null);
            }
            return((ASN1Object)values[i]);
        }
示例#27
0
        public KeySpecificInfo(
            ASN1Sequence seq)
        {
            IEnumerator e = seq.getObjects();

            e.MoveNext();
            algorithm = (DERObjectIdentifier)e.Current;
            e.MoveNext();
            counter = (ASN1OctetString)e.Current;
        }
示例#28
0
        public PolicyInformation(
            ASN1Sequence seq)
        {
            policyIdentifier = (DERObjectIdentifier)seq.getObjectAt(0);

            if (seq.size() > 1)
            {
                policyQualifiers = (ASN1Sequence)seq.getObjectAt(1);
            }
        }
示例#29
0
        public SMIMECapability(
            ASN1Sequence seq)
        {
            capabilityID = (DERObjectIdentifier)seq.getObjectAt(0);

            if (seq.size() > 1)
            {
                parameters = (ASN1Object)seq.getObjectAt(1);
            }
        }
示例#30
0
 public SafeBag(
     ASN1Sequence seq)
 {
     this.bagId    = (DERObjectIdentifier)seq.getObjectAt(0);
     this.bagValue = ((DERTaggedObject)seq.getObjectAt(1)).getObject();
     if (seq.size() == 3)
     {
         this.bagAttributes = (ASN1Set)seq.getObjectAt(2);
     }
 }