Skip to content

Commit 0b75336

Browse files
authored
feat(pcapng): add support for Decryption Secrets Block (#411)
feat(pcapng): add support for Decryption Secrets Block
1 parent e3edbd5 commit 0b75336

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

patterns/pcapng.hexpat

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,12 @@ enum CompressionType: u8 {
393393
Gzip = 0x2
394394
};
395395

396-
enum EncryptionType : u8 {
397-
// Experimental
396+
enum EncryptionType : u32 {
397+
TLS = 0x544c534b, /* TLS Key Log */
398+
SSH = 0x5353484b, /* SSH Key Log */
399+
WIREGUARD = 0x57474b4c, /* WireGuard Key Log */
400+
ZIGBEE_NWK_KEY = 0x5a4e574b, /* Zigbee NWK Key */
401+
ZIGBEE_APS_KEY = 0x5a415053 /* Zigbee APS Key */
398402
};
399403

400404
enum FixedLengthType : u8 {
@@ -410,12 +414,16 @@ struct CompressionBlock{
410414
u32 block_len2[[name("BlockLen2")]];
411415
};
412416

413-
// Experimental
414417
struct EncryptionBlock{
415418
BlockType block_type[[name("BlockType")]];
416419
u32 block_len1[[name("BlockLen1")]];
417420
EncryptionType comp_type [[name("Encryption")]];
418-
char data[block_len1];
421+
u32 secrets_len[[name("SecretsLength")]];
422+
char data[secrets_len];
423+
padding[-$ & 3];
424+
// https://ietf-opsawg-wg.github.io/draft-ietf-opsawg-pcap/draft-ietf-opsawg-pcapng.html#section-4.7-6.6.1
425+
// No DSB-specific options are currently defined
426+
// Option options;
419427
u32 block_len2[[name("BlockLen2")]];
420428
};
421429

@@ -505,6 +513,12 @@ struct PCAPng{
505513
} else {
506514
be CustomBlock CBN;
507515
}
516+
} else if (block_type == BlockType::Decryption) {
517+
if (order == PcapOrder::Little) {
518+
le EncryptionBlock DSB;
519+
} else {
520+
be EncryptionBlock DSB;
521+
}
508522
} else {
509523
std::print("Unknown BlockType at offset {:#x}\n", $);
510524
break;

0 commit comments

Comments
 (0)