diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /epan/dissectors/asn1/pkixtsp | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/asn1/pkixtsp')
-rw-r--r-- | epan/dissectors/asn1/pkixtsp/CMakeLists.txt | 39 | ||||
-rw-r--r-- | epan/dissectors/asn1/pkixtsp/PKIXTSP.asn | 184 | ||||
-rw-r--r-- | epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.c | 127 | ||||
-rw-r--r-- | epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.h | 18 | ||||
-rw-r--r-- | epan/dissectors/asn1/pkixtsp/pkixtsp.cnf | 32 |
5 files changed, 400 insertions, 0 deletions
diff --git a/epan/dissectors/asn1/pkixtsp/CMakeLists.txt b/epan/dissectors/asn1/pkixtsp/CMakeLists.txt new file mode 100644 index 00000000..a7899b25 --- /dev/null +++ b/epan/dissectors/asn1/pkixtsp/CMakeLists.txt @@ -0,0 +1,39 @@ +# CMakeLists.txt +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# SPDX-License-Identifier: GPL-2.0-or-later +# + +set( PROTOCOL_NAME pkixtsp ) + +set( PROTO_OPT ) + +set( EXT_ASN_FILE_LIST +) + +set( ASN_FILE_LIST + PKIXTSP.asn +) + +set( EXTRA_DIST + ${ASN_FILE_LIST} + packet-${PROTOCOL_NAME}-template.c + packet-${PROTOCOL_NAME}-template.h + ${PROTOCOL_NAME}.cnf +) + +set( SRC_FILES + ${EXTRA_DIST} + ${EXT_ASN_FILE_LIST} +) + +set( A2W_FLAGS -b ) + +set( EXTRA_CNF + "${CMAKE_CURRENT_BINARY_DIR}/../cms/cms-exp.cnf" +) + +ASN2WRS() diff --git a/epan/dissectors/asn1/pkixtsp/PKIXTSP.asn b/epan/dissectors/asn1/pkixtsp/PKIXTSP.asn new file mode 100644 index 00000000..d4f97d69 --- /dev/null +++ b/epan/dissectors/asn1/pkixtsp/PKIXTSP.asn @@ -0,0 +1,184 @@ +-- This ASN.1 definition defined the Time-Stamp Protocol +-- as of RFC3161. +-- This definition is taken from RFC3161 and modified to pass through +-- the asn2wrs compiler. +-- +-- Copyright statement of the original ASN.1 definition of RFC3161 as follows +-- +-- +-- Full Copyright Statement +-- +-- Copyright (C) The Internet Society (2001). All Rights Reserved. +-- +-- This document and translations of it may be copied and furnished to +-- others, and derivative works that comment on or otherwise explain it +-- or assist in its implementation may be prepared, copied, published +-- and distributed, in whole or in part, without restriction of any +-- kind, provided that the above copyright notice and this paragraph are +-- included on all such copies and derivative works. However, this +-- document itself may not be modified in any way, such as by removing +-- the copyright notice or references to the Internet Society or other +-- Internet organizations, except as needed for the purpose of +-- developing Internet standards in which case the procedures for +-- copyrights defined in the Internet Standards process must be +-- followed, or as required to translate it into languages other than +-- English. +-- +-- The limited permissions granted above are perpetual and will not be +-- revoked by the Internet Society or its successors or assigns. +-- +-- This document and the information contained herein is provided on an +-- "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING +-- TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING +-- BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION +-- HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF +-- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +PKIXTSP {iso(1) identified-organization(3) dod(6) internet(1) + security(5) mechanisms(5) pkix(7) id-mod(0) id-mod-tsp(13)} + +DEFINITIONS IMPLICIT TAGS ::= + +BEGIN + +-- EXPORTS ALL -- + +IMPORTS + + Extensions, AlgorithmIdentifier + FROM PKIX1Explicit88 {iso(1) identified-organization(3) + dod(6) internet(1) security(5) mechanisms(5) pkix(7) + id-mod(0) id-pkix1-explicit-88(1)} + + GeneralName FROM PKIX1Implicit88 {iso(1) + identified-organization(3) dod(6) internet(1) security(5) + mechanisms(5) pkix(7) id-mod(0) id-pkix1-implicit-88(2)} + + ContentInfo FROM CryptographicMessageSyntax {iso(1) + member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9) + smime(16) modules(0) cms(1)} + + PKIFreeText FROM PKIXCMP {iso(1) identified-organization(3) + dod(6) internet(1) security(5) mechanisms(5) pkix(7) id-mod(0) + id-mod-cmp(9)} ; + + -- Locally defined OIDs -- + +-- eContentType for a time-stamp token + +-- id-ct-TSTInfo OBJECT IDENTIFIER ::= { iso(1) member-body(2) +-- us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) ct(1) 4} + +-- 2.4.1 + +TimeStampReq ::= SEQUENCE { + version INTEGER { v1(1) }, + messageImprint MessageImprint, + --a hash algorithm OID and the hash value of the data to be + --time-stamped + reqPolicy TSAPolicyId OPTIONAL, + nonce INTEGER OPTIONAL, + certReq BOOLEAN DEFAULT FALSE, + extensions [0] IMPLICIT Extensions OPTIONAL } + +MessageImprint ::= SEQUENCE { + hashAlgorithm AlgorithmIdentifier, + hashedMessage OCTET STRING } + +TSAPolicyId ::= OBJECT IDENTIFIER + + +-- 2.4.2 + +TimeStampResp ::= SEQUENCE { + status PKIStatusInfo, + timeStampToken TimeStampToken OPTIONAL } + +-- The status is based on the definition of status +-- in section 3.2.3 of [RFC2510] + +PKIStatusInfo ::= SEQUENCE { + status PKIStatus, +--XXX dont implement PKIXCMP yet +-- statusString PKIFreeText OPTIONAL, + failInfo PKIFailureInfo OPTIONAL } + +PKIStatus ::= INTEGER { + granted (0), + -- when the PKIStatus contains the value zero a TimeStampToken, as + -- requested, is present. + grantedWithMods (1), + -- when the PKIStatus contains the value one a TimeStampToken, + -- with modifications, is present. + rejection (2), + waiting (3), + revocationWarning (4), + -- this message contains a warning that a revocation is + -- imminent + revocationNotification (5) + -- notification that a revocation has occurred +} + + -- When the TimeStampToken is not present + -- failInfo indicates the reason why the + -- time-stamp request was rejected and + -- may be one of the following values. + +PKIFailureInfo ::= BIT STRING { + badAlg (0), + -- unrecognized or unsupported Algorithm Identifier + badRequest (2), + -- transaction not permitted or supported + badDataFormat (5), + -- the data submitted has the wrong format + timeNotAvailable (14), + -- the TSA's time source is not available + unacceptedPolicy (15), + -- the requested TSA policy is not supported by the TSA. + unacceptedExtension (16), + -- the requested extension is not supported by the TSA. + addInfoNotAvailable (17), + -- the additional information requested could not be understood + -- or is not available + systemFailure (25) + -- the request cannot be handled due to system failure +} + +TimeStampToken ::= ContentInfo + + -- contentType is id-signedData as defined in [CMS] + -- content is SignedData as defined in([CMS]) + -- eContentType within SignedData is id-ct-TSTInfo + -- eContent within SignedData is TSTInfo + +TSTInfo ::= SEQUENCE { + version INTEGER { v1(1) }, + policy TSAPolicyId, + messageImprint MessageImprint, + -- MUST have the same value as the similar field in + -- TimeStampReq + serialNumber INTEGER, + -- Time-Stamping users MUST be ready to accommodate integers + -- up to 160 bits. + genTime GeneralizedTime, + accuracy Accuracy OPTIONAL, + ordering BOOLEAN DEFAULT FALSE, + nonce INTEGER OPTIONAL, + -- MUST be present if the similar field was present + -- in TimeStampReq. In that case it MUST have the same value. + tsa [0] GeneralName OPTIONAL, + extensions [1] IMPLICIT Extensions OPTIONAL } + +Accuracy ::= SEQUENCE { + seconds INTEGER OPTIONAL, + millis [0] INTEGER (1..999) OPTIONAL, + micros [1] INTEGER (1..999) OPTIONAL } + +-- from Appendix A + +id-aa-timeStampToken OBJECT IDENTIFIER ::= { iso(1) member-body(2) + us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) aa(2) 14 } + +SignatureTimeStampToken ::= TimeStampToken + +END diff --git a/epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.c b/epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.c new file mode 100644 index 00000000..319e91d9 --- /dev/null +++ b/epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.c @@ -0,0 +1,127 @@ +/* packet-pkixtsp.c + * Routines for RFC2634 Extended Security Services packet dissection + * Ronnie Sahlberg 2004 + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" + +#include <epan/packet.h> + +#include <epan/asn1.h> +#include "packet-ber.h" +#include "packet-pkixtsp.h" +#include "packet-pkix1explicit.h" +#include "packet-pkix1implicit.h" +#include "packet-cms.h" + +#define PNAME "PKIX Time Stamp Protocol" +#define PSNAME "PKIXTSP" +#define PFNAME "pkixtsp" + +void proto_register_pkixtsp(void); +void proto_reg_handoff_pkixtsp(void); + +static dissector_handle_t timestamp_reply_handle; +static dissector_handle_t timestamp_query_handle; + +/* Initialize the protocol and registered fields */ +static int proto_pkixtsp = -1; +#include "packet-pkixtsp-hf.c" + +/* Initialize the subtree pointers */ +static gint ett_pkixtsp = -1; +#include "packet-pkixtsp-ett.c" + + +#include "packet-pkixtsp-fn.c" + + +static int +dissect_timestamp_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_) +{ + proto_item *item=NULL; + proto_tree *tree=NULL; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP"); + + col_set_str(pinfo->cinfo, COL_INFO, "Reply"); + + + if(parent_tree){ + item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_pkixtsp); + } + + return dissect_pkixtsp_TimeStampResp(FALSE, tvb, 0, &asn1_ctx, tree, -1); +} + +static int +dissect_timestamp_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_) +{ + proto_item *item=NULL; + proto_tree *tree=NULL; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "PKIXTSP"); + + col_set_str(pinfo->cinfo, COL_INFO, "Query"); + + + if(parent_tree){ + item=proto_tree_add_item(parent_tree, proto_pkixtsp, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_pkixtsp); + } + + return dissect_pkixtsp_TimeStampReq(FALSE, tvb, 0, &asn1_ctx, tree, -1); +} + + +/*--- proto_register_pkixtsp ----------------------------------------------*/ +void proto_register_pkixtsp(void) { + + /* List of fields */ + static hf_register_info hf[] = { +#include "packet-pkixtsp-hfarr.c" + }; + + /* List of subtrees */ + static gint *ett[] = { + &ett_pkixtsp, +#include "packet-pkixtsp-ettarr.c" + }; + + /* Register protocol */ + proto_pkixtsp = proto_register_protocol(PNAME, PSNAME, PFNAME); + + /* Register fields and subtrees */ + proto_register_field_array(proto_pkixtsp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + timestamp_reply_handle = register_dissector(PFNAME "_reply", dissect_timestamp_reply, proto_pkixtsp); + timestamp_query_handle = register_dissector(PFNAME "_query", dissect_timestamp_query, proto_pkixtsp); + + register_ber_syntax_dissector("TimeStampReq", proto_pkixtsp, dissect_TimeStampReq_PDU); + register_ber_syntax_dissector("TimeStampResp", proto_pkixtsp, dissect_TimeStampResp_PDU); + + register_ber_oid_syntax(".tsq", NULL, "TimeStampReq"); + register_ber_oid_syntax(".tsr", NULL, "TimeStampResp"); +} + + +/*--- proto_reg_handoff_pkixtsp -------------------------------------------*/ +void proto_reg_handoff_pkixtsp(void) { + dissector_add_string("media_type", "application/timestamp-reply", timestamp_reply_handle); + dissector_add_string("media_type", "application/timestamp-query", timestamp_query_handle); + +#include "packet-pkixtsp-dis-tab.c" +} + diff --git a/epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.h b/epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.h new file mode 100644 index 00000000..5d6d47a3 --- /dev/null +++ b/epan/dissectors/asn1/pkixtsp/packet-pkixtsp-template.h @@ -0,0 +1,18 @@ +/* packet-pkixtsp.h + * Routines for RFC3161 Time-Stamp Protocol packet dissection + * Ronnie Sahlberg 2004 + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PACKET_PKIXTSP_H +#define PACKET_PKIXTSP_H + +/*#include "packet-pkixtsp-exp.h"*/ + +#endif /* PACKET_PKIXTSP_H */ + diff --git a/epan/dissectors/asn1/pkixtsp/pkixtsp.cnf b/epan/dissectors/asn1/pkixtsp/pkixtsp.cnf new file mode 100644 index 00000000..5d9a8cac --- /dev/null +++ b/epan/dissectors/asn1/pkixtsp/pkixtsp.cnf @@ -0,0 +1,32 @@ +# pkixtsp.cnf +# Time-Stamp Protocol (RFC3161) conformation file + +#.MODULE_IMPORT +PKIX1Explicit88 pkix1explicit +PKIX1Implicit88 pkix1implicit + +#.INCLUDE ../pkix1explicit/pkix1explicit_exp.cnf +#.INCLUDE ../pkix1implicit/pkix1implicit_exp.cnf +#.IMPORT ../cms/cms-exp.cnf + +#.EXPORTS + +#.PDU +TimeStampReq +TimeStampResp + +#.NO_EMIT + +#.TYPE_RENAME +TSTInfo/version Tst_version + +#.FIELD_RENAME +PKIStatusInfo/status pki_status +TSTInfo/version tst_version + +#.REGISTER +SignatureTimeStampToken B "1.2.840.113549.1.9.16.2.14" "id-aa-timeStampToken" +TSTInfo B "1.2.840.113549.1.9.16.1.4" "id-ct-TSTInfo" + +#.END + |