Inheritance: Asn1Object, Asn1OctetStringParser
 public Pkcs12PbeParams(
     byte[]	salt,
     int		iterations)
 {
     this.iv = new DerOctetString(salt);
     this.iterations = new DerInteger(iterations);
 }
Ejemplo n.º 2
0
		public RC2CbcParameter(
            int		parameterVersion,
            byte[]	iv)
        {
            this.version = new DerInteger(parameterVersion);
            this.iv = new DerOctetString(iv);
        }
Ejemplo n.º 3
0
		public Cast5CbcParameters(
            byte[]	iv,
            int		keyLength)
        {
            this.iv = new DerOctetString(iv);
            this.keyLength = new DerInteger(keyLength);
        }
        public RecipientKeyIdentifier(
            Asn1Sequence seq)
        {
            subjectKeyIdentifier = Asn1OctetString.GetInstance(
                seq[0]);

            switch(seq.Count)
            {
                case 1:
                    break;
                case 2:
                    if (seq[1] is DerGeneralizedTime)
                    {
                        date = (DerGeneralizedTime) seq[1];
                    }
                    else
                    {
                        other = OtherKeyAttribute.GetInstance(seq[2]);
                    }
                    break;
                case 3:
                    date  = (DerGeneralizedTime) seq[1];
                    other = OtherKeyAttribute.GetInstance(seq[2]);
                    break;
                default:
                    throw new ArgumentException("Invalid RecipientKeyIdentifier");
            }
        }
Ejemplo n.º 5
0
		public DataGroupHash(
            int				dataGroupNumber,
            Asn1OctetString	dataGroupHashValue)
        {
            this.dataGroupNumber = new DerInteger(dataGroupNumber);
            this.dataGroupHashValue = dataGroupHashValue;
        }
Ejemplo n.º 6
0
 public PbeParameter(
     byte[]	salt,
     int		iterationCount)
 {
     this.octStr = new DerOctetString(salt);
     this.iterationCount = new DerInteger(iterationCount);
 }
		public KeyAgreeRecipientInformation(
			KeyAgreeRecipientInfo	info,
			AlgorithmIdentifier		encAlg,
			Stream					data)
			: base(encAlg, AlgorithmIdentifier.GetInstance(info.KeyEncryptionAlgorithm), data)
		{
			_info = info;
//			_encAlg = encAlg;

			try
			{
				Asn1Sequence s = _info.RecipientEncryptedKeys;
				RecipientEncryptedKey id = RecipientEncryptedKey.GetInstance(s[0]);

				Asn1.Cms.IssuerAndSerialNumber iAnds = id.Identifier.IssuerAndSerialNumber;

//				byte[] issuerBytes = iAnds.Name.GetEncoded();

				_rid = new RecipientID();
//				_rid.SetIssuer(issuerBytes);
				_rid.Issuer = iAnds.Name;
				_rid.SerialNumber = iAnds.SerialNumber.Value;

				_encryptedKey = id.EncryptedKey;
			}
			catch (IOException e)
			{
				throw new ArgumentException("invalid rid in KeyAgreeRecipientInformation", e);
			}
		}
Ejemplo n.º 8
0
		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];
        }
Ejemplo n.º 9
0
		private IdeaCbcPar(
            Asn1Sequence seq)
        {
			if (seq.Count == 1)
			{
				iv = (Asn1OctetString) seq[0];
			}
        }
Ejemplo n.º 10
0
		public KekRecipientInfo(
            Asn1Sequence seq)
        {
            version = (DerInteger) seq[0];
            kekID = KekIdentifier.GetInstance(seq[1]);
            keyEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq[2]);
            encryptedKey = (Asn1OctetString) seq[3];
        }
Ejemplo n.º 11
0
		public PasswordRecipientInfo(
            AlgorithmIdentifier	keyEncryptionAlgorithm,
            Asn1OctetString		encryptedKey)
        {
            this.version = new DerInteger(0);
            this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
            this.encryptedKey = encryptedKey;
        }
