Reader for PGP objects.
Inheritance: Org.BouncyCastle.Utilities.IO.BaseInputStream
		public ElGamalPublicBcpgKey(
			BcpgInputStream bcpgIn)
		{
			this.p = new MPInteger(bcpgIn);
			this.g = new MPInteger(bcpgIn);
			this.y = new MPInteger(bcpgIn);
		}
        internal PublicKeyEncSessionPacket(
			BcpgInputStream bcpgIn)
        {
            version = bcpgIn.ReadByte();

            keyId |= (long)bcpgIn.ReadByte() << 56;
            keyId |= (long)bcpgIn.ReadByte() << 48;
            keyId |= (long)bcpgIn.ReadByte() << 40;
            keyId |= (long)bcpgIn.ReadByte() << 32;
            keyId |= (long)bcpgIn.ReadByte() << 24;
            keyId |= (long)bcpgIn.ReadByte() << 16;
            keyId |= (long)bcpgIn.ReadByte() << 8;
            keyId |= (uint)bcpgIn.ReadByte();

            algorithm = (PublicKeyAlgorithmTag) bcpgIn.ReadByte();

            switch ((PublicKeyAlgorithmTag) algorithm)
            {
                case PublicKeyAlgorithmTag.RsaEncrypt:
                case PublicKeyAlgorithmTag.RsaGeneral:
                    data = new BigInteger[]{ new MPInteger(bcpgIn).Value };
                    break;
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                    data = new BigInteger[]
                    {
                        new MPInteger(bcpgIn).Value,
                        new MPInteger(bcpgIn).Value
                    };
                    break;
                default:
                    throw new IOException("unknown PGP public key algorithm encountered");
            }
        }
 /// <param name="bcpgIn">The stream to read the packet from.</param>
 public DsaPublicBcpgKey(BcpgInputStream bcpgIn)
 {
     _p = new MPInteger(bcpgIn);
     _q = new MPInteger(bcpgIn);
     _g = new MPInteger(bcpgIn);
     _y = new MPInteger(bcpgIn);
 }
