public static SignedData Decode(G2Header root) { SignedData signed = new SignedData(); G2Header child = new G2Header(root.Data); while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD) { if (!G2Protocol.ReadPayload(child)) { continue; } switch (child.Name) { case Packet_Signature: signed.Signature = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Data: signed.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); break; } } return(signed); }
public static SignedData Decode(byte[] data) { G2Header root = new G2Header(data); if (!G2Protocol.ReadPacket(root)) { return(null); } if (root.Name != DataPacket.SignedData) { return(null); } return(SignedData.Decode(root)); }