/src/wireshark/epan/dissectors/packet-nist-csor.c
Line | Count | Source |
1 | | /* Do not modify this file. Changes will be overwritten. */ |
2 | | /* Generated automatically by the ASN.1 to Wireshark dissector compiler */ |
3 | | /* packet-nist-csor.c */ |
4 | | /* asn2wrs.py -b -q -L -p nist-csor -c ./nist-csor.cnf -s ./packet-nist-csor-template -D . -O ../.. aes1.asn */ |
5 | | |
6 | | /* packet-nist-csor.c |
7 | | * |
8 | | * Wireshark - Network traffic analyzer |
9 | | * By Gerald Combs <gerald@wireshark.org> |
10 | | * Copyright 1998 Gerald Combs |
11 | | * |
12 | | * SPDX-License-Identifier: GPL-2.0-or-later |
13 | | */ |
14 | | |
15 | | #include "config.h" |
16 | | |
17 | | #include <epan/packet.h> |
18 | | #include <epan/oids.h> |
19 | | #include <epan/asn1.h> |
20 | | #include <wsutil/array.h> |
21 | | |
22 | | #include "packet-nist-csor.h" |
23 | | #include "packet-ber.h" |
24 | | #include "packet-pkix1explicit.h" |
25 | | #include "packet-pkix1implicit.h" |
26 | | |
27 | | void proto_register_nist_csor(void); |
28 | | void proto_reg_handoff_nist_csor(void); |
29 | | |
30 | | /* Initialize the protocol and registered fields */ |
31 | | static int proto_nist_csor; |
32 | | static int hf_nist_csor_CFBParameters_PDU; /* CFBParameters */ |
33 | | static int hf_nist_csor_AES_IV_PDU; /* AES_IV */ |
34 | | static int hf_nist_csor_ShakeOutputLen_PDU; /* ShakeOutputLen */ |
35 | | static int hf_nist_csor_aes_IV; /* AES_IV */ |
36 | | static int hf_nist_csor_numberOfBits; /* NumberOfBits */ |
37 | | |
38 | | /* Initialize the subtree pointers */ |
39 | | static int ett_nist_csor_CFBParameters; |
40 | | |
41 | | |
42 | | unsigned |
43 | 0 | dissect_nist_csor_AES_IV(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
44 | 0 | offset = dissect_ber_constrained_octet_string(implicit_tag, actx, tree, tvb, offset, |
45 | 0 | 16, 16, hf_index, NULL); |
46 | |
|
47 | 0 | return offset; |
48 | 0 | } |
49 | | |
50 | | |
51 | | |
52 | | unsigned |
53 | 0 | dissect_nist_csor_NumberOfBits(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
54 | 0 | offset = dissect_ber_constrained_integer(implicit_tag, actx, tree, tvb, offset, |
55 | 0 | 1U, 128U, hf_index, NULL); |
56 | |
|
57 | 0 | return offset; |
58 | 0 | } |
59 | | |
60 | | |
61 | | static const ber_sequence_t CFBParameters_sequence[] = { |
62 | | { &hf_nist_csor_aes_IV , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_nist_csor_AES_IV }, |
63 | | { &hf_nist_csor_numberOfBits, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_nist_csor_NumberOfBits }, |
64 | | { NULL, 0, 0, 0, NULL } |
65 | | }; |
66 | | |
67 | | unsigned |
68 | 0 | dissect_nist_csor_CFBParameters(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
69 | 0 | offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset, |
70 | 0 | CFBParameters_sequence, hf_index, ett_nist_csor_CFBParameters); |
71 | |
|
72 | 0 | return offset; |
73 | 0 | } |
74 | | |
75 | | |
76 | | |
77 | | unsigned |
78 | 0 | dissect_nist_csor_ShakeOutputLen(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { |
79 | 0 | offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, |
80 | 0 | NULL); |
81 | |
|
82 | 0 | return offset; |
83 | 0 | } |
84 | | |
85 | | /*--- PDUs ---*/ |
86 | | |
87 | 0 | static int dissect_CFBParameters_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
88 | 0 | unsigned offset = 0; |
89 | 0 | asn1_ctx_t asn1_ctx; |
90 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
91 | 0 | offset = dissect_nist_csor_CFBParameters(false, tvb, offset, &asn1_ctx, tree, hf_nist_csor_CFBParameters_PDU); |
92 | 0 | return offset; |
93 | 0 | } |
94 | 0 | static int dissect_AES_IV_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
95 | 0 | unsigned offset = 0; |
96 | 0 | asn1_ctx_t asn1_ctx; |
97 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
98 | 0 | offset = dissect_nist_csor_AES_IV(false, tvb, offset, &asn1_ctx, tree, hf_nist_csor_AES_IV_PDU); |
99 | 0 | return offset; |
100 | 0 | } |
101 | 0 | static int dissect_ShakeOutputLen_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) { |
102 | 0 | unsigned offset = 0; |
103 | 0 | asn1_ctx_t asn1_ctx; |
104 | 0 | asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo); |
105 | 0 | offset = dissect_nist_csor_ShakeOutputLen(false, tvb, offset, &asn1_ctx, tree, hf_nist_csor_ShakeOutputLen_PDU); |
106 | 0 | return offset; |
107 | 0 | } |
108 | | |
109 | | |
110 | | |
111 | | /*--- proto_register_nist-csor ----------------------------------------------*/ |
112 | 15 | void proto_register_nist_csor(void) { |
113 | | |
114 | | /* List of fields */ |
115 | 15 | static hf_register_info hf[] = { |
116 | 15 | { &hf_nist_csor_CFBParameters_PDU, |
117 | 15 | { "CFBParameters", "nist-csor.CFBParameters_element", |
118 | 15 | FT_NONE, BASE_NONE, NULL, 0, |
119 | 15 | NULL, HFILL }}, |
120 | 15 | { &hf_nist_csor_AES_IV_PDU, |
121 | 15 | { "AES-IV", "nist-csor.AES_IV", |
122 | 15 | FT_BYTES, BASE_NONE, NULL, 0, |
123 | 15 | NULL, HFILL }}, |
124 | 15 | { &hf_nist_csor_ShakeOutputLen_PDU, |
125 | 15 | { "ShakeOutputLen", "nist-csor.ShakeOutputLen", |
126 | 15 | FT_INT32, BASE_DEC, NULL, 0, |
127 | 15 | NULL, HFILL }}, |
128 | 15 | { &hf_nist_csor_aes_IV, |
129 | 15 | { "aes-IV", "nist-csor.aes_IV", |
130 | 15 | FT_BYTES, BASE_NONE, NULL, 0, |
131 | 15 | NULL, HFILL }}, |
132 | 15 | { &hf_nist_csor_numberOfBits, |
133 | 15 | { "numberOfBits", "nist-csor.numberOfBits", |
134 | 15 | FT_UINT32, BASE_DEC, NULL, 0, |
135 | 15 | NULL, HFILL }}, |
136 | 15 | }; |
137 | | |
138 | | /* List of subtrees */ |
139 | 15 | static int *ett[] = { |
140 | 15 | &ett_nist_csor_CFBParameters, |
141 | 15 | }; |
142 | | |
143 | | /* Register protocol */ |
144 | 15 | proto_nist_csor = proto_register_protocol("NIST_CSOR", "NIST_CSOR", "nist_csor"); |
145 | | |
146 | | /* Register fields and subtrees */ |
147 | 15 | proto_register_field_array(proto_nist_csor, hf, array_length(hf)); |
148 | 15 | proto_register_subtree_array(ett, array_length(ett)); |
149 | 15 | } |
150 | | |
151 | | |
152 | | /*--- proto_reg_handoff_nist_csor -------------------------------------------*/ |
153 | 15 | void proto_reg_handoff_nist_csor(void) { |
154 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.2", dissect_AES_IV_PDU, proto_nist_csor, "id-aes128-CBC"); |
155 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.3", dissect_AES_IV_PDU, proto_nist_csor, "id-aes128-OFB"); |
156 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.4", dissect_CFBParameters_PDU, proto_nist_csor, "id-aes128-CFB"); |
157 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.22", dissect_AES_IV_PDU, proto_nist_csor, "id-aes192-CBC"); |
158 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.23", dissect_AES_IV_PDU, proto_nist_csor, "id-aes192-OFB"); |
159 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.24", dissect_CFBParameters_PDU, proto_nist_csor, "id-aes192-CFB"); |
160 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.42", dissect_AES_IV_PDU, proto_nist_csor, "id-aes256-CBC"); |
161 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.43", dissect_AES_IV_PDU, proto_nist_csor, "id-aes256-OFB"); |
162 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.1.44", dissect_CFBParameters_PDU, proto_nist_csor, "id-aes256-CFB"); |
163 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.2.17", dissect_ShakeOutputLen_PDU, proto_nist_csor, "id-shake128-len"); |
164 | 15 | register_ber_oid_dissector("2.16.840.1.101.3.4.2.18", dissect_ShakeOutputLen_PDU, proto_nist_csor, "id-shake256-len"); |
165 | | |
166 | 15 | oid_add_from_string("id-data","1.2.840.113549.1.7.1"); |
167 | | |
168 | | /* AES */ |
169 | 15 | oid_add_from_string("aes","2.16.840.1.101.3.4.1"); |
170 | | |
171 | | /* 128-bit AES information OIDs */ |
172 | 15 | oid_add_from_string("id-aes128-ECB","2.16.840.1.101.3.4.1.1"); |
173 | 15 | oid_add_from_string("id-aes128-wrap","2.16.840.1.101.3.4.1.5"); |
174 | 15 | oid_add_from_string("id-aes128-GCM","2.16.840.1.101.3.4.1.6"); |
175 | 15 | oid_add_from_string("id-aes128-CCM","2.16.840.1.101.3.4.1.7"); |
176 | 15 | oid_add_from_string("id-aes128-wrap-pad","2.16.840.1.101.3.4.1.8"); |
177 | | |
178 | | /* 192-bit AES information OIDs */ |
179 | 15 | oid_add_from_string("id-aes192-ECB","2.16.840.1.101.3.4.1.21"); |
180 | 15 | oid_add_from_string("id-aes192-wrap","2.16.840.1.101.3.4.1.25"); |
181 | 15 | oid_add_from_string("id-aes192-GCM","2.16.840.1.101.3.4.1.26"); |
182 | 15 | oid_add_from_string("id-aes192-CCM","2.16.840.1.101.3.4.1.27"); |
183 | 15 | oid_add_from_string("id-aes192-wrap-pad","2.16.840.1.101.3.4.1.28"); |
184 | | |
185 | | /* 256-bit AES information OIDs */ |
186 | 15 | oid_add_from_string("id-aes256-ECB","2.16.840.1.101.3.4.1.41"); |
187 | 15 | oid_add_from_string("id-aes256-wrap","2.16.840.1.101.3.4.1.45"); |
188 | 15 | oid_add_from_string("id-aes256-GCM","2.16.840.1.101.3.4.1.46"); |
189 | 15 | oid_add_from_string("id-aes256-CCM","2.16.840.1.101.3.4.1.47"); |
190 | 15 | oid_add_from_string("id-aes256-wrap-pad","2.16.840.1.101.3.4.1.48"); |
191 | | |
192 | | /* Secure Hash Algorithms */ |
193 | 15 | oid_add_from_string("hashAlgs","2.16.840.1.101.3.4.2"); |
194 | | |
195 | | /* SHA-2 family */ |
196 | 15 | oid_add_from_string("id-sha256","2.16.840.1.101.3.4.2.1"); |
197 | 15 | oid_add_from_string("id-sha384","2.16.840.1.101.3.4.2.2"); |
198 | 15 | oid_add_from_string("id-sha512","2.16.840.1.101.3.4.2.3"); |
199 | 15 | oid_add_from_string("id-sha224","2.16.840.1.101.3.4.2.4"); |
200 | 15 | oid_add_from_string("id-sha512-224","2.16.840.1.101.3.4.2.5"); |
201 | 15 | oid_add_from_string("id-sha512-256","2.16.840.1.101.3.4.2.6"); |
202 | | |
203 | | /* SHA-3 family */ |
204 | 15 | oid_add_from_string("id-sha3-224","2.16.840.1.101.3.4.2.7"); |
205 | 15 | oid_add_from_string("id-sha3-256","2.16.840.1.101.3.4.2.8"); |
206 | 15 | oid_add_from_string("id-sha3-384","2.16.840.1.101.3.4.2.9"); |
207 | 15 | oid_add_from_string("id-sha3-512","2.16.840.1.101.3.4.2.10"); |
208 | | |
209 | 15 | oid_add_from_string("id-shake128","2.16.840.1.101.3.4.2.11"); |
210 | 15 | oid_add_from_string("id-shake256","2.16.840.1.101.3.4.2.12"); |
211 | | |
212 | | /* HMAC with SHA-3 family */ |
213 | 15 | oid_add_from_string("id-hmacWithSHA3-224","2.16.840.1.101.3.4.2.13"); |
214 | 15 | oid_add_from_string("id-hmacWithSHA3-256","2.16.840.1.101.3.4.2.14"); |
215 | 15 | oid_add_from_string("id-hmacWithSHA3-384","2.16.840.1.101.3.4.2.15"); |
216 | 15 | oid_add_from_string("id-hmacWithSHA3-512","2.16.840.1.101.3.4.2.16"); |
217 | | |
218 | | /* Digital Signature Algorithms */ |
219 | 15 | oid_add_from_string("sigAlgs","2.16.840.1.101.3.4.3"); |
220 | | |
221 | | /* DSA with SHA-2 family */ |
222 | 15 | oid_add_from_string("id-dsa-with-sha224","2.16.840.1.101.3.4.3.1"); |
223 | 15 | oid_add_from_string("id-dsa-with-sha256","2.16.840.1.101.3.4.3.2"); |
224 | 15 | oid_add_from_string("id-dsa-with-sha384","2.16.840.1.101.3.4.3.3"); |
225 | 15 | oid_add_from_string("id-dsa-with-sha512","2.16.840.1.101.3.4.3.4"); |
226 | | |
227 | | /* DSA with SHA-3 family */ |
228 | 15 | oid_add_from_string("id-dsa-with-sha3-224","2.16.840.1.101.3.4.3.5"); |
229 | 15 | oid_add_from_string("id-dsa-with-sha3-256","2.16.840.1.101.3.4.3.6"); |
230 | 15 | oid_add_from_string("id-dsa-with-sha3-384","2.16.840.1.101.3.4.3.7"); |
231 | 15 | oid_add_from_string("id-dsa-with-sha3-512","2.16.840.1.101.3.4.3.8"); |
232 | | |
233 | | /* ECDSA with SHA-3 family */ |
234 | 15 | oid_add_from_string("id-ecdsa-with-sha3-224","2.16.840.1.101.3.4.3.9"); |
235 | 15 | oid_add_from_string("id-ecdsa-with-sha3-256","2.16.840.1.101.3.4.3.10"); |
236 | 15 | oid_add_from_string("id-ecdsa-with-sha3-384","2.16.840.1.101.3.4.3.11"); |
237 | 15 | oid_add_from_string("id-ecdsa-with-sha3-512","2.16.840.1.101.3.4.3.12"); |
238 | | |
239 | | /* RSA PKCS#1 v1.5 Signature with SHA-3 family */ |
240 | 15 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-224","2.16.840.1.101.3.4.3.13"); |
241 | 15 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-256","2.16.840.1.101.3.4.3.14"); |
242 | 15 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-384","2.16.840.1.101.3.4.3.15"); |
243 | 15 | oid_add_from_string("id-rsassa-pkcs1-v1_5-with-sha3-512","2.16.840.1.101.3.4.3.16"); |
244 | 15 | } |