Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-pkixtsp.c
blobb9e6085433b710ef012bf611ddd8820031b611ed
1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
3 /* packet-pkixtsp.c */
4 /* asn2wrs.py -b -q -L -p pkixtsp -c ./pkixtsp.cnf -s ./packet-pkixtsp-template -D . -O ../.. PKIXTSP.asn */
6 /* packet-pkixtsp.c
7 * Routines for RFC2634 Extended Security Services packet dissection
8 * Ronnie Sahlberg 2004
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include "config.h"
19 #include <epan/packet.h>
21 #include <epan/asn1.h>
22 #include <wsutil/array.h>
23 #include "packet-ber.h"
24 #include "packet-pkixtsp.h"
25 #include "packet-pkix1explicit.h"
26 #include "packet-pkix1implicit.h"
27 #include "packet-cms.h"
29 #define PNAME "PKIX Time Stamp Protocol"
30 #define PSNAME "PKIXTSP"
31 #define PFNAME "pkixtsp"
33 void proto_register_pkixtsp(void);
34 void proto_reg_handoff_pkixtsp(void);
36 static dissector_handle_t timestamp_reply_handle;
37 static dissector_handle_t timestamp_query_handle;
39 /* Initialize the protocol and registered fields */
40 static int proto_pkixtsp;
41 static int hf_pkixtsp_TimeStampReq_PDU; /* TimeStampReq */
42 static int hf_pkixtsp_TimeStampResp_PDU; /* TimeStampResp */
43 static int hf_pkixtsp_TSTInfo_PDU; /* TSTInfo */
44 static int hf_pkixtsp_SignatureTimeStampToken_PDU; /* SignatureTimeStampToken */
45 static int hf_pkixtsp_version; /* T_version */
46 static int hf_pkixtsp_messageImprint; /* MessageImprint */
47 static int hf_pkixtsp_reqPolicy; /* TSAPolicyId */
48 static int hf_pkixtsp_nonce; /* INTEGER */
49 static int hf_pkixtsp_certReq; /* BOOLEAN */
50 static int hf_pkixtsp_extensions; /* Extensions */
51 static int hf_pkixtsp_hashAlgorithm; /* AlgorithmIdentifier */
52 static int hf_pkixtsp_hashedMessage; /* OCTET_STRING */
53 static int hf_pkixtsp_status; /* PKIStatusInfo */
54 static int hf_pkixtsp_timeStampToken; /* TimeStampToken */
55 static int hf_pkixtsp_pki_status; /* PKIStatus */
56 static int hf_pkixtsp_failInfo; /* PKIFailureInfo */
57 static int hf_pkixtsp_tst_version; /* Tst_version */
58 static int hf_pkixtsp_policy; /* TSAPolicyId */
59 static int hf_pkixtsp_serialNumber; /* INTEGER */
60 static int hf_pkixtsp_genTime; /* GeneralizedTime */
61 static int hf_pkixtsp_accuracy; /* Accuracy */
62 static int hf_pkixtsp_ordering; /* BOOLEAN */
63 static int hf_pkixtsp_tsa; /* GeneralName */
64 static int hf_pkixtsp_seconds; /* INTEGER */
65 static int hf_pkixtsp_millis; /* INTEGER_1_999 */
66 static int hf_pkixtsp_micros; /* INTEGER_1_999 */
67 /* named bits */
68 static int hf_pkixtsp_PKIFailureInfo_badAlg;
69 static int hf_pkixtsp_PKIFailureInfo_spare_bit1;
70 static int hf_pkixtsp_PKIFailureInfo_badRequest;
71 static int hf_pkixtsp_PKIFailureInfo_spare_bit3;
72 static int hf_pkixtsp_PKIFailureInfo_spare_bit4;
73 static int hf_pkixtsp_PKIFailureInfo_badDataFormat;
74 static int hf_pkixtsp_PKIFailureInfo_spare_bit6;
75 static int hf_pkixtsp_PKIFailureInfo_spare_bit7;
76 static int hf_pkixtsp_PKIFailureInfo_spare_bit8;
77 static int hf_pkixtsp_PKIFailureInfo_spare_bit9;
78 static int hf_pkixtsp_PKIFailureInfo_spare_bit10;
79 static int hf_pkixtsp_PKIFailureInfo_spare_bit11;
80 static int hf_pkixtsp_PKIFailureInfo_spare_bit12;
81 static int hf_pkixtsp_PKIFailureInfo_spare_bit13;
82 static int hf_pkixtsp_PKIFailureInfo_timeNotAvailable;
83 static int hf_pkixtsp_PKIFailureInfo_unacceptedPolicy;
84 static int hf_pkixtsp_PKIFailureInfo_unacceptedExtension;
85 static int hf_pkixtsp_PKIFailureInfo_addInfoNotAvailable;
86 static int hf_pkixtsp_PKIFailureInfo_spare_bit18;
87 static int hf_pkixtsp_PKIFailureInfo_spare_bit19;
88 static int hf_pkixtsp_PKIFailureInfo_spare_bit20;
89 static int hf_pkixtsp_PKIFailureInfo_spare_bit21;
90 static int hf_pkixtsp_PKIFailureInfo_spare_bit22;
91 static int hf_pkixtsp_PKIFailureInfo_spare_bit23;
92 static int hf_pkixtsp_PKIFailureInfo_spare_bit24;
93 static int hf_pkixtsp_PKIFailureInfo_systemFailure;
95 /* Initialize the subtree pointers */
96 static int ett_pkixtsp;
97 static int ett_pkixtsp_TimeStampReq;
98 static int ett_pkixtsp_MessageImprint;
99 static int ett_pkixtsp_TimeStampResp;
100 static int ett_pkixtsp_PKIStatusInfo;
101 static int ett_pkixtsp_PKIFailureInfo;
102 static int ett_pkixtsp_TSTInfo;
103 static int ett_pkixtsp_Accuracy;
107 static const value_string pkixtsp_T_version_vals[] = {
108 { 1, "v1" },
109 { 0, NULL }
113 static int
114 dissect_pkixtsp_T_version(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
115 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
116 NULL);
118 return offset;
123 static int
124 dissect_pkixtsp_OCTET_STRING(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
125 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
126 NULL);
128 return offset;
132 static const ber_sequence_t MessageImprint_sequence[] = {
133 { &hf_pkixtsp_hashAlgorithm, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkix1explicit_AlgorithmIdentifier },
134 { &hf_pkixtsp_hashedMessage, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_OCTET_STRING },
135 { NULL, 0, 0, 0, NULL }
138 static int
139 dissect_pkixtsp_MessageImprint(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
140 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
141 MessageImprint_sequence, hf_index, ett_pkixtsp_MessageImprint);
143 return offset;
148 static int
149 dissect_pkixtsp_TSAPolicyId(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
150 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
152 return offset;
157 static int
158 dissect_pkixtsp_INTEGER(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
159 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
160 NULL);
162 return offset;
167 static int
168 dissect_pkixtsp_BOOLEAN(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
169 offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
171 return offset;
175 static const ber_sequence_t TimeStampReq_sequence[] = {
176 { &hf_pkixtsp_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_T_version },
177 { &hf_pkixtsp_messageImprint, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_MessageImprint },
178 { &hf_pkixtsp_reqPolicy , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_TSAPolicyId },
179 { &hf_pkixtsp_nonce , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_INTEGER },
180 { &hf_pkixtsp_certReq , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_BOOLEAN },
181 { &hf_pkixtsp_extensions , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_pkix1explicit_Extensions },
182 { NULL, 0, 0, 0, NULL }
185 static int
186 dissect_pkixtsp_TimeStampReq(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
187 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
188 TimeStampReq_sequence, hf_index, ett_pkixtsp_TimeStampReq);
190 return offset;
194 static const value_string pkixtsp_PKIStatus_vals[] = {
195 { 0, "granted" },
196 { 1, "grantedWithMods" },
197 { 2, "rejection" },
198 { 3, "waiting" },
199 { 4, "revocationWarning" },
200 { 5, "revocationNotification" },
201 { 0, NULL }
205 static int
206 dissect_pkixtsp_PKIStatus(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
207 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
208 NULL);
210 return offset;
214 static int * const PKIFailureInfo_bits[] = {
215 &hf_pkixtsp_PKIFailureInfo_badAlg,
216 &hf_pkixtsp_PKIFailureInfo_spare_bit1,
217 &hf_pkixtsp_PKIFailureInfo_badRequest,
218 &hf_pkixtsp_PKIFailureInfo_spare_bit3,
219 &hf_pkixtsp_PKIFailureInfo_spare_bit4,
220 &hf_pkixtsp_PKIFailureInfo_badDataFormat,
221 &hf_pkixtsp_PKIFailureInfo_spare_bit6,
222 &hf_pkixtsp_PKIFailureInfo_spare_bit7,
223 &hf_pkixtsp_PKIFailureInfo_spare_bit8,
224 &hf_pkixtsp_PKIFailureInfo_spare_bit9,
225 &hf_pkixtsp_PKIFailureInfo_spare_bit10,
226 &hf_pkixtsp_PKIFailureInfo_spare_bit11,
227 &hf_pkixtsp_PKIFailureInfo_spare_bit12,
228 &hf_pkixtsp_PKIFailureInfo_spare_bit13,
229 &hf_pkixtsp_PKIFailureInfo_timeNotAvailable,
230 &hf_pkixtsp_PKIFailureInfo_unacceptedPolicy,
231 &hf_pkixtsp_PKIFailureInfo_unacceptedExtension,
232 &hf_pkixtsp_PKIFailureInfo_addInfoNotAvailable,
233 &hf_pkixtsp_PKIFailureInfo_spare_bit18,
234 &hf_pkixtsp_PKIFailureInfo_spare_bit19,
235 &hf_pkixtsp_PKIFailureInfo_spare_bit20,
236 &hf_pkixtsp_PKIFailureInfo_spare_bit21,
237 &hf_pkixtsp_PKIFailureInfo_spare_bit22,
238 &hf_pkixtsp_PKIFailureInfo_spare_bit23,
239 &hf_pkixtsp_PKIFailureInfo_spare_bit24,
240 &hf_pkixtsp_PKIFailureInfo_systemFailure,
241 NULL
244 static int
245 dissect_pkixtsp_PKIFailureInfo(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
246 offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
247 PKIFailureInfo_bits, 26, hf_index, ett_pkixtsp_PKIFailureInfo,
248 NULL);
250 return offset;
254 static const ber_sequence_t PKIStatusInfo_sequence[] = {
255 { &hf_pkixtsp_pki_status , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_PKIStatus },
256 { &hf_pkixtsp_failInfo , BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_PKIFailureInfo },
257 { NULL, 0, 0, 0, NULL }
260 static int
261 dissect_pkixtsp_PKIStatusInfo(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
262 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
263 PKIStatusInfo_sequence, hf_index, ett_pkixtsp_PKIStatusInfo);
265 return offset;
270 static int
271 dissect_pkixtsp_TimeStampToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
272 offset = dissect_cms_ContentInfo(implicit_tag, tvb, offset, actx, tree, hf_index);
274 return offset;
278 static const ber_sequence_t TimeStampResp_sequence[] = {
279 { &hf_pkixtsp_status , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_PKIStatusInfo },
280 { &hf_pkixtsp_timeStampToken, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_TimeStampToken },
281 { NULL, 0, 0, 0, NULL }
284 static int
285 dissect_pkixtsp_TimeStampResp(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
286 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
287 TimeStampResp_sequence, hf_index, ett_pkixtsp_TimeStampResp);
289 return offset;
293 static const value_string pkixtsp_Tst_version_vals[] = {
294 { 1, "v1" },
295 { 0, NULL }
299 static int
300 dissect_pkixtsp_Tst_version(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
301 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
302 NULL);
304 return offset;
309 static int
310 dissect_pkixtsp_GeneralizedTime(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
311 offset = dissect_ber_GeneralizedTime(implicit_tag, actx, tree, tvb, offset, hf_index);
313 return offset;
318 static int
319 dissect_pkixtsp_INTEGER_1_999(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
320 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
321 NULL);
323 return offset;
327 static const ber_sequence_t Accuracy_sequence[] = {
328 { &hf_pkixtsp_seconds , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_INTEGER },
329 { &hf_pkixtsp_millis , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_pkixtsp_INTEGER_1_999 },
330 { &hf_pkixtsp_micros , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_pkixtsp_INTEGER_1_999 },
331 { NULL, 0, 0, 0, NULL }
334 static int
335 dissect_pkixtsp_Accuracy(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
336 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
337 Accuracy_sequence, hf_index, ett_pkixtsp_Accuracy);
339 return offset;
343 static const ber_sequence_t TSTInfo_sequence[] = {
344 { &hf_pkixtsp_tst_version , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_Tst_version },
345 { &hf_pkixtsp_policy , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_TSAPolicyId },
346 { &hf_pkixtsp_messageImprint, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_MessageImprint },
347 { &hf_pkixtsp_serialNumber, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_INTEGER },
348 { &hf_pkixtsp_genTime , BER_CLASS_UNI, BER_UNI_TAG_GeneralizedTime, BER_FLAGS_NOOWNTAG, dissect_pkixtsp_GeneralizedTime },
349 { &hf_pkixtsp_accuracy , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_Accuracy },
350 { &hf_pkixtsp_ordering , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_BOOLEAN },
351 { &hf_pkixtsp_nonce , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkixtsp_INTEGER },
352 { &hf_pkixtsp_tsa , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_pkix1implicit_GeneralName },
353 { &hf_pkixtsp_extensions , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_pkix1explicit_Extensions },
354 { NULL, 0, 0, 0, NULL }
357 static int
358 dissect_pkixtsp_TSTInfo(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
359 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
360 TSTInfo_sequence, hf_index, ett_pkixtsp_TSTInfo);
362 return offset;
367 static int
368 dissect_pkixtsp_SignatureTimeStampToken(bool implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
369 offset = dissect_pkixtsp_TimeStampToken(implicit_tag, tvb, offset, actx, tree, hf_index);
371 return offset;
374 /*--- PDUs ---*/
376 static int dissect_TimeStampReq_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
377 int offset = 0;
378 asn1_ctx_t asn1_ctx;
379 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
380 offset = dissect_pkixtsp_TimeStampReq(false, tvb, offset, &asn1_ctx, tree, hf_pkixtsp_TimeStampReq_PDU);
381 return offset;
383 static int dissect_TimeStampResp_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
384 int offset = 0;
385 asn1_ctx_t asn1_ctx;
386 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
387 offset = dissect_pkixtsp_TimeStampResp(false, tvb, offset, &asn1_ctx, tree, hf_pkixtsp_TimeStampResp_PDU);
388 return offset;
390 static int dissect_TSTInfo_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
391 int offset = 0;
392 asn1_ctx_t asn1_ctx;
393 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
394 offset = dissect_pkixtsp_TSTInfo(false, tvb, offset, &asn1_ctx, tree, hf_pkixtsp_TSTInfo_PDU);
395 return offset;
397 static int dissect_SignatureTimeStampToken_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
398 int offset = 0;
399 asn1_ctx_t asn1_ctx;
400 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
401 offset = dissect_pkixtsp_SignatureTimeStampToken(false, tvb, offset, &asn1_ctx, tree, hf_pkixtsp_SignatureTimeStampToken_PDU);
402 return offset;
407 static int
408 dissect_timestamp_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
410 proto_item *item=NULL;
411 proto_tree *tree=NULL;
412 asn1_ctx_t asn1_ctx;
413 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
415 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP");
417 col_set_str(pinfo->cinfo, COL_INFO, "Reply");
420 if(parent_tree){
421 item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, ENC_NA);
422 tree = proto_item_add_subtree(item, ett_pkixtsp);
425 return dissect_pkixtsp_TimeStampResp(false, tvb, 0, &asn1_ctx, tree, -1);
428 static int
429 dissect_timestamp_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
431 proto_item *item=NULL;
432 proto_tree *tree=NULL;
433 asn1_ctx_t asn1_ctx;
434 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
436 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP");
438 col_set_str(pinfo->cinfo, COL_INFO, "Query");
441 if(parent_tree){
442 item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, ENC_NA);
443 tree = proto_item_add_subtree(item, ett_pkixtsp);
446 return dissect_pkixtsp_TimeStampReq(false, tvb, 0, &asn1_ctx, tree, -1);
450 /*--- proto_register_pkixtsp ----------------------------------------------*/
451 void proto_register_pkixtsp(void) {
453 /* List of fields */
454 static hf_register_info hf[] = {
455 { &hf_pkixtsp_TimeStampReq_PDU,
456 { "TimeStampReq", "pkixtsp.TimeStampReq_element",
457 FT_NONE, BASE_NONE, NULL, 0,
458 NULL, HFILL }},
459 { &hf_pkixtsp_TimeStampResp_PDU,
460 { "TimeStampResp", "pkixtsp.TimeStampResp_element",
461 FT_NONE, BASE_NONE, NULL, 0,
462 NULL, HFILL }},
463 { &hf_pkixtsp_TSTInfo_PDU,
464 { "TSTInfo", "pkixtsp.TSTInfo_element",
465 FT_NONE, BASE_NONE, NULL, 0,
466 NULL, HFILL }},
467 { &hf_pkixtsp_SignatureTimeStampToken_PDU,
468 { "SignatureTimeStampToken", "pkixtsp.SignatureTimeStampToken_element",
469 FT_NONE, BASE_NONE, NULL, 0,
470 NULL, HFILL }},
471 { &hf_pkixtsp_version,
472 { "version", "pkixtsp.version",
473 FT_INT32, BASE_DEC, VALS(pkixtsp_T_version_vals), 0,
474 NULL, HFILL }},
475 { &hf_pkixtsp_messageImprint,
476 { "messageImprint", "pkixtsp.messageImprint_element",
477 FT_NONE, BASE_NONE, NULL, 0,
478 NULL, HFILL }},
479 { &hf_pkixtsp_reqPolicy,
480 { "reqPolicy", "pkixtsp.reqPolicy",
481 FT_OID, BASE_NONE, NULL, 0,
482 "TSAPolicyId", HFILL }},
483 { &hf_pkixtsp_nonce,
484 { "nonce", "pkixtsp.nonce",
485 FT_INT32, BASE_DEC, NULL, 0,
486 "INTEGER", HFILL }},
487 { &hf_pkixtsp_certReq,
488 { "certReq", "pkixtsp.certReq",
489 FT_BOOLEAN, BASE_NONE, NULL, 0,
490 "BOOLEAN", HFILL }},
491 { &hf_pkixtsp_extensions,
492 { "extensions", "pkixtsp.extensions",
493 FT_UINT32, BASE_DEC, NULL, 0,
494 NULL, HFILL }},
495 { &hf_pkixtsp_hashAlgorithm,
496 { "hashAlgorithm", "pkixtsp.hashAlgorithm_element",
497 FT_NONE, BASE_NONE, NULL, 0,
498 "AlgorithmIdentifier", HFILL }},
499 { &hf_pkixtsp_hashedMessage,
500 { "hashedMessage", "pkixtsp.hashedMessage",
501 FT_BYTES, BASE_NONE, NULL, 0,
502 "OCTET_STRING", HFILL }},
503 { &hf_pkixtsp_status,
504 { "status", "pkixtsp.status_element",
505 FT_NONE, BASE_NONE, NULL, 0,
506 "PKIStatusInfo", HFILL }},
507 { &hf_pkixtsp_timeStampToken,
508 { "timeStampToken", "pkixtsp.timeStampToken_element",
509 FT_NONE, BASE_NONE, NULL, 0,
510 NULL, HFILL }},
511 { &hf_pkixtsp_pki_status,
512 { "status", "pkixtsp.pki_status",
513 FT_INT32, BASE_DEC, VALS(pkixtsp_PKIStatus_vals), 0,
514 "PKIStatus", HFILL }},
515 { &hf_pkixtsp_failInfo,
516 { "failInfo", "pkixtsp.failInfo",
517 FT_BYTES, BASE_NONE, NULL, 0,
518 "PKIFailureInfo", HFILL }},
519 { &hf_pkixtsp_tst_version,
520 { "version", "pkixtsp.tst_version",
521 FT_INT32, BASE_DEC, VALS(pkixtsp_Tst_version_vals), 0,
522 "Tst_version", HFILL }},
523 { &hf_pkixtsp_policy,
524 { "policy", "pkixtsp.policy",
525 FT_OID, BASE_NONE, NULL, 0,
526 "TSAPolicyId", HFILL }},
527 { &hf_pkixtsp_serialNumber,
528 { "serialNumber", "pkixtsp.serialNumber",
529 FT_INT32, BASE_DEC, NULL, 0,
530 "INTEGER", HFILL }},
531 { &hf_pkixtsp_genTime,
532 { "genTime", "pkixtsp.genTime",
533 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0,
534 "GeneralizedTime", HFILL }},
535 { &hf_pkixtsp_accuracy,
536 { "accuracy", "pkixtsp.accuracy_element",
537 FT_NONE, BASE_NONE, NULL, 0,
538 NULL, HFILL }},
539 { &hf_pkixtsp_ordering,
540 { "ordering", "pkixtsp.ordering",
541 FT_BOOLEAN, BASE_NONE, NULL, 0,
542 "BOOLEAN", HFILL }},
543 { &hf_pkixtsp_tsa,
544 { "tsa", "pkixtsp.tsa",
545 FT_UINT32, BASE_DEC, NULL, 0,
546 "GeneralName", HFILL }},
547 { &hf_pkixtsp_seconds,
548 { "seconds", "pkixtsp.seconds",
549 FT_INT32, BASE_DEC, NULL, 0,
550 "INTEGER", HFILL }},
551 { &hf_pkixtsp_millis,
552 { "millis", "pkixtsp.millis",
553 FT_UINT32, BASE_DEC, NULL, 0,
554 "INTEGER_1_999", HFILL }},
555 { &hf_pkixtsp_micros,
556 { "micros", "pkixtsp.micros",
557 FT_UINT32, BASE_DEC, NULL, 0,
558 "INTEGER_1_999", HFILL }},
559 { &hf_pkixtsp_PKIFailureInfo_badAlg,
560 { "badAlg", "pkixtsp.PKIFailureInfo.badAlg",
561 FT_BOOLEAN, 8, NULL, 0x80,
562 NULL, HFILL }},
563 { &hf_pkixtsp_PKIFailureInfo_spare_bit1,
564 { "spare_bit1", "pkixtsp.PKIFailureInfo.spare.bit1",
565 FT_BOOLEAN, 8, NULL, 0x40,
566 NULL, HFILL }},
567 { &hf_pkixtsp_PKIFailureInfo_badRequest,
568 { "badRequest", "pkixtsp.PKIFailureInfo.badRequest",
569 FT_BOOLEAN, 8, NULL, 0x20,
570 NULL, HFILL }},
571 { &hf_pkixtsp_PKIFailureInfo_spare_bit3,
572 { "spare_bit3", "pkixtsp.PKIFailureInfo.spare.bit3",
573 FT_BOOLEAN, 8, NULL, 0x10,
574 NULL, HFILL }},
575 { &hf_pkixtsp_PKIFailureInfo_spare_bit4,
576 { "spare_bit4", "pkixtsp.PKIFailureInfo.spare.bit4",
577 FT_BOOLEAN, 8, NULL, 0x08,
578 NULL, HFILL }},
579 { &hf_pkixtsp_PKIFailureInfo_badDataFormat,
580 { "badDataFormat", "pkixtsp.PKIFailureInfo.badDataFormat",
581 FT_BOOLEAN, 8, NULL, 0x04,
582 NULL, HFILL }},
583 { &hf_pkixtsp_PKIFailureInfo_spare_bit6,
584 { "spare_bit6", "pkixtsp.PKIFailureInfo.spare.bit6",
585 FT_BOOLEAN, 8, NULL, 0x02,
586 NULL, HFILL }},
587 { &hf_pkixtsp_PKIFailureInfo_spare_bit7,
588 { "spare_bit7", "pkixtsp.PKIFailureInfo.spare.bit7",
589 FT_BOOLEAN, 8, NULL, 0x01,
590 NULL, HFILL }},
591 { &hf_pkixtsp_PKIFailureInfo_spare_bit8,
592 { "spare_bit8", "pkixtsp.PKIFailureInfo.spare.bit8",
593 FT_BOOLEAN, 8, NULL, 0x80,
594 NULL, HFILL }},
595 { &hf_pkixtsp_PKIFailureInfo_spare_bit9,
596 { "spare_bit9", "pkixtsp.PKIFailureInfo.spare.bit9",
597 FT_BOOLEAN, 8, NULL, 0x40,
598 NULL, HFILL }},
599 { &hf_pkixtsp_PKIFailureInfo_spare_bit10,
600 { "spare_bit10", "pkixtsp.PKIFailureInfo.spare.bit10",
601 FT_BOOLEAN, 8, NULL, 0x20,
602 NULL, HFILL }},
603 { &hf_pkixtsp_PKIFailureInfo_spare_bit11,
604 { "spare_bit11", "pkixtsp.PKIFailureInfo.spare.bit11",
605 FT_BOOLEAN, 8, NULL, 0x10,
606 NULL, HFILL }},
607 { &hf_pkixtsp_PKIFailureInfo_spare_bit12,
608 { "spare_bit12", "pkixtsp.PKIFailureInfo.spare.bit12",
609 FT_BOOLEAN, 8, NULL, 0x08,
610 NULL, HFILL }},
611 { &hf_pkixtsp_PKIFailureInfo_spare_bit13,
612 { "spare_bit13", "pkixtsp.PKIFailureInfo.spare.bit13",
613 FT_BOOLEAN, 8, NULL, 0x04,
614 NULL, HFILL }},
615 { &hf_pkixtsp_PKIFailureInfo_timeNotAvailable,
616 { "timeNotAvailable", "pkixtsp.PKIFailureInfo.timeNotAvailable",
617 FT_BOOLEAN, 8, NULL, 0x02,
618 NULL, HFILL }},
619 { &hf_pkixtsp_PKIFailureInfo_unacceptedPolicy,
620 { "unacceptedPolicy", "pkixtsp.PKIFailureInfo.unacceptedPolicy",
621 FT_BOOLEAN, 8, NULL, 0x01,
622 NULL, HFILL }},
623 { &hf_pkixtsp_PKIFailureInfo_unacceptedExtension,
624 { "unacceptedExtension", "pkixtsp.PKIFailureInfo.unacceptedExtension",
625 FT_BOOLEAN, 8, NULL, 0x80,
626 NULL, HFILL }},
627 { &hf_pkixtsp_PKIFailureInfo_addInfoNotAvailable,
628 { "addInfoNotAvailable", "pkixtsp.PKIFailureInfo.addInfoNotAvailable",
629 FT_BOOLEAN, 8, NULL, 0x40,
630 NULL, HFILL }},
631 { &hf_pkixtsp_PKIFailureInfo_spare_bit18,
632 { "spare_bit18", "pkixtsp.PKIFailureInfo.spare.bit18",
633 FT_BOOLEAN, 8, NULL, 0x20,
634 NULL, HFILL }},
635 { &hf_pkixtsp_PKIFailureInfo_spare_bit19,
636 { "spare_bit19", "pkixtsp.PKIFailureInfo.spare.bit19",
637 FT_BOOLEAN, 8, NULL, 0x10,
638 NULL, HFILL }},
639 { &hf_pkixtsp_PKIFailureInfo_spare_bit20,
640 { "spare_bit20", "pkixtsp.PKIFailureInfo.spare.bit20",
641 FT_BOOLEAN, 8, NULL, 0x08,
642 NULL, HFILL }},
643 { &hf_pkixtsp_PKIFailureInfo_spare_bit21,
644 { "spare_bit21", "pkixtsp.PKIFailureInfo.spare.bit21",
645 FT_BOOLEAN, 8, NULL, 0x04,
646 NULL, HFILL }},
647 { &hf_pkixtsp_PKIFailureInfo_spare_bit22,
648 { "spare_bit22", "pkixtsp.PKIFailureInfo.spare.bit22",
649 FT_BOOLEAN, 8, NULL, 0x02,
650 NULL, HFILL }},
651 { &hf_pkixtsp_PKIFailureInfo_spare_bit23,
652 { "spare_bit23", "pkixtsp.PKIFailureInfo.spare.bit23",
653 FT_BOOLEAN, 8, NULL, 0x01,
654 NULL, HFILL }},
655 { &hf_pkixtsp_PKIFailureInfo_spare_bit24,
656 { "spare_bit24", "pkixtsp.PKIFailureInfo.spare.bit24",
657 FT_BOOLEAN, 8, NULL, 0x80,
658 NULL, HFILL }},
659 { &hf_pkixtsp_PKIFailureInfo_systemFailure,
660 { "systemFailure", "pkixtsp.PKIFailureInfo.systemFailure",
661 FT_BOOLEAN, 8, NULL, 0x40,
662 NULL, HFILL }},
665 /* List of subtrees */
666 static int *ett[] = {
667 &ett_pkixtsp,
668 &ett_pkixtsp_TimeStampReq,
669 &ett_pkixtsp_MessageImprint,
670 &ett_pkixtsp_TimeStampResp,
671 &ett_pkixtsp_PKIStatusInfo,
672 &ett_pkixtsp_PKIFailureInfo,
673 &ett_pkixtsp_TSTInfo,
674 &ett_pkixtsp_Accuracy,
677 /* Register protocol */
678 proto_pkixtsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
680 /* Register fields and subtrees */
681 proto_register_field_array(proto_pkixtsp, hf, array_length(hf));
682 proto_register_subtree_array(ett, array_length(ett));
684 timestamp_reply_handle = register_dissector(PFNAME "_reply", dissect_timestamp_reply, proto_pkixtsp);
685 timestamp_query_handle = register_dissector(PFNAME "_query", dissect_timestamp_query, proto_pkixtsp);
687 register_ber_syntax_dissector("TimeStampReq", proto_pkixtsp, dissect_TimeStampReq_PDU);
688 register_ber_syntax_dissector("TimeStampResp", proto_pkixtsp, dissect_TimeStampResp_PDU);
690 register_ber_oid_syntax(".tsq", NULL, "TimeStampReq");
691 register_ber_oid_syntax(".tsr", NULL, "TimeStampResp");
695 /*--- proto_reg_handoff_pkixtsp -------------------------------------------*/
696 void proto_reg_handoff_pkixtsp(void) {
697 dissector_add_string("media_type", "application/timestamp-reply", timestamp_reply_handle);
698 dissector_add_string("media_type", "application/timestamp-query", timestamp_query_handle);
700 register_ber_oid_dissector("1.2.840.113549.1.9.16.2.14", dissect_SignatureTimeStampToken_PDU, proto_pkixtsp, "id-aa-timeStampToken");
701 register_ber_oid_dissector("1.2.840.113549.1.9.16.1.4", dissect_TSTInfo_PDU, proto_pkixtsp, "id-ct-TSTInfo");