Example #1
0
        public byte[] GetEncodedContents()
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.Write(pubKeyPacket.GetEncodedContents());

            pOut.WriteByte((byte)s2kUsage);

            if (s2kUsage == UsageChecksum || s2kUsage == UsageSha1)
            {
                pOut.WriteByte((byte)encAlgorithm);
                pOut.WriteObject(s2k);
            }

            if (iv != null)
            {
                pOut.Write(iv);
            }

            if (secKeyData != null && secKeyData.Length > 0)
            {
                pOut.Write(secKeyData);
            }

            return(bOut.ToArray());
        }
Example #2
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            bcpgOut.WriteByte((byte)type);
            bcpgOut.WriteByte((byte)algorithm);

            if (type != GnuDummyS2K)
            {
                if (type != 0)
                {
                    bcpgOut.Write(iv);
                }

                if (type == 3)
                {
                    bcpgOut.WriteByte((byte)itCount);
                }
            }
            else
            {
                bcpgOut.WriteByte((byte)'G');
                bcpgOut.WriteByte((byte)'N');
                bcpgOut.WriteByte((byte)'U');
                bcpgOut.WriteByte((byte)protectionMode);
            }
        }
Example #3
0
        public byte[] GetEncodedContents()
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);
            pOut.WriteInt((int)time);

            if (version <= 3)
            {
                pOut.WriteShort((short)validDays);
            }

            pOut.WriteByte((byte)algorithm);

            pOut.WriteObject((BcpgObject)key);

            return(bOut.ToArray());
        }
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);

            pOut.WriteLong(keyId);

            pOut.WriteByte((byte)algorithm);

            for (int i = 0; i != data.Length; i++)
            {
                MPInteger.Encode(pOut, data[i]);
            }

            bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, bOut.ToArray(), true);
        }
Example #5
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);

            if (version == 3 || version == 2)
            {
                pOut.Write(
                    5,                     // the length of the next block
                    (byte)signatureType);

                pOut.WriteInt((int)(creationTime / 1000L));

                pOut.WriteLong(keyId);

                pOut.Write(
                    (byte)keyAlgorithm,
                    (byte)hashAlgorithm);
            }
            else if (version == 4)
            {
                pOut.Write(
                    (byte)signatureType,
                    (byte)keyAlgorithm,
                    (byte)hashAlgorithm);

                EncodeLengthAndData(pOut, GetEncodedSubpackets(hashedData));

                EncodeLengthAndData(pOut, GetEncodedSubpackets(unhashedData));
            }
            else
            {
                throw new IOException("unknown version: " + version);
            }

            pOut.Write(fingerprint);

            if (signature != null)
            {
                pOut.WriteObjects(signature);
            }
            else
            {
                pOut.Write(signatureEncoding);
            }

            bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
        }
Example #6
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.Write(
                (byte)version,
                (byte)sigType,
                (byte)hashAlgorithm,
                (byte)keyAlgorithm);

            pOut.WriteLong(keyId);

            pOut.WriteByte((byte)nested);

            bcpgOut.WritePacket(PacketTag.OnePassSignature, bOut.ToArray(), true);
        }
		public override void Encode(
			BcpgOutputStream bcpgOut)
		{
			MemoryStream bOut = new MemoryStream();
			BcpgOutputStream pOut = new BcpgOutputStream(bOut);

			pOut.WriteByte((byte) version);

			pOut.WriteLong(keyId);

			pOut.WriteByte((byte)algorithm);

			for (int i = 0; i != data.Length; i++)
			{
				MPInteger.Encode(pOut, data[i]);
			}

			bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession , bOut.ToArray(), true);
		}
		public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

			pOut.WriteByte((byte) version);

			if (version == 3 || version == 2)
            {
				pOut.Write(
					5, // the length of the next block
					(byte) signatureType);

				pOut.WriteInt((int)(creationTime / 1000L));

				pOut.WriteLong(keyId);

				pOut.Write(
					(byte) keyAlgorithm,
					(byte) hashAlgorithm);
            }
            else if (version == 4)
            {
                pOut.Write(
					(byte) signatureType,
					(byte) keyAlgorithm,
					(byte) hashAlgorithm);

				EncodeLengthAndData(pOut, GetEncodedSubpackets(hashedData));

				EncodeLengthAndData(pOut, GetEncodedSubpackets(unhashedData));
            }
            else
            {
                throw new IOException("unknown version: " + version);
            }

			pOut.Write(fingerprint);

			if (signature != null)
			{
				pOut.WriteObjects(signature);
			}
			else
			{
				pOut.Write(signatureEncoding);
			}

			bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
        }
		public override void Encode(
			BcpgOutputStream bcpgOut)
		{
			MemoryStream bOut = new MemoryStream();
			BcpgOutputStream pOut = new BcpgOutputStream(bOut);

			pOut.Write(
				(byte) version,
				(byte) sigType,
				(byte) hashAlgorithm,
				(byte) keyAlgorithm);

			pOut.WriteLong(keyId);

			pOut.WriteByte((byte) nested);

			bcpgOut.WritePacket(PacketTag.OnePassSignature, bOut.ToArray(), true);
		}
		public byte[] GetEncodedContents()
        {
            MemoryStream bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.Write(pubKeyPacket.GetEncodedContents());

			pOut.WriteByte((byte) s2kUsage);

			if (s2kUsage == UsageChecksum || s2kUsage == UsageSha1)
            {
                pOut.WriteByte((byte) encAlgorithm);
                pOut.WriteObject(s2k);
            }

			if (iv != null)
            {
                pOut.Write(iv);
            }

            if (secKeyData != null && secKeyData.Length > 0)
            {
                pOut.Write(secKeyData);
            }

            return bOut.ToArray();
        }
Example #11
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            bcpgOut.WriteByte((byte) type);
            bcpgOut.WriteByte((byte) algorithm);

            if (type != GnuDummyS2K)
            {
                if (type != 0)
                {
                    bcpgOut.Write(iv);
                }

                if (type == 3)
                {
                    bcpgOut.WriteByte((byte) itCount);
                }
            }
            else
            {
                bcpgOut.WriteByte((byte) 'G');
                bcpgOut.WriteByte((byte) 'N');
                bcpgOut.WriteByte((byte) 'U');
                bcpgOut.WriteByte((byte) protectionMode);
            }
        }
        public byte[] GetEncodedContents()
        {
            MemoryStream bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte) version);
            pOut.WriteInt((int) time);

			if (version <= 3)
            {
                pOut.WriteShort((short) validDays);
            }

			pOut.WriteByte((byte) algorithm);

			pOut.WriteObject((BcpgObject)key);

			return bOut.ToArray();
        }