private static void ParseDeadBeefItem(byte tag, Asn1.Kind kind) { var item = Asn1.ParseItem($"{tag:X2}04DEADBEEF".DecodeHex()); Assert.Equal(kind, item.Key); Assert.Equal(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }, item.Value); }
private static void ParseDeadBeefItem(byte tag, Asn1.Kind kind) { var item = Asn1.ParseItem(string.Format("{0:X2}04DEADBEEF", tag).DecodeHex()); Assert.AreEqual(kind, item.Key); Assert.AreEqual(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }, item.Value); }
internal static byte[] ExtractAsn1Item(BinaryReader reader, Asn1.Kind expectedKind) { var item = Asn1.ExtractItem(reader); if (item.Key == expectedKind) { return(item.Value); } throw new InternalErrorException($"ASN.1 decoding failed, expected {expectedKind}, got {item.Key}"); }
internal static byte[] ExtractAsn1Item(byte[] bytes, Asn1.Kind expectedKind) { return(bytes.Open(reader => ExtractAsn1Item(reader, expectedKind))); }