public SignatureSubpacketTag[] GetCriticalTags() { int count = 0; for (int i = 0; i != packets.Length; i++) { if (packets[i].IsCritical()) { count++; } } SignatureSubpacketTag[] list = new SignatureSubpacketTag[count]; count = 0; for (int i = 0; i != packets.Length; i++) { if (packets[i].IsCritical()) { list[count++] = packets[i].SubpacketType; } } return list; }
public PreferredAlgorithms( SignatureSubpacketTag type, bool critical, int[] preferences) : base(type, critical, IntToByteArray(preferences)) { }
public SignatureSubpacketTag[] GetCriticalTags() { int count = 0; for (int i = 0; i != packets.Length; i++) { if (packets[i].IsCritical()) { count++; } } SignatureSubpacketTag[] list = new SignatureSubpacketTag[count]; count = 0; for (int i = 0; i != packets.Length; i++) { if (packets[i].IsCritical()) { list[count++] = packets[i].SubpacketType; } } return(list); }
public PreferredAlgorithms( SignatureSubpacketTag type, bool critical, byte[] data) : base(type, critical, data) { }
protected internal SignatureSubpacket(SignatureSubpacketTag type, bool critical, bool isLongLength, byte[] data) { this.type = type; this.critical = critical; this.isLongLength = isLongLength; this.data = data; }
/** * Return all signature subpackets of the passed in type. * @param type subpacket type code * @return an array of zero or more matching subpackets. */ public SignatureSubpacket[] GetSubpackets( SignatureSubpacketTag type) { int count = 0; for (int i = 0; i < packets.Length; ++i) { if (packets[i].SubpacketType == type) { ++count; } } SignatureSubpacket[] result = new SignatureSubpacket[count]; int pos = 0; for (int i = 0; i < packets.Length; ++i) { if (packets[i].SubpacketType == type) { result[pos++] = packets[i]; } } return(result); }
/** * Return all signature subpackets of the passed in type. * @param type subpacket type code * @return an array of zero or more matching subpackets. */ public SignatureSubpacket[] GetSubpackets( SignatureSubpacketTag type) { int count = 0; for (int i = 0; i < packets.Length; ++i) { if (packets[i].SubpacketType == type) { ++count; } } SignatureSubpacket[] result = new SignatureSubpacket[count]; int pos = 0; for (int i = 0; i < packets.Length; ++i) { if (packets[i].SubpacketType == type) { result[pos++] = packets[i]; } } return result; }
protected internal SignatureSubpacket( SignatureSubpacketTag type, bool critical, byte[] data) { this.type = type; this.critical = critical; this.data = data; }
private bool packetPresent(SignatureSubpacket[] packets, SignatureSubpacketTag type) { for (int i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { return(true); } } return(false); }
public SignatureSubpacket GetSubpacket(SignatureSubpacketTag type) { for (int i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { return(packets[i]); } } return(null); }
/// <summary> /// Packets the present. /// </summary> /// <param name="packets">The packets.</param> /// <param name="type">The type.</param> /// <returns></returns> private static bool PacketPresent(ISignatureSubpacket[] packets, SignatureSubpacketTag type) { for (var i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { return(true); } } return(false); }
public ISignatureSubpacket GetSubpacket(SignatureSubpacketTag type) { for (var i = 0; i != _packets.Length; i++) { if (_packets[i].SubpacketType == type) { return(_packets[i]); } } return(null); }
public SignatureSubpacket GetSubpacket( SignatureSubpacketTag type) { for (int i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { return packets[i]; } } return null; }
/** * Return all signature subpackets of the passed in type. * @param type subpacket type code * @return an array of zero or more matching subpackets. */ public SignatureSubpacket[] GetSubpackets( SignatureSubpacketTag type) { ArrayList list = new ArrayList(); for (int i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { list.Add(packets[i]); } } return (SignatureSubpacket[]) list.ToArray(typeof(SignatureSubpacket)); }
/** * Return all signature subpackets of the passed in type. * @param type subpacket type code * @return an array of zero or more matching subpackets. */ public SignatureSubpacket[] GetSubpackets( SignatureSubpacketTag type) { ArrayList list = new ArrayList(); for (int i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { list.Add(packets[i]); } } return((SignatureSubpacket[])list.ToArray(typeof(SignatureSubpacket))); }
public SignatureSubpacketTag[] GetCriticalTags() { int num = 0; for (int i = 0; i != packets.Length; i++) { if (packets[i].IsCritical()) { num++; } } SignatureSubpacketTag[] array = new SignatureSubpacketTag[num]; num = 0; for (int j = 0; j != packets.Length; j++) { if (packets[j].IsCritical()) { array[num++] = packets[j].SubpacketType; } } return(array); }
public SignatureSubpacket[] GetSubpackets(SignatureSubpacketTag type) { int num = 0; for (int i = 0; i < packets.Length; i++) { if (packets[i].SubpacketType == type) { num++; } } SignatureSubpacket[] array = new SignatureSubpacket[num]; int num2 = 0; for (int j = 0; j < packets.Length; j++) { if (packets[j].SubpacketType == type) { array[num2++] = packets[j]; } } return(array); }
/** * Return true if a particular subpacket type exists. * * @param type type to look for. * @return true if present, false otherwise. */ public bool HasSubpacket( SignatureSubpacketTag type) { return(GetSubpacket(type) != null); }
public SignatureSubpacket ReadPacket() { int num = input.ReadByte(); if (num < 0) { return(null); } int num2 = 0; bool isLongLength = false; if (num < 192) { num2 = num; } else if (num <= 223) { num2 = (num - 192 << 8) + input.ReadByte() + 192; } else { if (num != 255) { throw new IOException("unexpected length header"); } isLongLength = true; num2 = ((input.ReadByte() << 24) | (input.ReadByte() << 16) | (input.ReadByte() << 8) | input.ReadByte()); } int num3 = input.ReadByte(); if (num3 < 0) { throw new EndOfStreamException("unexpected EOF reading signature sub packet"); } byte[] array = new byte[num2 - 1]; int num4 = Streams.ReadFully(input, array); bool critical = (num3 & 0x80) != 0; SignatureSubpacketTag signatureSubpacketTag = (SignatureSubpacketTag)(num3 & 0x7F); if (num4 != array.Length) { switch (signatureSubpacketTag) { case SignatureSubpacketTag.CreationTime: array = CheckData(array, 4, num4, "Signature Creation Time"); break; case SignatureSubpacketTag.IssuerKeyId: array = CheckData(array, 8, num4, "Issuer"); break; case SignatureSubpacketTag.KeyExpireTime: array = CheckData(array, 4, num4, "Signature Key Expiration Time"); break; case SignatureSubpacketTag.ExpireTime: array = CheckData(array, 4, num4, "Signature Expiration Time"); break; default: throw new EndOfStreamException("truncated subpacket data."); } } switch (signatureSubpacketTag) { case SignatureSubpacketTag.CreationTime: return(new SignatureCreationTime(critical, isLongLength, array)); case SignatureSubpacketTag.KeyExpireTime: return(new KeyExpirationTime(critical, isLongLength, array)); case SignatureSubpacketTag.ExpireTime: return(new SignatureExpirationTime(critical, isLongLength, array)); case SignatureSubpacketTag.Revocable: return(new Revocable(critical, isLongLength, array)); case SignatureSubpacketTag.Exportable: return(new Exportable(critical, isLongLength, array)); case SignatureSubpacketTag.IssuerKeyId: return(new IssuerKeyId(critical, isLongLength, array)); case SignatureSubpacketTag.TrustSig: return(new TrustSignature(critical, isLongLength, array)); case SignatureSubpacketTag.PreferredSymmetricAlgorithms: case SignatureSubpacketTag.PreferredHashAlgorithms: case SignatureSubpacketTag.PreferredCompressionAlgorithms: return(new PreferredAlgorithms(signatureSubpacketTag, critical, isLongLength, array)); case SignatureSubpacketTag.KeyFlags: return(new KeyFlags(critical, isLongLength, array)); case SignatureSubpacketTag.PrimaryUserId: return(new PrimaryUserId(critical, isLongLength, array)); case SignatureSubpacketTag.SignerUserId: return(new SignerUserId(critical, isLongLength, array)); case SignatureSubpacketTag.NotationData: return(new NotationData(critical, isLongLength, array)); default: return(new SignatureSubpacket(signatureSubpacketTag, critical, isLongLength, array)); } }
private bool packetPresent( SignatureSubpacket[] packets, SignatureSubpacketTag type) { for (int i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { return true; } } return false; }
/** * Return all signature subpackets of the passed in type. * @param type subpacket type code * @return an array of zero or more matching subpackets. */ public ISignatureSubpacket[] GetSubpackets(SignatureSubpacketTag type) { return(_packets.Where(t => t.SubpacketType == type).ToArray()); }
public SignatureSubpacket ReadPacket() { int l = input.ReadByte(); if (l < 0) { return(null); } int bodyLen = 0; bool isLongLength = false; if (l < 192) { bodyLen = l; } else if (l <= 223) { bodyLen = ((l - 192) << 8) + (input.ReadByte()) + 192; } else if (l == 255) { isLongLength = true; bodyLen = (input.ReadByte() << 24) | (input.ReadByte() << 16) | (input.ReadByte() << 8) | input.ReadByte(); } else { throw new IOException("unexpected length header"); } int tag = input.ReadByte(); if (tag < 0) { throw new EndOfStreamException("unexpected EOF reading signature sub packet"); } byte[] data = new byte[bodyLen - 1]; // // this may seem a bit strange but it turns out some applications miscode the length // in fixed length fields, so we check the length we do get, only throwing an exception if // we really cannot continue // int bytesRead = Streams.ReadFully(input, data); bool isCritical = ((tag & 0x80) != 0); SignatureSubpacketTag type = (SignatureSubpacketTag)(tag & 0x7f); if (bytesRead != data.Length) { switch (type) { case SignatureSubpacketTag.CreationTime: data = CheckData(data, 4, bytesRead, "Signature Creation Time"); break; case SignatureSubpacketTag.IssuerKeyId: data = CheckData(data, 8, bytesRead, "Issuer"); break; case SignatureSubpacketTag.KeyExpireTime: data = CheckData(data, 4, bytesRead, "Signature Key Expiration Time"); break; case SignatureSubpacketTag.ExpireTime: data = CheckData(data, 4, bytesRead, "Signature Expiration Time"); break; default: throw new EndOfStreamException("truncated subpacket data."); } } switch (type) { case SignatureSubpacketTag.CreationTime: return(new SignatureCreationTime(isCritical, isLongLength, data)); case SignatureSubpacketTag.KeyExpireTime: return(new KeyExpirationTime(isCritical, isLongLength, data)); case SignatureSubpacketTag.ExpireTime: return(new SignatureExpirationTime(isCritical, isLongLength, data)); case SignatureSubpacketTag.Revocable: return(new Revocable(isCritical, isLongLength, data)); case SignatureSubpacketTag.Exportable: return(new Exportable(isCritical, isLongLength, data)); case SignatureSubpacketTag.IssuerKeyId: return(new IssuerKeyId(isCritical, isLongLength, data)); case SignatureSubpacketTag.TrustSig: return(new TrustSignature(isCritical, isLongLength, data)); case SignatureSubpacketTag.PreferredCompressionAlgorithms: case SignatureSubpacketTag.PreferredHashAlgorithms: case SignatureSubpacketTag.PreferredSymmetricAlgorithms: return(new PreferredAlgorithms(type, isCritical, isLongLength, data)); case SignatureSubpacketTag.KeyFlags: return(new KeyFlags(isCritical, isLongLength, data)); case SignatureSubpacketTag.PrimaryUserId: return(new PrimaryUserId(isCritical, isLongLength, data)); case SignatureSubpacketTag.SignerUserId: return(new SignerUserId(isCritical, isLongLength, data)); case SignatureSubpacketTag.NotationData: return(new NotationData(isCritical, isLongLength, data)); } return(new SignatureSubpacket(type, isCritical, isLongLength, data)); }
public ISignatureSubpacket GetSubpacket(SignatureSubpacketTag type) { for (var i = 0; i != _packets.Length; i++) { if (_packets[i].SubpacketType == type) { return _packets[i]; } } return null; }
/** * Return true if a particular subpacket type exists. * * @param type type to look for. * @return true if present, false otherwise. */ public bool HasSubpacket( SignatureSubpacketTag type) { return GetSubpacket(type) != null; }
/** * Return all signature subpackets of the passed in type. * @param type subpacket type code * @return an array of zero or more matching subpackets. */ public ISignatureSubpacket[] GetSubpackets(SignatureSubpacketTag type) { return _packets.Where(t => t.SubpacketType == type).ToArray(); }
/// <summary> /// Packets the present. /// </summary> /// <param name="packets">The packets.</param> /// <param name="type">The type.</param> /// <returns></returns> private static bool PacketPresent(ISignatureSubpacket[] packets, SignatureSubpacketTag type) { for (var i = 0; i != packets.Length; i++) { if (packets[i].SubpacketType == type) { return true; } } return false; }
public SignatureSubpacket ReadPacket() { int num = this.input.ReadByte(); if (num < 0) { return(null); } int num2 = 0; if (num < 192) { num2 = num; } else if (num <= 223) { num2 = (num - 192 << 8) + this.input.ReadByte() + 192; } else if (num == 255) { num2 = (this.input.ReadByte() << 24 | this.input.ReadByte() << 16 | this.input.ReadByte() << 8 | this.input.ReadByte()); } int num3 = this.input.ReadByte(); if (num3 < 0) { throw new EndOfStreamException("unexpected EOF reading signature sub packet"); } byte[] array = new byte[num2 - 1]; if (Streams.ReadFully(this.input, array) < array.Length) { throw new EndOfStreamException(); } bool critical = (num3 & 128) != 0; SignatureSubpacketTag type = (SignatureSubpacketTag)(num3 & 127); switch (type) { case SignatureSubpacketTag.CreationTime: return(new SignatureCreationTime(critical, array)); case SignatureSubpacketTag.ExpireTime: return(new SignatureExpirationTime(critical, array)); case SignatureSubpacketTag.Exportable: return(new Exportable(critical, array)); case SignatureSubpacketTag.TrustSig: return(new TrustSignature(critical, array)); case SignatureSubpacketTag.Revocable: return(new Revocable(critical, array)); case SignatureSubpacketTag.KeyExpireTime: return(new KeyExpirationTime(critical, array)); case SignatureSubpacketTag.PreferredSymmetricAlgorithms: case SignatureSubpacketTag.PreferredHashAlgorithms: case SignatureSubpacketTag.PreferredCompressionAlgorithms: return(new PreferredAlgorithms(type, critical, array)); case SignatureSubpacketTag.IssuerKeyId: return(new IssuerKeyId(critical, array)); case SignatureSubpacketTag.NotationData: return(new NotationData(critical, array)); case SignatureSubpacketTag.PrimaryUserId: return(new PrimaryUserId(critical, array)); case SignatureSubpacketTag.KeyFlags: return(new KeyFlags(critical, array)); case SignatureSubpacketTag.SignerUserId: return(new SignerUserId(critical, array)); } return(new SignatureSubpacket(type, critical, array)); }
public SignatureSubpacket ReadPacket() { int l = input.ReadByte(); if (l < 0) { return(null); } int bodyLen = 0; if (l < 192) { bodyLen = l; } else if (l <= 223) { bodyLen = ((l - 192) << 8) + (input.ReadByte()) + 192; } else if (l == 255) { bodyLen = (input.ReadByte() << 24) | (input.ReadByte() << 16) | (input.ReadByte() << 8) | input.ReadByte(); } else { // TODO Error? } int tag = input.ReadByte(); if (tag < 0) { throw new EndOfStreamException("unexpected EOF reading signature sub packet"); } byte[] data = new byte[bodyLen - 1]; if (Streams.ReadFully(input, data) < data.Length) { throw new EndOfStreamException(); } bool isCritical = ((tag & 0x80) != 0); SignatureSubpacketTag type = (SignatureSubpacketTag)(tag & 0x7f); switch (type) { case SignatureSubpacketTag.CreationTime: return(new SignatureCreationTime(isCritical, data)); case SignatureSubpacketTag.KeyExpireTime: return(new KeyExpirationTime(isCritical, data)); case SignatureSubpacketTag.ExpireTime: return(new SignatureExpirationTime(isCritical, data)); case SignatureSubpacketTag.Revocable: return(new Revocable(isCritical, data)); case SignatureSubpacketTag.Exportable: return(new Exportable(isCritical, data)); case SignatureSubpacketTag.IssuerKeyId: return(new IssuerKeyId(isCritical, data)); case SignatureSubpacketTag.TrustSig: return(new TrustSignature(isCritical, data)); case SignatureSubpacketTag.PreferredCompressionAlgorithms: case SignatureSubpacketTag.PreferredHashAlgorithms: case SignatureSubpacketTag.PreferredSymmetricAlgorithms: return(new PreferredAlgorithms(type, isCritical, data)); case SignatureSubpacketTag.KeyFlags: return(new KeyFlags(isCritical, data)); case SignatureSubpacketTag.PrimaryUserId: return(new PrimaryUserId(isCritical, data)); case SignatureSubpacketTag.SignerUserId: return(new SignerUserId(isCritical, data)); case SignatureSubpacketTag.NotationData: return(new NotationData(isCritical, data)); } return(new SignatureSubpacket(type, isCritical, data)); }
protected internal SignatureSubpacket(SignatureSubpacketTag type, bool critical, byte[] data) { this._type = type; this._critical = critical; this.Data = data; }