Wireshark  4.3.0
The Wireshark network protocol analyzer
packet-knxip_decrypt.h
1 /* packet-knxip_decrypt.h
2  * Decryption keys and decryption functions for KNX/IP Dissector
3  * Copyright 2018, ise GmbH <Ralf.Nasilowski@ise.de>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11 #ifndef KNXIP_CRYPT_H
12 #define KNXIP_CRYPT_H
13 
14 #define KNX_KEY_LENGTH 16
15 
16 // Calculate MAC for KNX IP Security or KNX Data Security
17 void knx_ccm_calc_cbc_mac( guint8 p_mac[ KNX_KEY_LENGTH ], const guint8 key[ KNX_KEY_LENGTH ],
18  const guint8* a_bytes, gint a_length, const guint8* p_bytes, gint p_length,
19  const guint8 b_0[ KNX_KEY_LENGTH ] );
20 
21 // Calculate MAC for KNX IP Security
22 void knxip_ccm_calc_cbc_mac( guint8 p_mac[ KNX_KEY_LENGTH ], const guint8 key[ KNX_KEY_LENGTH ],
23  const guint8* a_bytes, gint a_length, const guint8* p_bytes, gint p_length,
24  const guint8* nonce, guint8 nonce_length );
25 
26 // Encrypt for KNX IP Security or KNX Data Security
27 guint8* knx_ccm_encrypt( guint8* p_result, const guint8 key[ KNX_KEY_LENGTH ], const guint8* p_bytes, gint p_length,
28  const guint8* mac, guint8 mac_length, const guint8 ctr_0[ KNX_KEY_LENGTH ], guint8 s0_bytes_used_for_mac);
29 
30 // Encrypt for KNX IP Security
31 guint8* knxip_ccm_encrypt( guint8* p_result, const guint8 key[ KNX_KEY_LENGTH ], const guint8* p_bytes, gint p_length,
32  const guint8 mac[ KNX_KEY_LENGTH ], const guint8* nonce, guint8 nonce_length );
33 
34 // Decrypt for KNX IP Security
35 guint8* knxip_ccm_decrypt( guint8* p_result, const guint8 key[ KNX_KEY_LENGTH ], const guint8* crypt, gint crypt_length,
36  const guint8* nonce, guint8 nonce_length );
37 
38 // For importing keyring.XML file exported from ETS:
39 
41 {
42  struct knx_keyring_mca_keys* next;
43  guint8 mca[ 4 ]; // IP multicast address
44  guint8 key[ KNX_KEY_LENGTH ]; // encryption key
45 };
46 
48 {
49  struct knx_keyring_ga_keys* next;
50  guint16 ga; // KNX GA
51  guint8 key[ KNX_KEY_LENGTH ]; // encryption key
52 };
53 
55 {
56  struct knx_keyring_ga_senders* next;
57  guint16 ga; // KNX GA
58  guint16 ia; // sending KNX IA
59 };
60 
62 {
63  struct knx_keyring_ia_keys* next;
64  guint16 ia; // KNX IA
65  guint8 key[ KNX_KEY_LENGTH ]; // encryption key
66 };
67 
69 {
70  struct knx_keyring_ia_seqs* next;
71  guint16 ia; // KNX IA
72  guint64 seq; // 6-byte sequence number
73 };
74 
80 
81 // Read KNX security keys from keyring XML file (exported from ETS)
82 void read_knx_keyring_xml_file( const gchar* key_file, const gchar* password, const gchar* key_info_file );
83 
84 #endif // KNXIP_CRYPT_H
85 
86 /*
87  * Editor modelines - https://www.wireshark.org/tools/modelines.html
88  *
89  * Local variables:
90  * c-basic-offset: 2
91  * tab-width: 8
92  * indent-tabs-mode: nil
93  * End:
94  *
95  * vi: set shiftwidth=2 tabstop=8 expandtab:
96  * :indentSize=2:tabSize=8:noTabs=true:
97  */
Definition: packet-knxip_decrypt.h:48
Definition: packet-knxip_decrypt.h:55
Definition: packet-knxip_decrypt.h:62
Definition: packet-knxip_decrypt.h:69
Definition: packet-knxip_decrypt.h:41