Esempio n. 4
0
        internal PublicKeyPacket(
            BcpgInputStream bcpgIn)
        {
            version = bcpgIn.ReadByte();

            time = ((uint)bcpgIn.ReadByte() << 24) | ((uint)bcpgIn.ReadByte() << 16)
                | ((uint)bcpgIn.ReadByte() << 8) | (uint)bcpgIn.ReadByte();

            if (version <= 3)
            {
                validDays = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
            }

            algorithm = (PublicKeyAlgorithmTag) bcpgIn.ReadByte();

            switch ((PublicKeyAlgorithmTag) algorithm)
            {
                case PublicKeyAlgorithmTag.RsaEncrypt:
                case PublicKeyAlgorithmTag.RsaGeneral:
                case PublicKeyAlgorithmTag.RsaSign:
                    key = new RsaPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.Dsa:
                    key = new DsaPublicBcpgKey(bcpgIn);
                    break;
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                    key = new ElGamalPublicBcpgKey(bcpgIn);
                    break;
                default:
                    throw new IOException("unknown PGP public key algorithm encountered");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SecretKeyPacket"/> class.
        /// </summary>
        /// <param name="bcpgIn">The BCPG in.</param>
        internal SecretKeyPacket(BcpgInputStream bcpgIn)
        {
            if (this is SecretSubkeyPacket)
            {
                this.PublicKeyPacket = new PublicSubkeyPacket(bcpgIn);
            }
            else
            {
                this.PublicKeyPacket = new PublicKeyPacket(bcpgIn);
            }

            this.S2KUsage = bcpgIn.ReadByte();

            if (this.S2KUsage == UsageChecksum || this.S2KUsage == UsageSha1)
            {
                this.EncAlgorithm = (SymmetricKeyAlgorithmTag)bcpgIn.ReadByte();
                this.S2K = new S2k(bcpgIn);
            }
            else
            {
                this.EncAlgorithm = (SymmetricKeyAlgorithmTag)this.S2KUsage;
            }

            if (!(this.S2K != null && this.S2K.Type == S2k.GnuDummyS2K && this.S2K.ProtectionMode == 0x01))
            {
                if (this.S2KUsage != 0)
                {
                    _iv = ((int)EncAlgorithm) < 7 ? new byte[8] : new byte[16];
                    bcpgIn.ReadFully(_iv);
                }
            }

            _secKeyData = bcpgIn.ReadAll();
        }
Esempio n. 6
0
        internal SecretKeyPacket(
            BcpgInputStream bcpgIn)
        {
            pubKeyPacket = new PublicKeyPacket(bcpgIn);

            s2kUsage = bcpgIn.ReadByte();

            if (s2kUsage == UsageChecksum || s2kUsage == UsageSha1)
            {
                encAlgorithm = (SymmetricKeyAlgorithmTag) bcpgIn.ReadByte();
                s2k = new S2k(bcpgIn);
            }
            else
            {
                encAlgorithm = (SymmetricKeyAlgorithmTag) s2kUsage;
            }

            if (!(s2k != null && s2k.Type == S2k.GnuDummyS2K && s2k.ProtectionMode == 0x01))
            {
                if (s2kUsage != 0)
                {
                    if (((int) encAlgorithm) < 7)
                    {
                        iv = new byte[8];
                    }
                    else
                    {
                        iv = new byte[16];
                    }
                    bcpgIn.ReadFully(iv);
                }
            }

            secKeyData = bcpgIn.ReadAll();
        }
 /// <param name="bcpgIn">The stream to read the packet from.</param>
 public DsaPublicBcpgKey(
     BcpgInputStream bcpgIn)
 {
     this.p = new MPInteger(bcpgIn);
     this.q = new MPInteger(bcpgIn);
     this.g = new MPInteger(bcpgIn);
     this.y = new MPInteger(bcpgIn);
 }
		internal ExperimentalPacket(
            PacketTag		tag,
            BcpgInputStream	bcpgIn)
        {
            this.tag = tag;

			this.contents = bcpgIn.ReadAll();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SymmetricKeyEncSessionPacket"/> class.
        /// </summary>
        /// <param name="bcpgIn">The BCPG in.</param>
        public SymmetricKeyEncSessionPacket(BcpgInputStream bcpgIn)
        {
            Version = bcpgIn.ReadByte();
            EncAlgorithm = (SymmetricKeyAlgorithmTag)bcpgIn.ReadByte();

            S2K = new S2k(bcpgIn);

            _secKeyData = bcpgIn.ReadAll();
        }
Esempio n. 10
0
		internal ModDetectionCodePacket(
            BcpgInputStream bcpgIn)
        {
			if (bcpgIn == null)
				throw new ArgumentNullException("bcpgIn");

			this.digest = new byte[20];
            bcpgIn.ReadFully(this.digest);
        }
        public RsaSecretBcpgKey(BcpgInputStream bcpgIn)
        {
            _d = new MPInteger(bcpgIn);
            _p = new MPInteger(bcpgIn);
            _q = new MPInteger(bcpgIn);
            _u = new MPInteger(bcpgIn);

            _expP = _d.Value.Remainder(_p.Value.Subtract(BigInteger.One));
            _expQ = _d.Value.Remainder(_q.Value.Subtract(BigInteger.One));
            _crt = _q.Value.ModInverse(_p.Value);
        }
        public MPInteger(BcpgInputStream bcpgIn)
        {
            if (bcpgIn == null)
                throw new ArgumentNullException("bcpgIn");

            var length = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
            var bytes = new byte[(length + 7) / 8];

            bcpgIn.ReadFully(bytes);

            _val = new BigInteger(1, bytes);
        }
Esempio n. 13
0
		public RsaSecretBcpgKey(
			BcpgInputStream bcpgIn)
		{
			this.d = new MPInteger(bcpgIn);
			this.p = new MPInteger(bcpgIn);
			this.q = new MPInteger(bcpgIn);
			this.u = new MPInteger(bcpgIn);

			this.expP = d.Value.Remainder(p.Value.Subtract(BigInteger.One));
			this.expQ = d.Value.Remainder(q.Value.Subtract(BigInteger.One));
			this.crt = q.Value.ModInverse(p.Value);
		}
        public UserAttributePacket(BcpgInputStream bcpgIn)
        {
            var sIn = new UserAttributeSubpacketsParser(bcpgIn);
            UserAttributeSubpacket sub;

            var v = Platform.CreateArrayList<IUserAttributeSubpacket>();
            while ((sub = sIn.ReadPacket()) != null)
            {
                v.Add(sub);
            }
            _subpackets = v.ToArray();
        }
        public TrustPacket(BcpgInputStream bcpgIn)
        {
            using (var bOut = new MemoryStream())
            {
                int ch;
                while ((ch = bcpgIn.ReadByte()) >= 0)
                {
                    bOut.WriteByte((byte) ch);
                }

                _levelAndTrustAmount = bOut.ToArray();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ECDHPublicBcpgKey"/> class.
        /// </summary>
        /// <param name="bcpgIn">The BCPG in.</param>
        /// <exception cref="Org.BouncyCastle.Bcpg.OpenPgp.PgpException">kdf parameter size of 3 expected.</exception>
        /// <param name="oid">The OID.</param>
        private ECDHPublicBcpgKey(BcpgInputStream bcpgIn, DerObjectIdentifier oid)
            : base(bcpgIn, oid)
        {
            var kdfParamters = this.ReadBytesOfEncodedLength(bcpgIn);
            if(kdfParamters.Length != 3)
                throw new PgpException("kdf parameter size of 3 expected.");

            _reserved = kdfParamters[0];
            _hashFunctionId = kdfParamters[1];
            _symAlgorithmId = kdfParamters[2];

            this.VerifyHashAlgorithm();
            this.VerifySymmetricKeyAlgorithm();
        }
        protected static byte[] ReadBytesOfEncodedLength(
            BcpgInputStream bcpgIn)
        {
            int length = bcpgIn.ReadByte();
            if (length == 0 || length == 0xFF)
            {
                throw new IOException("future extensions not yet implemented.");
            }

            byte[] buffer = new byte[length + 2];
            bcpgIn.ReadFully(buffer, 2, buffer.Length - 2);
            buffer[0] = (byte)0x06;
            buffer[1] = (byte)length;

            return buffer;
        }
        /// <param name="bcpgIn">The stream to read the packet from.</param>
        public ECDHPublicBcpgKey(
            BcpgInputStream bcpgIn)
            : base(bcpgIn)
        {
            int length = bcpgIn.ReadByte();
            byte[] kdfParameters =  new byte[length];
            if (kdfParameters.Length != 3)
                throw new InvalidOperationException("kdf parameters size of 3 expected.");

            bcpgIn.ReadFully(kdfParameters);

            reserved = kdfParameters[0];
            hashFunctionId = kdfParameters[1];
            symAlgorithmId = kdfParameters[2];

            VerifyHashAlgorithm();
            VerifySymmetricKeyAlgorithm();
        }
Esempio n. 19
0
		internal LiteralDataPacket(
            BcpgInputStream bcpgIn)
			: base(bcpgIn)
        {
            format = bcpgIn.ReadByte();
            int len = bcpgIn.ReadByte();

			fileName = new byte[len];
			for (int i = 0; i != len; ++i)
            {
                fileName[i] = (byte)bcpgIn.ReadByte();
            }

			modDate = (((uint)bcpgIn.ReadByte() << 24)
				| ((uint)bcpgIn.ReadByte() << 16)
                | ((uint)bcpgIn.ReadByte() << 8)
				| (uint)bcpgIn.ReadByte()) * 1000L;
        }
        public UserAttributePacket(
            BcpgInputStream bcpgIn)
        {
            UserAttributeSubpacketsParser sIn = new UserAttributeSubpacketsParser(bcpgIn);
            UserAttributeSubpacket sub;

            IList v = Platform.CreateArrayList();
            while ((sub = sIn.ReadPacket()) != null)
            {
                v.Add(sub);
            }

            subpackets = new UserAttributeSubpacket[v.Count];

            for (int i = 0; i != subpackets.Length; i++)
            {
                subpackets[i] = (UserAttributeSubpacket)v[i];
            }
        }
Esempio n. 21
0
        internal LiteralDataPacket(
            BcpgInputStream bcpgIn)
            : base(bcpgIn)
        {
            format = bcpgIn.ReadByte();
            int l = bcpgIn.ReadByte();

            char[] fileNameChars = new char[l];
            for (int i = 0; i != fileNameChars.Length; i++)
            {
                fileNameChars[i] = (char)bcpgIn.ReadByte();
            }
            fileName = new string(fileNameChars);

            modDate = (((uint)bcpgIn.ReadByte() << 24)
                | ((uint)bcpgIn.ReadByte() << 16)
                | ((uint)bcpgIn.ReadByte() << 8)
                | (uint)bcpgIn.ReadByte()) * 1000L;
        }
		internal OnePassSignaturePacket(
			BcpgInputStream	bcpgIn)
		{
			version = bcpgIn.ReadByte();
			sigType = bcpgIn.ReadByte();
			hashAlgorithm = (HashAlgorithmTag) bcpgIn.ReadByte();
			keyAlgorithm = (PublicKeyAlgorithmTag) bcpgIn.ReadByte();

			keyId |= (long)bcpgIn.ReadByte() << 56;
			keyId |= (long)bcpgIn.ReadByte() << 48;
			keyId |= (long)bcpgIn.ReadByte() << 40;
			keyId |= (long)bcpgIn.ReadByte() << 32;
			keyId |= (long)bcpgIn.ReadByte() << 24;
			keyId |= (long)bcpgIn.ReadByte() << 16;
			keyId |= (long)bcpgIn.ReadByte() << 8;
			keyId |= (uint)bcpgIn.ReadByte();

			nested = bcpgIn.ReadByte();
		}
        internal PublicKeyEncSessionPacket(BcpgInputStream bcpgIn)
        {
            _version = bcpgIn.ReadByte();

            _keyId |= (long)bcpgIn.ReadByte() << 56;
            _keyId |= (long)bcpgIn.ReadByte() << 48;
            _keyId |= (long)bcpgIn.ReadByte() << 40;
            _keyId |= (long)bcpgIn.ReadByte() << 32;
            _keyId |= (long)bcpgIn.ReadByte() << 24;
            _keyId |= (long)bcpgIn.ReadByte() << 16;
            _keyId |= (long)bcpgIn.ReadByte() << 8;
            _keyId |= (uint)bcpgIn.ReadByte();

            _algorithm = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();

            switch (_algorithm)
            {
                case PublicKeyAlgorithmTag.RsaEncrypt:
                case PublicKeyAlgorithmTag.RsaGeneral:
                    _data = new[] { new MPInteger(bcpgIn).Value };
                    break;
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                    _data = new[]
                    {
                        new MPInteger(bcpgIn).Value,
                        new MPInteger(bcpgIn).Value
                    };
                    break;

                case PublicKeyAlgorithmTag.Ecdh:
                    _data = new[] { new MPInteger(bcpgIn).Value };
                    var length = bcpgIn.ReadByte();
                    if (length > 0xFF)
                        throw new IOException("EC DH symmetric key data is too long.");
                    _extraData = new byte[length];
                    bcpgIn.ReadFully(_extraData, 0, length);
                    break;
                default:
                    throw new IOException("unknown PGP public key algorithm encountered");
            }
        }
		internal PublicKeyEncSessionPacket(
			BcpgInputStream bcpgIn)
		{
			version = bcpgIn.ReadByte();

			keyId |= (long)bcpgIn.ReadByte() << 56;
			keyId |= (long)bcpgIn.ReadByte() << 48;
			keyId |= (long)bcpgIn.ReadByte() << 40;
			keyId |= (long)bcpgIn.ReadByte() << 32;
			keyId |= (long)bcpgIn.ReadByte() << 24;
			keyId |= (long)bcpgIn.ReadByte() << 16;
			keyId |= (long)bcpgIn.ReadByte() << 8;
			keyId |= (uint)bcpgIn.ReadByte();

			algorithm = (PublicKeyAlgorithmTag) bcpgIn.ReadByte();

			switch ((PublicKeyAlgorithmTag) algorithm)
			{
				case PublicKeyAlgorithmTag.RsaEncrypt:
				case PublicKeyAlgorithmTag.RsaGeneral:
					data = new byte[][]{ new MPInteger(bcpgIn).GetEncoded() };
					break;
				case PublicKeyAlgorithmTag.ElGamalEncrypt:
				case PublicKeyAlgorithmTag.ElGamalGeneral:
                    MPInteger p = new MPInteger(bcpgIn);
                    MPInteger g = new MPInteger(bcpgIn);
					data = new byte[][]{
                        p.GetEncoded(),
                        g.GetEncoded(),
                    };
					break;
                case PublicKeyAlgorithmTag.ECDH:
                    data = new byte[][]{ Streams.ReadAll(bcpgIn) };
                    break;
				default:
					throw new IOException("unknown PGP public key algorithm encountered");
			}
		}
Esempio n. 25
0
        public RsaSecretBcpgKey(
			BcpgInputStream bcpgIn)
        {
            this.d = new MPInteger(bcpgIn);

            MPInteger p = new MPInteger(bcpgIn);
            MPInteger q = new MPInteger(bcpgIn);

            // pgp requires (p < q)
            if (p.Value.CompareTo(q.Value) > 0)
            {
                MPInteger tmp = p;
                p = q;
                q = tmp;
            }

            this.p = p;
            this.q = q;

            this.u = new MPInteger(bcpgIn);
            this.expP = d.Value.Remainder(p.Value.Subtract(BigInteger.One));
            this.expQ = d.Value.Remainder(q.Value.Subtract(BigInteger.One));
            this.crt = q.Value.ModInverse(p.Value);
        }
Esempio n. 26
0
 /// <param name="bcpgIn">The stream to read the packet from.</param>
 protected internal ECDsaPublicBcpgKey(
     BcpgInputStream bcpgIn)
     : base(bcpgIn)
 {
 }
        internal SignaturePacket(BcpgInputStream bcpgIn)
        {
            _version = bcpgIn.ReadByte();


            //TODO: refactor
            switch (_version)
            {
            case 2:
            case 3:
                bcpgIn.ReadByte();
                _signatureType = bcpgIn.ReadByte();
                CreationTime   = (((long)bcpgIn.ReadByte() << 24) | ((long)bcpgIn.ReadByte() << 16)
                                  | ((long)bcpgIn.ReadByte() << 8) | (uint)bcpgIn.ReadByte()) * 1000L;
                _keyId        |= (long)bcpgIn.ReadByte() << 56;
                _keyId        |= (long)bcpgIn.ReadByte() << 48;
                _keyId        |= (long)bcpgIn.ReadByte() << 40;
                _keyId        |= (long)bcpgIn.ReadByte() << 32;
                _keyId        |= (long)bcpgIn.ReadByte() << 24;
                _keyId        |= (long)bcpgIn.ReadByte() << 16;
                _keyId        |= (long)bcpgIn.ReadByte() << 8;
                _keyId        |= (uint)bcpgIn.ReadByte();
                _keyAlgorithm  = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();
                _hashAlgorithm = (HashAlgorithmTag)bcpgIn.ReadByte();
                break;

            case 4:
            {
                _signatureType = bcpgIn.ReadByte();
                _keyAlgorithm  = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();
                _hashAlgorithm = (HashAlgorithmTag)bcpgIn.ReadByte();

                var hashedLength = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
                var hashed       = new byte[hashedLength];

                bcpgIn.ReadFully(hashed);

                //
                // read the signature sub packet data.
                //
                using (var hashedStream = new MemoryStream(hashed, false))
                {
                    var sIn = new SignatureSubpacketsParser(hashedStream);
                    var v   = Platform.CreateArrayList <ISignatureSubpacket>();

                    SignatureSubpacket sub;
                    while ((sub = sIn.ReadPacket()) != null)
                    {
                        v.Add(sub);

                        var issuerKeyId = sub as IssuerKeyId;
                        if (issuerKeyId != null)
                        {
                            _keyId = issuerKeyId.KeyId;
                        }
                        else
                        {
                            var signatureCreationTime = sub as SignatureCreationTime;
                            if (signatureCreationTime != null)
                            {
                                CreationTime = DateTimeUtilities.DateTimeToUnixMs(signatureCreationTime.GetTime());
                            }
                        }
                    }
                    _hashedData = v.ToArray();

                    var unhashedLength = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
                    var unhashed       = new byte[unhashedLength];
                    bcpgIn.ReadFully(unhashed);

                    v.Clear();
                    using (var unhashedStream = new MemoryStream(unhashed, false))
                    {
                        sIn = new SignatureSubpacketsParser(unhashedStream);

                        while ((sub = sIn.ReadPacket()) != null)
                        {
                            v.Add(sub);

                            var issuerKeyId = sub as IssuerKeyId;
                            if (issuerKeyId != null)
                            {
                                _keyId = issuerKeyId.KeyId;
                            }
                        }
                    }
                    _unhashedData = v.ToArray();
                }
            }
            break;

            default:
                throw new Exception("unsupported version: " + _version);
            }

            _fingerprint = new byte[2];
            bcpgIn.ReadFully(_fingerprint);

            switch (_keyAlgorithm)
            {
            case PublicKeyAlgorithmTag.RsaGeneral:
            case PublicKeyAlgorithmTag.RsaSign:
                var v = new MPInteger(bcpgIn);
                _signature = new[] { v };
                break;

            case PublicKeyAlgorithmTag.Dsa:
            case PublicKeyAlgorithmTag.Ecdsa:
            case PublicKeyAlgorithmTag.Ecdh:
                var r = new MPInteger(bcpgIn);
                var s = new MPInteger(bcpgIn);
                _signature = new[] { r, s };
                break;

            case PublicKeyAlgorithmTag.ElGamalEncrypt:     // yep, this really does happen sometimes.
            case PublicKeyAlgorithmTag.ElGamalGeneral:
                var p = new MPInteger(bcpgIn);
                var g = new MPInteger(bcpgIn);
                var y = new MPInteger(bcpgIn);
                _signature = new[] { p, g, y };
                break;

            default:
                if (_keyAlgorithm >= PublicKeyAlgorithmTag.Experimental_1 && _keyAlgorithm <= PublicKeyAlgorithmTag.Experimental_11)
                {
                    _signature = null;
                    using (var bOut = new MemoryStream())
                    {
                        int ch;
                        while ((ch = bcpgIn.ReadByte()) >= 0)
                        {
                            bOut.WriteByte((byte)ch);
                        }
                        _signatureEncoding = bOut.ToArray();
                    }
                }
                else
                {
                    throw new IOException("unknown signature key algorithm: " + _keyAlgorithm);
                }
                break;
            }
        }
Esempio n. 28
0
        public Packet ReadPacket()
        {
            int hdr = this.ReadByte();

            if (hdr < 0)
            {
                return(null);
            }

            if ((hdr & 0x80) == 0)
            {
                throw new IOException("invalid header encountered");
            }

            bool      newPacket = (hdr & 0x40) != 0;
            PacketTag tag       = 0;
            int       bodyLen   = 0;
            bool      partial   = false;

            if (newPacket)
            {
                tag = (PacketTag)(hdr & 0x3f);

                int l = this.ReadByte();

                if (l < 192)
                {
                    bodyLen = l;
                }
                else if (l <= 223)
                {
                    int b = m_in.ReadByte();
                    bodyLen = ((l - 192) << 8) + (b) + 192;
                }
                else if (l == 255)
                {
                    bodyLen = (m_in.ReadByte() << 24) | (m_in.ReadByte() << 16)
                              | (m_in.ReadByte() << 8) | m_in.ReadByte();
                }
                else
                {
                    partial = true;
                    bodyLen = 1 << (l & 0x1f);
                }
            }
            else
            {
                int lengthType = hdr & 0x3;

                tag = (PacketTag)((hdr & 0x3f) >> 2);

                switch (lengthType)
                {
                case 0:
                    bodyLen = this.ReadByte();
                    break;

                case 1:
                    bodyLen = (this.ReadByte() << 8) | this.ReadByte();
                    break;

                case 2:
                    bodyLen = (this.ReadByte() << 24) | (this.ReadByte() << 16)
                              | (this.ReadByte() << 8) | this.ReadByte();
                    break;

                case 3:
                    partial = true;
                    break;

                default:
                    throw new IOException("unknown length type encountered");
                }
            }

            BcpgInputStream objStream;

            if (bodyLen == 0 && partial)
            {
                objStream = this;
            }
            else
            {
                PartialInputStream pis = new PartialInputStream(this, partial, bodyLen);
                objStream = new BcpgInputStream(pis);
            }

            switch (tag)
            {
            case PacketTag.Reserved:
                return(new InputStreamPacket(objStream));

            case PacketTag.PublicKeyEncryptedSession:
                return(new PublicKeyEncSessionPacket(objStream));

            case PacketTag.Signature:
                return(new SignaturePacket(objStream));

            case PacketTag.SymmetricKeyEncryptedSessionKey:
                return(new SymmetricKeyEncSessionPacket(objStream));

            case PacketTag.OnePassSignature:
                return(new OnePassSignaturePacket(objStream));

            case PacketTag.SecretKey:
                return(new SecretKeyPacket(objStream));

            case PacketTag.PublicKey:
                return(new PublicKeyPacket(objStream));

            case PacketTag.SecretSubkey:
                return(new SecretSubkeyPacket(objStream));

            case PacketTag.CompressedData:
                return(new CompressedDataPacket(objStream));

            case PacketTag.SymmetricKeyEncrypted:
                return(new SymmetricEncDataPacket(objStream));

            case PacketTag.Marker:
                return(new MarkerPacket(objStream));

            case PacketTag.LiteralData:
                return(new LiteralDataPacket(objStream));

            case PacketTag.Trust:
                return(new TrustPacket(objStream));

            case PacketTag.UserId:
                return(new UserIdPacket(objStream));

            case PacketTag.UserAttribute:
                return(new UserAttributePacket(objStream));

            case PacketTag.PublicSubkey:
                return(new PublicSubkeyPacket(objStream));

            case PacketTag.SymmetricEncryptedIntegrityProtected:
                return(new SymmetricEncIntegrityPacket(objStream));

            case PacketTag.ModificationDetectionCode:
                return(new ModDetectionCodePacket(objStream));

            case PacketTag.Experimental1:
            case PacketTag.Experimental2:
            case PacketTag.Experimental3:
            case PacketTag.Experimental4:
                return(new ExperimentalPacket(tag, objStream));

            default:
                throw new IOException("unknown packet type encountered: " + tag);
            }
        }
		/**
		* @param in
		*/
		public DsaSecretBcpgKey(
			BcpgInputStream bcpgIn)
		{
			this.x = new MPInteger(bcpgIn);
		}
 /// <param name="bcpgIn">The stream to read the packet from.</param>
 protected ECPublicBcpgKey(
     BcpgInputStream bcpgIn)
 {
     this.oid = DerObjectIdentifier.GetInstance(Asn1Object.FromByteArray(ReadBytesOfEncodedLength(bcpgIn)));
     this.point = new MPInteger(bcpgIn).Value;
 }
Esempio n. 31
0
 internal PartialInputStream(BcpgInputStream bcpgIn, bool partial, int dataLength)
 {
     this.m_in       = bcpgIn;
     this.partial    = partial;
     this.dataLength = dataLength;
 }
Esempio n. 32
0
        public Packet ReadPacket()
        {
            //IL_001b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0150: Unknown result type (might be due to invalid IL or missing references)
            //IL_0298: Unknown result type (might be due to invalid IL or missing references)
            int num = ((Stream)this).ReadByte();

            if (num < 0)
            {
                return(null);
            }
            if ((num & 0x80) == 0)
            {
                throw new IOException("invalid header encountered");
            }
            bool      flag      = (num & 0x40) != 0;
            PacketTag packetTag = PacketTag.Reserved;
            int       num2      = 0;
            bool      flag2     = false;

            if (flag)
            {
                packetTag = (PacketTag)(num & 0x3F);
                int num3 = ((Stream)this).ReadByte();
                if (num3 < 192)
                {
                    num2 = num3;
                }
                else if (num3 <= 223)
                {
                    int num4 = m_in.ReadByte();
                    num2 = (num3 - 192 << 8) + num4 + 192;
                }
                else if (num3 == 255)
                {
                    num2 = (m_in.ReadByte() << 24) | (m_in.ReadByte() << 16) | (m_in.ReadByte() << 8) | m_in.ReadByte();
                }
                else
                {
                    flag2 = true;
                    num2  = 1 << (num3 & 0x1F);
                }
            }
            else
            {
                int num5 = num & 3;
                packetTag = (PacketTag)((num & 0x3F) >> 2);
                switch (num5)
                {
                case 0:
                    num2 = ((Stream)this).ReadByte();
                    break;

                case 1:
                    num2 = (((Stream)this).ReadByte() << 8) | ((Stream)this).ReadByte();
                    break;

                case 2:
                    num2 = (((Stream)this).ReadByte() << 24) | (((Stream)this).ReadByte() << 16) | (((Stream)this).ReadByte() << 8) | ((Stream)this).ReadByte();
                    break;

                case 3:
                    flag2 = true;
                    break;

                default:
                    throw new IOException("unknown length type encountered");
                }
            }
            BcpgInputStream bcpgIn;

            if (num2 == 0 && flag2)
            {
                bcpgIn = this;
            }
            else
            {
                PartialInputStream inputStream = new PartialInputStream(this, flag2, num2);
                bcpgIn = new BcpgInputStream((Stream)(object)inputStream);
            }
            switch (packetTag)
            {
            case PacketTag.Reserved:
                return(new InputStreamPacket(bcpgIn));

            case PacketTag.PublicKeyEncryptedSession:
                return(new PublicKeyEncSessionPacket(bcpgIn));

            case PacketTag.Signature:
                return(new SignaturePacket(bcpgIn));

            case PacketTag.SymmetricKeyEncryptedSessionKey:
                return(new SymmetricKeyEncSessionPacket(bcpgIn));

            case PacketTag.OnePassSignature:
                return(new OnePassSignaturePacket(bcpgIn));

            case PacketTag.SecretKey:
                return(new SecretKeyPacket(bcpgIn));

            case PacketTag.PublicKey:
                return(new PublicKeyPacket(bcpgIn));

            case PacketTag.SecretSubkey:
                return(new SecretSubkeyPacket(bcpgIn));

            case PacketTag.CompressedData:
                return(new CompressedDataPacket(bcpgIn));

            case PacketTag.SymmetricKeyEncrypted:
                return(new SymmetricEncDataPacket(bcpgIn));

            case PacketTag.Marker:
                return(new MarkerPacket(bcpgIn));

            case PacketTag.LiteralData:
                return(new LiteralDataPacket(bcpgIn));

            case PacketTag.Trust:
                return(new TrustPacket(bcpgIn));

            case PacketTag.UserId:
                return(new UserIdPacket(bcpgIn));

            case PacketTag.UserAttribute:
                return(new UserAttributePacket(bcpgIn));

            case PacketTag.PublicSubkey:
                return(new PublicSubkeyPacket(bcpgIn));

            case PacketTag.SymmetricEncryptedIntegrityProtected:
                return(new SymmetricEncIntegrityPacket(bcpgIn));

            case PacketTag.ModificationDetectionCode:
                return(new ModDetectionCodePacket(bcpgIn));

            case PacketTag.Experimental1:
            case PacketTag.Experimental2:
            case PacketTag.Experimental3:
            case PacketTag.Experimental4:
                return(new ExperimentalPacket(packetTag, bcpgIn));

            default:
                throw new IOException(string.Concat((object)"unknown packet type encountered: ", (object)packetTag));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ECDHPublicBcpgKey"/> class.
 /// </summary>
 /// <param name="bcpgIn">The BCPG in.</param>
 /// <exception cref="Org.BouncyCastle.Bcpg.OpenPgp.PgpException">kdf parameter size of 3 expected.</exception>
 public ECDHPublicBcpgKey(BcpgInputStream bcpgIn)
     : this(bcpgIn, null)
 {
 }
Esempio n. 34
0
        internal SignaturePacket(BcpgInputStream bcpgIn)
        {
            this.version = bcpgIn.ReadByte();
            if (this.version == 3 || this.version == 2)
            {
                bcpgIn.ReadByte();
                this.signatureType = bcpgIn.ReadByte();
                this.creationTime  = ((long)bcpgIn.ReadByte() << 24 | (long)bcpgIn.ReadByte() << 16 | (long)bcpgIn.ReadByte() << 8 | (long)((ulong)bcpgIn.ReadByte())) * 1000L;
                this.keyId        |= (long)bcpgIn.ReadByte() << 56;
                this.keyId        |= (long)bcpgIn.ReadByte() << 48;
                this.keyId        |= (long)bcpgIn.ReadByte() << 40;
                this.keyId        |= (long)bcpgIn.ReadByte() << 32;
                this.keyId        |= (long)bcpgIn.ReadByte() << 24;
                this.keyId        |= (long)bcpgIn.ReadByte() << 16;
                this.keyId        |= (long)bcpgIn.ReadByte() << 8;
                this.keyId        |= (long)((ulong)bcpgIn.ReadByte());
                this.keyAlgorithm  = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();
                this.hashAlgorithm = (HashAlgorithmTag)bcpgIn.ReadByte();
            }
            else
            {
                if (this.version != 4)
                {
                    throw new Exception("unsupported version: " + this.version);
                }
                this.signatureType = bcpgIn.ReadByte();
                this.keyAlgorithm  = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();
                this.hashAlgorithm = (HashAlgorithmTag)bcpgIn.ReadByte();
                int    num    = bcpgIn.ReadByte() << 8 | bcpgIn.ReadByte();
                byte[] buffer = new byte[num];
                bcpgIn.ReadFully(buffer);
                SignatureSubpacketsParser signatureSubpacketsParser = new SignatureSubpacketsParser(new MemoryStream(buffer, false));
                IList list = Platform.CreateArrayList();
                SignatureSubpacket value;
                while ((value = signatureSubpacketsParser.ReadPacket()) != null)
                {
                    list.Add(value);
                }
                this.hashedData = new SignatureSubpacket[list.Count];
                for (int num2 = 0; num2 != this.hashedData.Length; num2++)
                {
                    SignatureSubpacket signatureSubpacket = (SignatureSubpacket)list[num2];
                    if (signatureSubpacket is IssuerKeyId)
                    {
                        this.keyId = ((IssuerKeyId)signatureSubpacket).KeyId;
                    }
                    else if (signatureSubpacket is SignatureCreationTime)
                    {
                        this.creationTime = DateTimeUtilities.DateTimeToUnixMs(((SignatureCreationTime)signatureSubpacket).GetTime());
                    }
                    this.hashedData[num2] = signatureSubpacket;
                }
                int    num3    = bcpgIn.ReadByte() << 8 | bcpgIn.ReadByte();
                byte[] buffer2 = new byte[num3];
                bcpgIn.ReadFully(buffer2);
                signatureSubpacketsParser = new SignatureSubpacketsParser(new MemoryStream(buffer2, false));
                list.Clear();
                while ((value = signatureSubpacketsParser.ReadPacket()) != null)
                {
                    list.Add(value);
                }
                this.unhashedData = new SignatureSubpacket[list.Count];
                for (int num4 = 0; num4 != this.unhashedData.Length; num4++)
                {
                    SignatureSubpacket signatureSubpacket2 = (SignatureSubpacket)list[num4];
                    if (signatureSubpacket2 is IssuerKeyId)
                    {
                        this.keyId = ((IssuerKeyId)signatureSubpacket2).KeyId;
                    }
                    this.unhashedData[num4] = signatureSubpacket2;
                }
            }
            this.fingerprint = new byte[2];
            bcpgIn.ReadFully(this.fingerprint);
            PublicKeyAlgorithmTag publicKeyAlgorithmTag = this.keyAlgorithm;

            switch (publicKeyAlgorithmTag)
            {
            case PublicKeyAlgorithmTag.RsaGeneral:
            case PublicKeyAlgorithmTag.RsaSign:
            {
                MPInteger mPInteger = new MPInteger(bcpgIn);
                this.signature = new MPInteger[]
                {
                    mPInteger
                };
                return;
            }

            case PublicKeyAlgorithmTag.RsaEncrypt:
                break;

            default:
                switch (publicKeyAlgorithmTag)
                {
                case PublicKeyAlgorithmTag.ElGamalEncrypt:
                case PublicKeyAlgorithmTag.ElGamalGeneral:
                {
                    MPInteger mPInteger2 = new MPInteger(bcpgIn);
                    MPInteger mPInteger3 = new MPInteger(bcpgIn);
                    MPInteger mPInteger4 = new MPInteger(bcpgIn);
                    this.signature = new MPInteger[]
                    {
                        mPInteger2,
                        mPInteger3,
                        mPInteger4
                    };
                    return;
                }

                case PublicKeyAlgorithmTag.Dsa:
                {
                    MPInteger mPInteger5 = new MPInteger(bcpgIn);
                    MPInteger mPInteger6 = new MPInteger(bcpgIn);
                    this.signature = new MPInteger[]
                    {
                        mPInteger5,
                        mPInteger6
                    };
                    return;
                }
                }
                break;
            }
            if (this.keyAlgorithm >= PublicKeyAlgorithmTag.Experimental_1 && this.keyAlgorithm <= PublicKeyAlgorithmTag.Experimental_11)
            {
                this.signature = null;
                MemoryStream memoryStream = new MemoryStream();
                int          num5;
                while ((num5 = bcpgIn.ReadByte()) >= 0)
                {
                    memoryStream.WriteByte((byte)num5);
                }
                this.signatureEncoding = memoryStream.ToArray();
                return;
            }
            throw new IOException("unknown signature key algorithm: " + this.keyAlgorithm);
        }
Esempio n. 35
0
 public UserIdPacket(
     BcpgInputStream bcpgIn)
 {
     this.idData = bcpgIn.ReadAll();
 }
Esempio n. 36
0
 public MarkerPacket(BcpgInputStream bcpgIn)
 {
     bcpgIn.ReadFully(this.marker);
 }
 public ECSecretBcpgKey(BcpgInputStream bcpgIn)
 {
     _x = new MPInteger(bcpgIn);
 }
Esempio n. 38
0
 /// <summary>Construct an RSA public key from the passed in stream.</summary>
 public RsaPublicBcpgKey(
     BcpgInputStream bcpgIn)
 {
     this.n = new MPInteger(bcpgIn);
     this.e = new MPInteger(bcpgIn);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ECPublicBcpgKey"/> class.
 /// </summary>
 /// <param name="bcpgIn">The BCPG in.</param>
 /// <param name="oid">The OID.</param>
 protected ECPublicBcpgKey(BcpgInputStream bcpgIn, DerObjectIdentifier oid)
 {
     _oid   = oid ?? new DerObjectIdentifier(this.ReadBytesOfEncodedLength(bcpgIn));
     _point = DecodePoint(new MPInteger(bcpgIn).Value, _oid);
 }
Esempio n. 40
0
 public UserIdPacket(
     BcpgInputStream bcpgIn)
 {
     this.idData = bcpgIn.ReadAll();
 }
 public SymmetricEncDataPacket(
     BcpgInputStream bcpgIn)
     : base(bcpgIn)
 {
 }
Esempio n. 42
0
        internal SignaturePacket(
            BcpgInputStream bcpgIn)
        {
            version = bcpgIn.ReadByte();

            if (version == 3 || version == 2)
            {
//                int l =
                bcpgIn.ReadByte();

                signatureType = bcpgIn.ReadByte();
                creationTime  = (((long)bcpgIn.ReadByte() << 24) | ((long)bcpgIn.ReadByte() << 16)
                                 | ((long)bcpgIn.ReadByte() << 8) | (uint)bcpgIn.ReadByte()) * 1000L;

                keyId |= (long)bcpgIn.ReadByte() << 56;
                keyId |= (long)bcpgIn.ReadByte() << 48;
                keyId |= (long)bcpgIn.ReadByte() << 40;
                keyId |= (long)bcpgIn.ReadByte() << 32;
                keyId |= (long)bcpgIn.ReadByte() << 24;
                keyId |= (long)bcpgIn.ReadByte() << 16;
                keyId |= (long)bcpgIn.ReadByte() << 8;
                keyId |= (uint)bcpgIn.ReadByte();

                keyAlgorithm  = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();
                hashAlgorithm = (HashAlgorithmTag)bcpgIn.ReadByte();
            }
            else if (version == 4)
            {
                signatureType = bcpgIn.ReadByte();
                keyAlgorithm  = (PublicKeyAlgorithmTag)bcpgIn.ReadByte();
                hashAlgorithm = (HashAlgorithmTag)bcpgIn.ReadByte();

                int    hashedLength = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
                byte[] hashed       = new byte[hashedLength];

                bcpgIn.ReadFully(hashed);

                //
                // read the signature sub packet data.
                //
                SignatureSubpacketsParser sIn = new SignatureSubpacketsParser(
                    new MemoryStream(hashed, false));

                IList v = Platform.CreateArrayList();
                SignatureSubpacket sub;
                while ((sub = sIn.ReadPacket()) != null)
                {
                    v.Add(sub);
                }

                hashedData = new SignatureSubpacket[v.Count];

                for (int i = 0; i != hashedData.Length; i++)
                {
                    SignatureSubpacket p = (SignatureSubpacket)v[i];
                    if (p is IssuerKeyId)
                    {
                        keyId = ((IssuerKeyId)p).KeyId;
                    }
                    else if (p is SignatureCreationTime)
                    {
                        creationTime = DateTimeUtilities.DateTimeToUnixMs(
                            ((SignatureCreationTime)p).GetTime());
                    }

                    hashedData[i] = p;
                }

                int    unhashedLength = (bcpgIn.ReadByte() << 8) | bcpgIn.ReadByte();
                byte[] unhashed       = new byte[unhashedLength];

                bcpgIn.ReadFully(unhashed);

                sIn = new SignatureSubpacketsParser(new MemoryStream(unhashed, false));

                v.Clear();

                while ((sub = sIn.ReadPacket()) != null)
                {
                    v.Add(sub);
                }

                unhashedData = new SignatureSubpacket[v.Count];

                for (int i = 0; i != unhashedData.Length; i++)
                {
                    SignatureSubpacket p = (SignatureSubpacket)v[i];
                    if (p is IssuerKeyId)
                    {
                        keyId = ((IssuerKeyId)p).KeyId;
                    }

                    unhashedData[i] = p;
                }
            }
            else
            {
                throw new Exception("unsupported version: " + version);
            }

            fingerprint = new byte[2];
            bcpgIn.ReadFully(fingerprint);

            switch (keyAlgorithm)
            {
            case PublicKeyAlgorithmTag.RsaGeneral:
            case PublicKeyAlgorithmTag.RsaSign:
                MPInteger v = new MPInteger(bcpgIn);
                signature = new MPInteger[] { v };
                break;

            case PublicKeyAlgorithmTag.Dsa:
                MPInteger r = new MPInteger(bcpgIn);
                MPInteger s = new MPInteger(bcpgIn);
                signature = new MPInteger[] { r, s };
                break;

            case PublicKeyAlgorithmTag.ElGamalEncrypt:     // yep, this really does happen sometimes.
            case PublicKeyAlgorithmTag.ElGamalGeneral:
                MPInteger p = new MPInteger(bcpgIn);
                MPInteger g = new MPInteger(bcpgIn);
                MPInteger y = new MPInteger(bcpgIn);
                signature = new MPInteger[] { p, g, y };
                break;

            case PublicKeyAlgorithmTag.ECDsa:
                MPInteger ecR = new MPInteger(bcpgIn);
                MPInteger ecS = new MPInteger(bcpgIn);
                signature = new MPInteger[] { ecR, ecS };
                break;

            default:
                if (keyAlgorithm >= PublicKeyAlgorithmTag.Experimental_1 && keyAlgorithm <= PublicKeyAlgorithmTag.Experimental_11)
                {
                    signature = null;
                    MemoryStream bOut = new MemoryStream();
                    int          ch;
                    while ((ch = bcpgIn.ReadByte()) >= 0)
                    {
                        bOut.WriteByte((byte)ch);
                    }
                    signatureEncoding = bOut.ToArray();
                }
                else
                {
                    throw new IOException("unknown signature key algorithm: " + keyAlgorithm);
                }
                break;
            }
        }
Esempio n. 43
0
        public Packet ReadPacket()
        {
            int num = this.ReadByte();

            if (num < 0)
            {
                return(null);
            }
            if ((num & 128) == 0)
            {
                throw new IOException("invalid header encountered");
            }
            bool      flag  = (num & 64) != 0;
            int       num2  = 0;
            bool      flag2 = false;
            PacketTag packetTag;

            if (flag)
            {
                packetTag = (PacketTag)(num & 63);
                int num3 = this.ReadByte();
                if (num3 < 192)
                {
                    num2 = num3;
                }
                else if (num3 <= 223)
                {
                    int num4 = this.m_in.ReadByte();
                    num2 = (num3 - 192 << 8) + num4 + 192;
                }
                else if (num3 == 255)
                {
                    num2 = (this.m_in.ReadByte() << 24 | this.m_in.ReadByte() << 16 | this.m_in.ReadByte() << 8 | this.m_in.ReadByte());
                }
                else
                {
                    flag2 = true;
                    num2  = 1 << num3;
                }
            }
            else
            {
                int num5 = num & 3;
                packetTag = (PacketTag)((num & 63) >> 2);
                switch (num5)
                {
                case 0:
                    num2 = this.ReadByte();
                    break;

                case 1:
                    num2 = (this.ReadByte() << 8 | this.ReadByte());
                    break;

                case 2:
                    num2 = (this.ReadByte() << 24 | this.ReadByte() << 16 | this.ReadByte() << 8 | this.ReadByte());
                    break;

                case 3:
                    flag2 = true;
                    break;

                default:
                    throw new IOException("unknown length type encountered");
                }
            }
            BcpgInputStream bcpgIn;

            if (num2 == 0 && flag2)
            {
                bcpgIn = this;
            }
            else
            {
                BcpgInputStream.PartialInputStream inputStream = new BcpgInputStream.PartialInputStream(this, flag2, num2);
                bcpgIn = new BcpgInputStream(inputStream);
            }
            PacketTag packetTag2 = packetTag;

            switch (packetTag2)
            {
            case PacketTag.Reserved:
                return(new InputStreamPacket(bcpgIn));

            case PacketTag.PublicKeyEncryptedSession:
                return(new PublicKeyEncSessionPacket(bcpgIn));

            case PacketTag.Signature:
                return(new SignaturePacket(bcpgIn));

            case PacketTag.SymmetricKeyEncryptedSessionKey:
                return(new SymmetricKeyEncSessionPacket(bcpgIn));

            case PacketTag.OnePassSignature:
                return(new OnePassSignaturePacket(bcpgIn));

            case PacketTag.SecretKey:
                return(new SecretKeyPacket(bcpgIn));

            case PacketTag.PublicKey:
                return(new PublicKeyPacket(bcpgIn));

            case PacketTag.SecretSubkey:
                return(new SecretSubkeyPacket(bcpgIn));

            case PacketTag.CompressedData:
                return(new CompressedDataPacket(bcpgIn));

            case PacketTag.SymmetricKeyEncrypted:
                return(new SymmetricEncDataPacket(bcpgIn));

            case PacketTag.Marker:
                return(new MarkerPacket(bcpgIn));

            case PacketTag.LiteralData:
                return(new LiteralDataPacket(bcpgIn));

            case PacketTag.Trust:
                return(new TrustPacket(bcpgIn));

            case PacketTag.UserId:
                return(new UserIdPacket(bcpgIn));

            case PacketTag.PublicSubkey:
                return(new PublicSubkeyPacket(bcpgIn));

            case (PacketTag)15:
            case (PacketTag)16:
                break;

            case PacketTag.UserAttribute:
                return(new UserAttributePacket(bcpgIn));

            case PacketTag.SymmetricEncryptedIntegrityProtected:
                return(new SymmetricEncIntegrityPacket(bcpgIn));

            case PacketTag.ModificationDetectionCode:
                return(new ModDetectionCodePacket(bcpgIn));

            default:
                switch (packetTag2)
                {
                case PacketTag.Experimental1:
                case PacketTag.Experimental2:
                case PacketTag.Experimental3:
                case PacketTag.Experimental4:
                    return(new ExperimentalPacket(packetTag, bcpgIn));
                }
                break;
            }
            throw new IOException("unknown packet type encountered: " + packetTag);
        }
Esempio n. 44
0
 internal SecretSubkeyPacket(
     BcpgInputStream bcpgIn)
     : base(bcpgIn)
 {
 }
 internal PartialInputStream(
     BcpgInputStream	bcpgIn,
     bool			partial,
     int				dataLength)
 {
     this.m_in = bcpgIn;
     this.partial = partial;
     this.dataLength = dataLength;
 }
Esempio n. 46
0
 internal ExperimentalPacket(PacketTag tag, BcpgInputStream bcpgIn)
 {
     this.tag = tag;
     contents = bcpgIn.ReadAll();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ECDSAPublicBcpgKey"/> class.
 /// </summary>
 /// <param name="bcpgIn">The BCPG in.</param>
 public ECDSAPublicBcpgKey(BcpgInputStream bcpgIn)
     : base(bcpgIn, null)
 {
 }
Esempio n. 48
0
 /**
  * @param in
  */
 public DsaSecretBcpgKey(
     BcpgInputStream bcpgIn)
 {
     this.x = new MPInteger(bcpgIn);
 }
Esempio n. 49
0
 internal CompressedDataPacket(BcpgInputStream bcpgIn)
     : base(bcpgIn)
 {
     algorithm = (CompressionAlgorithmTag)((Stream)bcpgIn).ReadByte();
 }
Esempio n. 50
0
 public RsaPublicBcpgKey(BcpgInputStream bcpgIn)
 {
     n = new MPInteger(bcpgIn);
     e = new MPInteger(bcpgIn);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ElGamalSecretBcpgKey"/> class.
 /// </summary>
 /// <param name="bcpgIn">The BCPG in.</param>
 public ElGamalSecretBcpgKey(BcpgInputStream bcpgIn)
 {
     _x = new MPInteger(bcpgIn);
 }
Esempio n. 52
0
 internal PublicSubkeyPacket(
     BcpgInputStream bcpgIn)
     : base(bcpgIn)
 {
 }