Ejemplo n.º 12
0
		private PbeParameter(Asn1Sequence seq)
		{
			if (seq.Count != 2)
				throw new ArgumentException("Wrong number of elements in sequence", "seq");

			salt = Asn1OctetString.GetInstance(seq[0]);
			iterationCount = DerInteger.GetInstance(seq[1]);
		}
Ejemplo n.º 13
0
        public ResponderID(
            Asn1OctetString id)
        {
            if (id == null)
                throw new ArgumentNullException("id");

            this.id = id;
        }
Ejemplo n.º 14
0
		private Cast5CbcParameters(
            Asn1Sequence seq)
        {
			if (seq.Count != 2)
				throw new ArgumentException("Wrong number of elements in sequence", "seq");

			iv = (Asn1OctetString) seq[0];
            keyLength = (DerInteger) seq[1];
        }
Ejemplo n.º 15
0
 public RecipientKeyIdentifier(
     Asn1OctetString         subjectKeyIdentifier,
     DerGeneralizedTime      date,
     OtherKeyAttribute       other)
 {
     this.subjectKeyIdentifier = subjectKeyIdentifier;
     this.date = date;
     this.other = other;
 }
Ejemplo n.º 16
0
		public KekIdentifier(
            byte[]              keyIdentifier,
            DerGeneralizedTime  date,
            OtherKeyAttribute   other)
        {
            this.keyIdentifier = new DerOctetString(keyIdentifier);
            this.date = date;
            this.other = other;
        }
Ejemplo n.º 17
0
		private ResponseBytes(
            Asn1Sequence seq)
        {
			if (seq.Count != 2)
				throw new ArgumentException("Wrong number of elements in sequence", "seq");

			this.responseType = DerObjectIdentifier.GetInstance(seq[0]);
            this.response = Asn1OctetString.GetInstance(seq[1]);
        }
		public EncryptedContentInfo(
            DerObjectIdentifier	contentType,
            AlgorithmIdentifier	contentEncryptionAlgorithm,
            Asn1OctetString		encryptedContent)
        {
            this.contentType = contentType;
            this.contentEncryptionAlgorithm = contentEncryptionAlgorithm;
            this.encryptedContent = encryptedContent;
        }
Ejemplo n.º 19
0
		private DataGroupHash(
			Asn1Sequence seq)
        {
			if (seq.Count != 2)
				throw new ArgumentException("Wrong number of elements in sequence", "seq");

			this.dataGroupNumber = DerInteger.GetInstance(seq[0]);
            this.dataGroupHashValue = Asn1OctetString.GetInstance(seq[1]);
        }
Ejemplo n.º 20
0
		public RecipientKeyIdentifier(
			byte[]				subjectKeyIdentifier,
			DerGeneralizedTime	date,
			OtherKeyAttribute	other)
		{
			this.subjectKeyIdentifier = new DerOctetString(subjectKeyIdentifier);
			this.date = date;
			this.other = other;
		}
        private Gost28147Parameters(
            Asn1Sequence seq)
        {
			if (seq.Count != 2)
				throw new ArgumentException("Wrong number of elements in sequence", "seq");

			this.iv = Asn1OctetString.GetInstance(seq[0]);
			this.paramSet = DerObjectIdentifier.GetInstance(seq[1]);
        }
Ejemplo n.º 22
0
		public KekRecipientInfo(
            KekIdentifier       kekID,
            AlgorithmIdentifier keyEncryptionAlgorithm,
            Asn1OctetString     encryptedKey)
        {
            this.version = new DerInteger(4);
            this.kekID = kekID;
            this.keyEncryptionAlgorithm = keyEncryptionAlgorithm;
            this.encryptedKey = encryptedKey;
        }
Ejemplo n.º 23
0
 public BiometricData(
     TypeOfBiometricData	typeOfBiometricData,
     AlgorithmIdentifier	hashAlgorithm,
     Asn1OctetString		biometricDataHash)
 {
     this.typeOfBiometricData = typeOfBiometricData;
     this.hashAlgorithm = hashAlgorithm;
     this.biometricDataHash = biometricDataHash;
     this.sourceDataUri = null;
 }
