public override void Encode(IBcpgOutputStream pOut)
            {
                var pk = new SymmetricKeyEncSessionPacket(
                    EncAlgorithm, _s2K, SessionInfo);

                pOut.WritePacket(pk);
            }
        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);
                }
            }
        }
Пример #3
0
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                for (var i = 0; i != _subpackets.Length; i++)
                {
                    _subpackets[i].Encode(bOut);
                }

                bcpgOut.WritePacket(PacketTag.UserAttribute, bOut.ToArray(), false);
            }
        }
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {

                for (var i = 0; i != _subpackets.Length; i++)
                {
                    _subpackets[i].Encode(bOut);
                }

                bcpgOut.WritePacket(PacketTag.UserAttribute, bOut.ToArray(), false);
            }
        }
        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(
            IBcpgOutputStream bcpgOut)
        {
            using (MemoryStream bOut = new MemoryStream())
            {
                using (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);
                }
            }
        }
        /// <summary>
        /// Encodes this instance to the given stream.
        /// </summary>
        /// <param name="bcpgOut">The BCPG out.</param>
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {
                    pOut.Write(
                        (byte)Version,
                        (byte)EncAlgorithm);

                    pOut.WriteObject(S2K);

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

                    bcpgOut.WritePacket(PacketTag.SymmetricKeyEncryptedSessionKey, bOut.ToArray(), true);
                }
            }
        }
 public override void Encode(IBcpgOutputStream pOut)
 {
     var pk = new PublicKeyEncSessionPacket(_pubKey.KeyId, _pubKey.Algorithm, _data, _extraData);
     pOut.WritePacket(pk);
 }
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.Trust, _levelAndTrustAmount, true);
 }
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.PublicSubkey, GetEncodedContents(), true);
 }
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.UserId, _idData, true);
 }
Пример #12
0
 public override void Encode(
     IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.ModificationDetectionCode, digest, false);
 }
 /// <summary>
 /// Encodes this instance to the given stream.
 /// </summary>
 /// <param name="bcpgOut">The BCPG out.</param>
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.SecretSubkey, GetEncodedContents(), true);
 }
Пример #14
0
 /// <summary>
 /// Encodes this instance to the given stream.
 /// </summary>
 /// <param name="bcpgOut">The BCPG out.</param>
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.SecretKey, this.GetEncodedContents(), true);
 }
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(_tag, _contents, true);
 }
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(_tag, _contents, true);
 }
Пример #17
0
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.Trust, _levelAndTrustAmount, true);
 }
 public override void Encode(
     IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.Marker, marker, true);
 }
            public override void Encode(IBcpgOutputStream pOut)
            {
                var pk = new SymmetricKeyEncSessionPacket(
                    EncAlgorithm, _s2K, SessionInfo);

                pOut.WritePacket(pk);
            }
        public override void Encode(
	        IBcpgOutputStream bcpgOut)
        {
            using (MemoryStream bOut = new MemoryStream())
            {
                using (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);

                    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(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);
                }
            }
        }
        /// <summary>
        /// Encodes this instance to the given stream.
        /// </summary>
        /// <param name="bcpgOut">The BCPG out.</param>
        public override void Encode(IBcpgOutputStream bcpgOut)
        {
            using (var bOut = new MemoryStream())
            {
                using (var pOut = new BcpgOutputStream(bOut))
                {

                    pOut.Write(
                        (byte)Version,
                        (byte)EncAlgorithm);

                    pOut.WriteObject(S2K);

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

                    bcpgOut.WritePacket(PacketTag.SymmetricKeyEncryptedSessionKey, bOut.ToArray(), true);
                }
            }
        }
            public override void Encode(IBcpgOutputStream pOut)
            {
                var pk = new PublicKeyEncSessionPacket(_pubKey.KeyId, _pubKey.Algorithm, _data, _extraData);

                pOut.WritePacket(pk);
            }
 public override void Encode(
     IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.ModificationDetectionCode, digest, false);
 }
Пример #26
0
 public override void Encode(IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.UserId, _idData, true);
 }
Пример #27
0
 public override void Encode(
     IBcpgOutputStream bcpgOut)
 {
     bcpgOut.WritePacket(PacketTag.Marker, marker, true);
 }