Esempio n. 1
0
 public (StreamablePacket Packet, Stream Stream) ReadStreamablePacket()
 {
     if (innerReader.NextPacketTag() == PacketTag.LiteralData)
     {
         // TODO: Version 5 signatures
         var literalDataPacket = innerReader.ReadStreamablePacket();
         literalDataRead = true;
         return(literalDataPacket.Packet, new CryptoStream(literalDataPacket.Stream, hashTransform, CryptoStreamMode.Read));
     }
     return(innerReader.ReadStreamablePacket());
 }
Esempio n. 2
0
        internal PgpEncryptedMessage(IPacketReader packetReader)
        {
            this.packetReader = packetReader;
            this.publicKeyEncSessionPackets    = new List <PublicKeyEncSessionPacket>();
            this.symmetricKeyEncSessionPackets = new List <SymmetricKeyEncSessionPacket>();

            while (packetReader.NextPacketTag() == PacketTag.PublicKeyEncryptedSession ||
                   packetReader.NextPacketTag() == PacketTag.SymmetricKeyEncryptedSessionKey)
            {
                var keyPacket = packetReader.ReadContainedPacket();
                if (keyPacket is SymmetricKeyEncSessionPacket symmetricKeyEncSessionPacket)
                {
                    symmetricKeyEncSessionPackets.Add(symmetricKeyEncSessionPacket);
                }
                else
                {
                    publicKeyEncSessionPackets.Add((PublicKeyEncSessionPacket)keyPacket);
                }
            }

            var packet = packetReader.ReadStreamablePacket();

            if (!(packet.Packet is SymmetricEncDataPacket) &&
                !(packet.Packet is SymmetricEncIntegrityPacket))
            {
                throw new IOException("unexpected packet in stream: " + packet);
            }

            this.encryptedPacket = packet.Packet;
            this.inputStream     = packet.Stream;
        }
Esempio n. 3
0
        internal PgpLiteralMessage(IPacketReader packetReader)
        {
            var packet = packetReader.ReadStreamablePacket();

            this.literalDataPacket = (LiteralDataPacket)packet.Packet;
            this.inputStream       = packet.Stream;
        }
Esempio n. 4
0
        internal PgpCompressedMessage(IPacketReader packetReader)
        {
            var packet = packetReader.ReadStreamablePacket();

            this.compressedDataPacket = (CompressedDataPacket)packet.Packet;
            this.inputStream          = packet.Stream;
            this.packetReader         = packetReader;
        }