1 /******************************************************************************
2 ** Copyright (C) 2006-2007 ascolab GmbH. All Rights Reserved.
3 ** Web: http://www.ascolab.com
5 ** SPDX-License-Identifier: GPL-2.0-or-later
7 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
8 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10 ** Project: OpcUa Wireshark Plugin
12 ** Description: OpcUa Security Layer Decoder.
14 ** Author: Gerhard Gappmeier <gerhard.gappmeier@ascolab.com>
15 ******************************************************************************/
19 #include <epan/packet.h>
20 #include "opcua_security_layer.h"
21 #include "opcua_transport_layer.h"
23 static int hf_opcua_security_tokenid
;
24 static int hf_opcua_security_padding
;
25 static int hf_opcua_security_signature
;
26 static int hf_opcua_sequence_seqno
;
27 static int hf_opcua_sequence_rqid
;
29 /** Register symmetric security layer types. */
30 void registerSecurityLayerTypes(int proto
)
32 static hf_register_info hf
[] =
34 /* id full name abbreviation type display strings bitmask blurb HFILL */
35 {&hf_opcua_security_tokenid
, {"Security Token Id", "opcua.security.tokenid", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
36 {&hf_opcua_security_padding
, {"Security Padding", "opcua.security.padding", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
37 {&hf_opcua_security_signature
, {"Security Signature", "opcua.security.signature", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
39 proto_register_field_array(proto
, hf
, array_length(hf
));
42 /** Register sequence header types. */
43 void registerSequenceLayerTypes(int proto
)
45 static hf_register_info hf
[] =
47 /* id full name abbreviation type display strings bitmask blurb HFILL */
48 {&hf_opcua_sequence_seqno
, {"Sequence Number", "opcua.sequence.seq", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
49 {&hf_opcua_sequence_rqid
, {"RequestId", "opcua.sequence.rqid", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}}
51 proto_register_field_array(proto
, hf
, array_length(hf
));
54 /* The symmetric security header consists only of one field. */
55 void parseSecurityHeader(proto_tree
*tree
, tvbuff_t
*tvb
, int *pOffset
, struct ua_metadata
*data _U_
)
57 proto_tree_add_item(tree
, hf_opcua_security_tokenid
, tvb
, *pOffset
, 4, ENC_LITTLE_ENDIAN
); *pOffset
+=4;
60 /* Sequence header can optionally be encrypted. */
61 void parseSequenceHeader(proto_tree
*tree
, tvbuff_t
*tvb
, int *pOffset
, struct ua_metadata
*data
)
63 if (!data
->encrypted
) {
64 proto_tree_add_item(tree
, hf_opcua_sequence_seqno
, tvb
, *pOffset
, 4, ENC_LITTLE_ENDIAN
); *pOffset
+=4;
65 proto_tree_add_item(tree
, hf_opcua_sequence_rqid
, tvb
, *pOffset
, 4, ENC_LITTLE_ENDIAN
); *pOffset
+=4;
69 /* Parse symmetric security footer (signed only) */
70 void parseSecurityFooterSO(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, unsigned sig_len
)
72 proto_tree_add_item(tree
, hf_opcua_security_signature
, tvb
, offset
, sig_len
, ENC_NA
);
75 /* Parse symmetric security footer (signed and encrypted) */
76 void parseSecurityFooterSAE(proto_tree
*tree
, tvbuff_t
*tvb
, int offset
, unsigned pad_len
, unsigned sig_len
)
78 proto_tree_add_item(tree
, hf_opcua_security_padding
, tvb
, offset
, pad_len
+ 1, ENC_NA
);
79 proto_tree_add_item(tree
, hf_opcua_security_signature
, tvb
, offset
+ pad_len
+ 1, sig_len
, ENC_NA
);
83 * Editor modelines - https://www.wireshark.org/tools/modelines.html
88 * indent-tabs-mode: nil
91 * vi: set shiftwidth=4 tabstop=8 expandtab:
92 * :indentSize=4:tabSize=8:noTabs=true: