private EncryptedValue(Asn1Sequence seq)
        {
            int index = 0;
            while (seq[index] is Asn1TaggedObject)
            {
                Asn1TaggedObject tObj = (Asn1TaggedObject)seq[index];

                switch (tObj.TagNo)
                {
                    case 0:
                        intendedAlg = AlgorithmIdentifier.GetInstance(tObj, false);
                        break;
                    case 1:
                        symmAlg = AlgorithmIdentifier.GetInstance(tObj, false);
                        break;
                    case 2:
                        encSymmKey = DerBitString.GetInstance(tObj, false);
                        break;
                    case 3:
                        keyAlg = AlgorithmIdentifier.GetInstance(tObj, false);
                        break;
                    case 4:
                        valueHint = Asn1OctetString.GetInstance(tObj, false);
                        break;
                }
                ++index;
            }

            encValue = DerBitString.GetInstance(seq[index]);
        }
예제 #2
0
 public DigestInfo(
     AlgorithmIdentifier	algID,
     byte[]				digest)
 {
     this.digest = digest;
     this.algID = algID;
 }
 public CompressedDataParser(
     Asn1SequenceParser seq)
 {
     this._version = (DerInteger)seq.ReadObject();
     this._compressionAlgorithm = AlgorithmIdentifier.GetInstance(seq.ReadObject().ToAsn1Object());
     this._encapContentInfo = new ContentInfoParser((Asn1SequenceParser)seq.ReadObject());
 }
 public EncryptedPrivateKeyInfo(
     AlgorithmIdentifier	algId,
     byte[]				encoding)
 {
     this.algId = algId;
     this.data = new DerOctetString(encoding);
 }
예제 #5
0
 /**
  * Creates a new PKMACValue.
  * @param aid CMPObjectIdentifiers.passwordBasedMAC, with PBMParameter
  * @param value MAC of the DER-encoded SubjectPublicKeyInfo
  */
 public PKMacValue(
     AlgorithmIdentifier algID,
     DerBitString        macValue)
 {
     this.algID = algID;
     this.macValue = macValue;
 }
        public RsassaPssParameters(
            Asn1Sequence seq)
        {
            hashAlgorithm = DefaultHashAlgorithm;
            maskGenAlgorithm = DefaultMaskGenFunction;
            saltLength = DefaultSaltLength;
            trailerField = DefaultTrailerField;

            for (int i = 0; i != seq.Count; i++)
            {
                Asn1TaggedObject o = (Asn1TaggedObject)seq[i];

                switch (o.TagNo)
                {
                    case 0:
                        hashAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
                        break;
                    case 1:
                        maskGenAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
                        break;
                    case 2:
                        saltLength = DerInteger.GetInstance(o, true);
                        break;
                    case 3:
                        trailerField = DerInteger.GetInstance(o, true);
                        break;
                    default:
                        throw new ArgumentException("unknown tag");
                }
            }
        }
 /**
  * The default version
  */
 public RsassaPssParameters()
 {
     hashAlgorithm = DefaultHashAlgorithm;
     maskGenAlgorithm = DefaultMaskGenFunction;
     saltLength = DefaultSaltLength;
     trailerField = DefaultTrailerField;
 }
        public RsaesOaepParameters(
            Asn1Sequence seq)
        {
            hashAlgorithm = DefaultHashAlgorithm;
            maskGenAlgorithm = DefaultMaskGenFunction;
            pSourceAlgorithm = DefaultPSourceAlgorithm;

            for (int i = 0; i != seq.Count; i++)
            {
                Asn1TaggedObject o = (Asn1TaggedObject)seq[i];

                switch (o.TagNo)
                {
                    case 0:
                        hashAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
                        break;
                    case 1:
                        maskGenAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
                        break;
                    case 2:
                        pSourceAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
                        break;
                    default:
                        throw new ArgumentException("unknown tag");
                }
            }
        }
        public AuthenticatedData(
            OriginatorInfo		originatorInfo,
            Asn1Set				recipientInfos,
            AlgorithmIdentifier	macAlgorithm,
            AlgorithmIdentifier	digestAlgorithm,
            ContentInfo			encapsulatedContent,
            Asn1Set				authAttrs,
            Asn1OctetString		mac,
            Asn1Set				unauthAttrs)
        {
            if (digestAlgorithm != null || authAttrs != null)
            {
                if (digestAlgorithm == null || authAttrs == null)
                {
                    throw new ArgumentException("digestAlgorithm and authAttrs must be set together");
                }
            }

            version = new DerInteger(CalculateVersion(originatorInfo));

            this.originatorInfo = originatorInfo;
            this.macAlgorithm = macAlgorithm;
            this.digestAlgorithm = digestAlgorithm;
            this.recipientInfos = recipientInfos;
            this.encapsulatedContentInfo = encapsulatedContent;
            this.authAttrs = authAttrs;
            this.mac = mac;
            this.unauthAttrs = unauthAttrs;
        }
        private LdsSecurityObject(
            Asn1Sequence seq)
        {
            if (seq == null || seq.Count == 0)
                throw new ArgumentException("null or empty sequence passed.");

            IEnumerator e = seq.GetEnumerator();

            // version
            e.MoveNext();
            version = DerInteger.GetInstance(e.Current);
            // digestAlgorithmIdentifier
            e.MoveNext();
            digestAlgorithmIdentifier = AlgorithmIdentifier.GetInstance(e.Current);

            e.MoveNext();
            Asn1Sequence datagroupHashSeq = Asn1Sequence.GetInstance(e.Current);

            if (version.Value.Equals(BigInteger.One))
            {
                e.MoveNext();
                versionInfo = LdsVersionInfo.GetInstance(e.Current);
            }

            CheckDatagroupHashSeqSize(datagroupHashSeq.Count);

            datagroupHash = new DataGroupHash[datagroupHashSeq.Count];
            for (int i= 0; i< datagroupHashSeq.Count; i++)
            {
                datagroupHash[i] = DataGroupHash.GetInstance(datagroupHashSeq[i]);
            }
        }
 public EncryptedContentInfoParser(
     Asn1SequenceParser seq)
 {
     _contentType = (DerObjectIdentifier)seq.ReadObject();
     _contentEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq.ReadObject().ToAsn1Object());
     _encryptedContent = (Asn1TaggedObjectParser)seq.ReadObject();
 }
 public OriginatorPublicKey(
     AlgorithmIdentifier algorithm,
     byte[]              publicKey)
 {
     this.algorithm = algorithm;
     this.publicKey = new DerBitString(publicKey);
 }
 public KekRecipientInfo(
     Asn1Sequence seq)
 {
     version = (DerInteger) seq[0];
     kekID = KekIdentifier.GetInstance(seq[1]);
     keyEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq[2]);
     encryptedKey = (Asn1OctetString) seq[3];
 }
 public KeyTransRecipientInfo(
     Asn1Sequence seq)
 {
     this.version = (DerInteger) seq[0];
     this.rid = RecipientIdentifier.GetInstance(seq[1]);
     this.keyEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq[2]);
     this.encryptedKey = (Asn1OctetString) seq[3];
 }
 public PasswordRecipientInfo(
     AlgorithmIdentifier	keyEncryptionAlgorithm,
     Asn1OctetString		encryptedKey)
 {
     this.version = new DerInteger(0);
     this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
     this.encryptedKey = encryptedKey;
 }
 public EncryptedContentInfo(
     DerObjectIdentifier	contentType,
     AlgorithmIdentifier	contentEncryptionAlgorithm,
     Asn1OctetString		encryptedContent)
 {
     this.contentType = contentType;
     this.contentEncryptionAlgorithm = contentEncryptionAlgorithm;
     this.encryptedContent = encryptedContent;
 }
        private EncryptedPrivateKeyInfo(
            Asn1Sequence seq)
        {
            if (seq.Count != 2)
                throw new ArgumentException("Wrong number of elements in sequence", "seq");

            algId = AlgorithmIdentifier.GetInstance(seq[0]);
            data = Asn1OctetString.GetInstance(seq[1]);
        }
 public RsaesOaepParameters(
     AlgorithmIdentifier hashAlgorithm,
     AlgorithmIdentifier maskGenAlgorithm,
     AlgorithmIdentifier pSourceAlgorithm)
 {
     this.hashAlgorithm = hashAlgorithm;
     this.maskGenAlgorithm = maskGenAlgorithm;
     this.pSourceAlgorithm = pSourceAlgorithm;
 }
예제 #19
0
 public PrivateKeyInfo(
     AlgorithmIdentifier	algID,
     Asn1Object			privateKey,
     Asn1Set				attributes)
 {
     this.algID = algID;
     this.privKey = new DerOctetString(privateKey.GetEncoded(Asn1Encodable.Der));
     this.attributes = attributes;
 }
예제 #20
0
        private DigestInfo(
            Asn1Sequence seq)
        {
            if (seq.Count != 2)
                throw new ArgumentException("Wrong number of elements in sequence", "seq");

            algID = AlgorithmIdentifier.GetInstance(seq[0]);
            digest = Asn1OctetString.GetInstance(seq[1]).GetOctets();
        }
 public CertificationRequest(
     CertificationRequestInfo	requestInfo,
     AlgorithmIdentifier			algorithm,
     DerBitString				signature)
 {
     this.reqInfo = requestInfo;
     this.sigAlgId = algorithm;
     this.sigBits = signature;
 }
        private CertificateList(
            Asn1Sequence seq)
        {
            if (seq.Count != 3)
                throw new ArgumentException("sequence wrong size for CertificateList", "seq");

            tbsCertList = TbsCertificateList.GetInstance(seq[0]);
            sigAlgID = AlgorithmIdentifier.GetInstance(seq[1]);
            sig = DerBitString.GetInstance(seq[2]);
        }
예제 #23
0
 public EncryptedData(
     DerObjectIdentifier	contentType,
     AlgorithmIdentifier	encryptionAlgorithm,
     Asn1Encodable		content)
 {
     data = new BerSequence(
         contentType,
         encryptionAlgorithm.ToAsn1Object(),
         new BerTaggedObject(false, 0, content));
 }
 public KekRecipientInfo(
     KekIdentifier       kekID,
     AlgorithmIdentifier keyEncryptionAlgorithm,
     Asn1OctetString     encryptedKey)
 {
     this.version = new DerInteger(4);
     this.kekID = kekID;
     this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
     this.encryptedKey = encryptedKey;
 }
        public LdsSecurityObject(
            AlgorithmIdentifier	digestAlgorithmIdentifier,
            DataGroupHash[]		datagroupHash)
        {
            this.version = new DerInteger(0);
            this.digestAlgorithmIdentifier = digestAlgorithmIdentifier;
            this.datagroupHash = datagroupHash;

            CheckDatagroupHashSeqSize(datagroupHash.Length);
        }
        public CertificationRequest(
            Asn1Sequence seq)
        {
            if (seq.Count != 3)
                throw new ArgumentException("Wrong number of elements in sequence", "seq");

            reqInfo = CertificationRequestInfo.GetInstance(seq[0]);
            sigAlgId = AlgorithmIdentifier.GetInstance(seq[1]);
            sigBits = DerBitString.GetInstance(seq[2]);
        }
 public BasicOcspResponse(
     ResponseData		tbsResponseData,
     AlgorithmIdentifier	signatureAlgorithm,
     DerBitString		signature,
     Asn1Sequence		certs)
 {
     this.tbsResponseData = tbsResponseData;
     this.signatureAlgorithm = signatureAlgorithm;
     this.signature = signature;
     this.certs = certs;
 }
 public RsassaPssParameters(
     AlgorithmIdentifier hashAlgorithm,
     AlgorithmIdentifier maskGenAlgorithm,
     DerInteger saltLength,
     DerInteger trailerField)
 {
     this.hashAlgorithm = hashAlgorithm;
     this.maskGenAlgorithm = maskGenAlgorithm;
     this.saltLength = saltLength;
     this.trailerField = trailerField;
 }
예제 #29
0
        private CertID(
            Asn1Sequence seq)
        {
            if (seq.Count != 4)
                throw new ArgumentException("Wrong number of elements in sequence", "seq");

            this.hashAlgorithm = AlgorithmIdentifier.GetInstance(seq[0]);
            this.issuerNameHash = Asn1OctetString.GetInstance(seq[1]);
            this.issuerKeyHash = Asn1OctetString.GetInstance(seq[2]);
            this.serialNumber = DerInteger.GetInstance(seq[3]);
        }
예제 #30
0
 public CertID(
     AlgorithmIdentifier hashAlgorithm,
     Asn1OctetString     issuerNameHash,
     Asn1OctetString     issuerKeyHash,
     DerInteger          serialNumber)
 {
     this.hashAlgorithm = hashAlgorithm;
     this.issuerNameHash = issuerNameHash;
     this.issuerKeyHash = issuerKeyHash;
     this.serialNumber = serialNumber;
 }