<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0-beta.98" />

UserAttributeSubpacketsParser

Parser for user attribute subpackets
using Org.BouncyCastle.Bcpg.Attr; using System.IO; namespace Org.BouncyCastle.Bcpg { public class UserAttributeSubpacketsParser { private readonly Stream m_input; public UserAttributeSubpacketsParser(Stream input) { m_input = input; } public virtual UserAttributeSubpacket ReadPacket() { StreamUtilities.StreamFlags flags; uint num = StreamUtilities.ReadBodyLen(m_input, out flags); if (flags.HasFlag(StreamUtilities.StreamFlags.Eof)) return null; if (flags.HasFlag(StreamUtilities.StreamFlags.Partial)) throw new IOException("unrecognised length reading user attribute subpacket"); bool flag = flags.HasFlag(StreamUtilities.StreamFlags.LongLength); if (num < 1 || num > 2147483647) throw new EndOfStreamException("out of range data found in user attribute subpacket"); byte num2 = StreamUtilities.RequireByte(m_input); byte[] array = new byte[num - 1]; StreamUtilities.RequireBytes(m_input, array); UserAttributeSubpacketTag userAttributeSubpacketTag = (UserAttributeSubpacketTag)num2; if (userAttributeSubpacketTag == UserAttributeSubpacketTag.ImageAttribute) return new ImageAttrib(flag, array); return new UserAttributeSubpacket(userAttributeSubpacketTag, flag, array); } } }