Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-mka.h
1/* packet-mka.h
2 * Routines for MKA packet dissection
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __PACKET_MKA_H__
8#define __PACKET_MKA_H__
9
10#include <epan/packet.h>
11
12#define MKA_MI_LEN_PUB 12U
13#define MKA_MAX_CKN_LEN_PUB 32U
14
15#define AES128_KEY_LEN 16
16#define AES256_KEY_LEN 32
17
18#define MKA_KI_LEN 16U
19
20#define MACSEC_SCI_LEN 8U
21#define MACSEC_XPN_SALT_LEN 12U
22
23#define MACSEC_GCM_AES_128 UINT64_C(0x0080C20001000001)
24#define MACSEC_GCM_AES_256 UINT64_C(0x0080C20001000002)
25#define MACSEC_GCM_AES_XPN_128 UINT64_C(0x0080C20001000003)
26#define MACSEC_GCM_AES_XPN_256 UINT64_C(0x0080C20001000004)
27
28#define MKA_CAK_AES_GCM_128_LEN (AES128_KEY_LEN)
29#define MKA_CAK_AES_GCM_256_LEN (AES256_KEY_LEN)
30#define MKA_MAX_CAK_LEN (MKA_CAK_AES_GCM_256_LEN)
31
32#define MKA_MAX_KEK_LEN (MKA_CAK_AES_GCM_256_LEN)
33#define MKA_MAX_ICK_LEN (MKA_CAK_AES_GCM_256_LEN)
34#define MKA_MAX_SAK_LEN (MKA_CAK_AES_GCM_256_LEN)
35
36typedef struct _mka_sak_info_key {
37 /* the SAK unwrapped by the KEK */
38 unsigned char sak[MKA_MAX_SAK_LEN];
39
40 /* the Key Identifier (Server MI + Key Number) */
41 uint8_t ki[MKA_KI_LEN];
42
43 /* SCIs of active participants (those that have sent MKPDUs) for the
44 * CA using this CKN. Note there can be passive participants, see
45 * IEEE 802.1X-2020 9.4.6 */
46 wmem_map_t *sci_map;
47 wmem_array_t *mi_array;
48
49 unsigned char salt[MACSEC_XPN_SALT_LEN];
50
51 uint64_t cipher_suite;
52 unsigned sak_len;
53} mka_sak_info_key_t;
54
55typedef struct _mka_ckn_info_key {
56 /* The KEK derived from the CAK */
57 unsigned char kek[MKA_MAX_KEK_LEN];
58 unsigned kek_len;
59
60 /* The ICK derived from the CAK */
61 unsigned char ick[MKA_MAX_ICK_LEN];
62 unsigned ick_len;
63} mka_ckn_info_key_t;
64
65typedef struct _mka_ckn_info {
66 /* CKN: a byte array of 0 to 32 bytes. */
67 unsigned char *ckn;
68 unsigned ckn_len;
69
70 /* CAK: a byte array of 0 to 32 bytes. */
71 unsigned char *cak;
72 unsigned cak_len;
73
74 /* Identifier for the name of the entry. */
75 char *name;
76
77 /* KEK/ICK data for this entry */
78 mka_ckn_info_key_t key;
79} mka_ckn_info_t;
80
81/* Tap record emitted once per MKPDU carrying a CKN (known or not). */
82typedef struct _mka_ca_tap {
83 /* CA this MKPDU belongs to. ckn_info is NULL for a CKN not in the table
84 * (its MKPDUs cannot be authenticated and its SAK cannot be unwrapped). */
85 const mka_ckn_info_t *ckn_info;
86 /* Raw CKN bytes from the Basic Parameter Set, identifying the CA even when
87 * ckn_info is NULL. */
88 uint8_t ckn[MKA_MAX_CKN_LEN_PUB];
89 unsigned ckn_len;
90
91 uint32_t frame_num;
92 nstime_t abs_ts;
93
94 /* Actor identity from the Basic Parameter Set. */
95 uint8_t actor_sci[MACSEC_SCI_LEN];
96 uint8_t actor_mi[MKA_MI_LEN_PUB];
97 uint32_t actor_mn;
98 uint8_t mka_version;
99 bool key_server;
100
101 /* Distributed SAK parameter set, if present. */
102 bool has_dist_sak;
103 uint8_t dist_sak_an;
104 uint32_t dist_sak_kn;
105 uint8_t dist_sak_ki[MKA_KI_LEN]; /* server MI + key number */
106 uint8_t dist_sak[MKA_MAX_SAK_LEN]; /* unwrapped SAK (if KEK known) */
107 unsigned dist_sak_len; /* 0 if the SAK was not unwrapped */
108
109 /* MACsec SAK Use parameter set, if present. */
110 bool has_sak_use;
111 uint8_t latest_an;
112 bool latest_tx; /* ltx */
113 bool latest_rx; /* lrx */
114 bool latest_ki_valid;
115 uint8_t latest_ki[MKA_KI_LEN]; /* latest key server MI + key number */
116 uint8_t old_an;
117 bool old_tx; /* otx */
118 bool old_rx; /* orx */
119 bool old_ki_valid;
120 uint8_t old_ki[MKA_KI_LEN]; /* old key server MI + key number */
121
122 /* Peer lists: arrays of MKA_MI_LEN_PUB-byte MIs. */
123 wmem_array_t *live_peers;
124 wmem_array_t *potential_peers;
125} mka_ca_tap_t;
126
127/* access to the table data from macsec dissector */
128const mka_ckn_info_t * get_mka_ckn_table(void);
129unsigned get_mka_ckn_table_count(void);
130
131mka_sak_info_key_t *mka_get_sak_info(const mka_ckn_info_t *ckn_info, unsigned an, uint32_t frame_num);
132
133/* This LPN is only guaranteed to be accurate to the upper 33 bits, as that
134 * is all that is required for the recovery algorithm in 802.1AE-2018 10.6.2
135 * sci is allowed to be NULL, in which case the largest value for any
136 * SCI for this SAK is returned. */
137uint64_t mka_get_lpn(const mka_sak_info_key_t *sak_info, const uint8_t *sci, uint32_t frame_num);
138
139#endif
struct _wmem_array_t wmem_array_t
Opaque type representing a dynamically resizable array in the wmem system.
Definition wmem_array.h:42
struct _wmem_map_t wmem_map_t
Opaque type representing a wmem-managed hash map.
Definition wmem_map.h:46
Definition packet-mka.h:82
Definition packet-mka.h:55
Definition packet-mka.h:65
Definition packet-mka.h:36
Definition nstime.h:26