public static KeyRequest Decode(G2ReceivedPacket packet) { KeyRequest kr = new KeyRequest(); G2Header child = new G2Header(packet.Root.Data); while (G2Protocol.ReadNextChild(packet.Root, child) == G2ReadResult.PACKET_GOOD) { if (!G2Protocol.ReadPayload(child)) { continue; } if (child.Name == Packet_Encryption) { kr.Encryption = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize); } else if (child.Name == Packet_Key) { kr.Key = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); } else if (child.Name == Packet_IV) { kr.IV = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); } } return(kr); }
public static KeyRequest Decode(G2ReceivedPacket packet) { KeyRequest kr = new KeyRequest(); G2Header child = new G2Header(packet.Root.Data); while( G2Protocol.ReadNextChild(packet.Root, child) == G2ReadResult.PACKET_GOOD ) { if (!G2Protocol.ReadPayload(child)) continue; if (child.Name == Packet_Encryption) kr.Encryption = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize); else if (child.Name == Packet_Key) kr.Key = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); else if (child.Name == Packet_IV) kr.IV = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); } return kr; }