WriteByte() public method

public WriteByte ( byte value ) : void
value byte
return void
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());
        }
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.WriteByte((byte)_version);

                    pOut.WriteLong(_keyId);

                    pOut.WriteByte((byte)_algorithm);

                    for (var i = 0; i != _data.Length; i++)
                    {
                        MPInteger.EncodeInteger(pOut, _data[i]);
                    }

                    if (_extraData != null)
                    {
                        if (_extraData.Length > 0xFF)
                        {
                            throw new PgpException("Extra Data is too large.");
                        }
                        pOut.WriteByte((byte)_extraData.Length);
                        pOut.Write(_extraData, 0, _extraData.Length);
                    }

                    bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, bOut.ToArray(), true);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Gets the encoded contents.
        /// </summary>
        /// <returns></returns>
        public byte[] GetEncodedContents()
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.Write(PublicKeyPacket.GetEncodedContents());
                    pOut.WriteByte((byte)this.S2KUsage);

                    if (this.S2KUsage == UsageChecksum || this.S2KUsage == UsageSha1)
                    {
                        pOut.WriteByte((byte)this.EncAlgorithm);
                        pOut.WriteObject(this.S2K);
                    }

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

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

                    return(bOut.ToArray());
                }
            }
        }
 public override void Encode(
     BcpgOutputStream bcpgOut)
 {
     base.Encode(bcpgOut);
     bcpgOut.WriteByte(0x3);
     bcpgOut.WriteByte(reserved);
     bcpgOut.WriteByte(hashFunctionId);
     bcpgOut.WriteByte(symAlgorithmId);
 }
 public override void Encode(
     BcpgOutputStream bcpgOut)
 {
     base.Encode(bcpgOut);
     bcpgOut.WriteByte(0x3);
     bcpgOut.WriteByte(reserved);
     bcpgOut.WriteByte(hashFunctionId);
     bcpgOut.WriteByte(symAlgorithmId);
 }
Example #6
0
        public override void Encode(BcpgOutputStream bcpgOut)
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.WriteByte((byte)this.version);
            bcpgOutputStream.WriteLong(this.keyId);
            bcpgOutputStream.WriteByte((byte)this.algorithm);
            for (int num = 0; num != this.data.Length; num++)
            {
                MPInteger.Encode(bcpgOutputStream, this.data[num]);
            }
            bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, memoryStream.ToArray(), true);
        }
        public virtual byte[] GetEncodedContents()
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.WriteByte((byte)this.version);
            bcpgOutputStream.WriteInt((int)this.time);
            if (this.version <= 3)
            {
                bcpgOutputStream.WriteShort((short)this.validDays);
            }
            bcpgOutputStream.WriteByte((byte)this.algorithm);
            bcpgOutputStream.WriteObject((BcpgObject)this.key);
            return(memoryStream.ToArray());
        }
Example #8
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 #9
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 #11
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            int length = val.BitLength;

            bcpgOut.WriteByte((byte) (length >> 8));
            bcpgOut.WriteByte((byte) length);

            byte[] bytes = val.ToByteArray();

            if (bytes[0] == 0)
            {
                bcpgOut.Write(bytes, 1, bytes.Length - 1);
            }
            else
            {
                bcpgOut.Write(bytes);
            }
        }
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            int length = val.BitLength;

            bcpgOut.WriteByte((byte)(length >> 8));
            bcpgOut.WriteByte((byte)length);

            byte[] bytes = val.ToByteArray();

            if (bytes[0] == 0)
            {
                bcpgOut.Write(bytes, 1, bytes.Length - 1);
            }
            else
            {
                bcpgOut.Write(bytes);
            }
        }
        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)
            {
                pOut.Write(data[i]);
            }

            Platform.Dispose(pOut);

            bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, bOut.ToArray(), true);
        }
        /// <summary>
        /// Gets the encoded contents.
        /// </summary>
        /// <returns></returns>
        public byte[] GetEncodedContents()
        {
            using (var bOut = new MemoryStream())
            {
                using (var 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 byte[] GetEncodedContents()
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.Write(this.pubKeyPacket.GetEncodedContents());
            bcpgOutputStream.WriteByte((byte)this.s2kUsage);
            if (this.s2kUsage == 255 || this.s2kUsage == 254)
            {
                bcpgOutputStream.WriteByte((byte)this.encAlgorithm);
                bcpgOutputStream.WriteObject(this.s2k);
            }
            if (this.iv != null)
            {
                bcpgOutputStream.Write(this.iv);
            }
            if (this.secKeyData != null && this.secKeyData.Length > 0)
            {
                bcpgOutputStream.Write(this.secKeyData);
            }
            return(memoryStream.ToArray());
        }
Example #16
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);
        }
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.WriteByte((byte)_version);

                    switch (_version)
                    {
                    case 2:
                    case 3:
                        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);
                        break;

                    case 4:
                        pOut.Write(
                            (byte)_signatureType,
                            (byte)_keyAlgorithm,
                            (byte)_hashAlgorithm);
                        EncodeLengthAndData(pOut, GetEncodedSubpackets(_hashedData));
                        EncodeLengthAndData(pOut, GetEncodedSubpackets(_unhashedData));
                        break;

                    default:
                        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 #18