Ejemplo n.º 24
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]);
        }
 internal KeyAgreeRecipientInformation(
     KeyAgreeRecipientInfo	info,
     RecipientID				rid,
     Asn1OctetString			encryptedKey,
     CmsSecureReadable		secureReadable)
     : base(info.KeyEncryptionAlgorithm, secureReadable)
 {
     this.info = info;
     this.rid = rid;
     this.encryptedKey = encryptedKey;
 }
Ejemplo n.º 26
0
		public CertID(
            AlgorithmIdentifier hashAlgorithm,
            Asn1OctetString     issuerNameHash,
            Asn1OctetString     issuerKeyHash,
            DerInteger          serialNumber)
        {
            this.hashAlgorithm = hashAlgorithm;
            this.issuerNameHash = issuerNameHash;
            this.issuerKeyHash = issuerKeyHash;
            this.serialNumber = serialNumber;
        }
Ejemplo n.º 27
0
		private static ICollection GetAlternativeName(
			Asn1OctetString extVal)
		{
			IList temp = Platform.CreateArrayList();

			if (extVal != null)
			{
				try
				{
					Asn1Sequence seq = DerSequence.GetInstance(FromExtensionValue(extVal));

					foreach (Asn1Encodable primName in seq)
					{
                        IList list = Platform.CreateArrayList();
                        GeneralName genName = GeneralName.GetInstance(primName);

						list.Add(genName.TagNo);

						switch (genName.TagNo)
						{
							case GeneralName.EdiPartyName:
							case GeneralName.X400Address:
							case GeneralName.OtherName:
								list.Add(genName.Name.ToAsn1Object());
								break;
							case GeneralName.DirectoryName:
								list.Add(X509Name.GetInstance(genName.Name).ToString());
								break;
							case GeneralName.DnsName:
							case GeneralName.Rfc822Name:
							case GeneralName.UniformResourceIdentifier:
								list.Add(((IAsn1String)genName.Name).GetString());
								break;
							case GeneralName.RegisteredID:
								list.Add(DerObjectIdentifier.GetInstance(genName.Name).Id);
								break;
							case GeneralName.IPAddress:
								list.Add(DerOctetString.GetInstance(genName.Name).GetOctets());
								break;
							default:
								throw new IOException("Bad tag number: " + genName.TagNo);
						}

						temp.Add(list);
					}
				}
				catch (Exception e)
				{
					throw new CertificateParsingException(e.Message);
				}
			}

			return temp;
		}
Ejemplo n.º 28
0
        /**
         *
         * Calulates the keyidentifier using a SHA1 hash over the BIT STRING
         * from SubjectPublicKeyInfo as defined in RFC2459.
         *
         * Example of making a AuthorityKeyIdentifier:
         * <pre>
         *   SubjectPublicKeyInfo apki = new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(
         *       publicKey.getEncoded()).readObject());
         *   AuthorityKeyIdentifier aki = new AuthorityKeyIdentifier(apki);
         * </pre>
         *
         **/
        public AuthorityKeyIdentifier(
            SubjectPublicKeyInfo spki)
        {
            IDigest digest = new Sha1Digest();
            byte[] resBuf = new byte[digest.GetDigestSize()];

            byte[] bytes = spki.PublicKeyData.GetBytes();
            digest.BlockUpdate(bytes, 0, bytes.Length);
            digest.DoFinal(resBuf, 0);
            this.keyidentifier = new DerOctetString(resBuf);
        }
		public EncryptedContentInfo(
            Asn1Sequence seq)
        {
            contentType = (DerObjectIdentifier) seq[0];
            contentEncryptionAlgorithm = AlgorithmIdentifier.GetInstance(seq[1]);

			if (seq.Count > 2)
            {
                encryptedContent = Asn1OctetString.GetInstance(
					(Asn1TaggedObject) seq[2], false);
            }
        }
Ejemplo n.º 30
0
		public ResponseBytes(
            DerObjectIdentifier	responseType,
            Asn1OctetString		response)
        {
			if (responseType == null)
				throw new ArgumentNullException("responseType");
			if (response == null)
				throw new ArgumentNullException("response");

			this.responseType = responseType;
            this.response = response;
        }