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; }
public Stream GetPacketStream(StreamablePacket packet) { if (!generator.onePassWritten) { WriteOnePassSignature(false); } if (packet is LiteralDataPacket) { // TODO: Version 5 signatures var packetStream = innerWriter.GetPacketStream(packet); generator.literalDataWritten = true; return(new CryptoStream(packetStream, hashTransform, CryptoStreamMode.Write)); } else { return(innerWriter.GetPacketStream(packet)); } }
public Stream GetPacketStream(StreamablePacket packet) => packetWriter.GetPacketStream(packet);