0
        public override void Encode(BcpgOutputStream bcpgOut)
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.Write(new byte[]
            {
                (byte)this.version,
                (byte)this.sigType,
                (byte)this.hashAlgorithm,
                (byte)this.keyAlgorithm
            });
            bcpgOutputStream.WriteLong(this.keyId);
            bcpgOutputStream.WriteByte((byte)this.nested);
            bcpgOut.WritePacket(PacketTag.OnePassSignature, memoryStream.ToArray(), true);
        }
        public override void Encode(BcpgOutputStream bcpgOut)
        {
            MemoryStream     memoryStream     = new MemoryStream();
            BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

            bcpgOutputStream.WriteByte((byte)this.version);
            if (this.version == 3 || this.version == 2)
            {
                bcpgOutputStream.Write(new byte[]
                {
                    5,
                    (byte)this.signatureType
                });
                bcpgOutputStream.WriteInt((int)(this.creationTime / 1000L));
                bcpgOutputStream.WriteLong(this.keyId);
                bcpgOutputStream.Write(new byte[]
                {
                    (byte)this.keyAlgorithm,
                    (byte)this.hashAlgorithm
                });
            }
            else
            {
                if (this.version != 4)
                {
                    throw new IOException("unknown version: " + this.version);
                }
                bcpgOutputStream.Write(new byte[]
                {
                    (byte)this.signatureType,
                    (byte)this.keyAlgorithm,
                    (byte)this.hashAlgorithm
                });
                SignaturePacket.EncodeLengthAndData(bcpgOutputStream, SignaturePacket.GetEncodedSubpackets(this.hashedData));
                SignaturePacket.EncodeLengthAndData(bcpgOutputStream, SignaturePacket.GetEncodedSubpackets(this.unhashedData));
            }
            bcpgOutputStream.Write(this.fingerprint);
            if (this.signature != null)
            {
                bcpgOutputStream.WriteObjects(this.signature);
            }
            else
            {
                bcpgOutputStream.Write(this.signatureEncoding);
            }
            bcpgOut.WritePacket(PacketTag.Signature, memoryStream.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);
        }
Example #21
0
 public override void Encode(BcpgOutputStream bcpgOut)
 {
     bcpgOut.WriteByte((byte)this.type);
     bcpgOut.WriteByte((byte)this.algorithm);
     if (this.type != 101)
     {
         if (this.type != 0)
         {
             bcpgOut.Write(this.iv);
         }
         if (this.type == 3)
         {
             bcpgOut.WriteByte((byte)this.itCount);
             return;
         }
     }
     else
     {
         bcpgOut.WriteByte(71);
         bcpgOut.WriteByte(78);
         bcpgOut.WriteByte(85);
         bcpgOut.WriteByte((byte)this.protectionMode);
     }
 }
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {

                    pOut.WriteByte((byte)_version);

                    switch (_version)
                    {
                        case 2:
                        case 3:
                            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);
                            break;
                        case 4:
                            pOut.Write(
                                (byte)_signatureType,
                                (byte)_keyAlgorithm,
                                (byte)_hashAlgorithm);
                            EncodeLengthAndData(pOut, GetEncodedSubpackets(_hashedData));
                            EncodeLengthAndData(pOut, GetEncodedSubpackets(_unhashedData));
                            break;
                        default:
                            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.WriteByte((byte) version);

			pOut.WriteLong(keyId);

			pOut.WriteByte((byte)algorithm);

            for (int i = 0; i < data.Length; ++i)
            {
                pOut.Write(data[i]);
            }

            Platform.Dispose(pOut);

            bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession , 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 override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {

                    pOut.WriteByte((byte)_version);

                    pOut.WriteLong(_keyId);

                    pOut.WriteByte((byte)_algorithm);

                    for (var i = 0; i != _data.Length; i++)
                    {
                        MPInteger.EncodeInteger(pOut, _data[i]);
                    }

                    if (_extraData != null)
                    {
                        if (_extraData.Length > 0xFF)
                            throw new PgpException("Extra Data is too large.");
                        pOut.WriteByte((byte)_extraData.Length);
                        pOut.Write(_extraData, 0, _extraData.Length);
                    }

                    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);

            pOut.WriteLong(keyId);

            pOut.WriteByte((byte)algorithm);

            for (int i = 0; i != data.Length; i++)
            {
                pOut.WriteObject(new MPInteger(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);
        }
Example #28
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();
        }
        /// <summary>
        /// Gets the encoded contents.
        /// </summary>
        /// <returns></returns>
        public byte[] GetEncodedContents()
        {
            using (var bOut = new MemoryStream())
            {
                using (var 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();
                }
            }
        }
Example #30
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 #31
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();
        }
        /// <summary>
        /// Gets the encoded contents.
        /// </summary>
        /// <returns></returns>
        public byte[] GetEncodedContents()
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.Write(PublicKeyPacket.GetEncodedContents());
                    pOut.WriteByte((byte) this.S2KUsage);

                    if (this.S2KUsage == UsageChecksum || this.S2KUsage == UsageSha1)
                    {
                        pOut.WriteByte((byte)this.EncAlgorithm);
                        pOut.WriteObject(this.S2K);
                    }

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

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

                    return bOut.ToArray();
                }
            }
        }