New protocol: PKCS#1 (rfc2313 pplus some extra oid's)
[obnox/wireshark/wip.git] / asn1 / pkcs1 / packet-pkcs1-template.c
1 /* packet-pkcs1.c
2  * Routines for PKCS#1/RFC2313 packet dissection
3  *
4  * $Id: packet-pkcs1-template.c,v 1.2 2004/05/25 21:07:43 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <glib.h>
30 #include <epan/packet.h>
31 #include <epan/conversation.h>
32
33 #include <stdio.h>
34 #include <string.h>
35
36 #include "packet-ber.h"
37 #include "packet-x509af.h"
38
39 #define PNAME  "PKCS#1"
40 #define PSNAME "PKCS-1"
41 #define PFNAME "pkcs-1"
42
43 /* Initialize the protocol and registered fields */
44 static int proto_pkcs1 = -1;
45 #include "packet-pkcs1-hf.c"
46
47 /* Initialize the subtree pointers */
48 #include "packet-pkcs1-ett.c"
49
50 #include "packet-pkcs1-fn.c"
51
52 /*--- proto_register_pkcs1 ----------------------------------------------*/
53 void proto_register_pkcs1(void) {
54
55   /* List of fields */
56   static hf_register_info hf[] = {
57 #include "packet-pkcs1-hfarr.c"
58   };
59
60   /* List of subtrees */
61   static gint *ett[] = {
62 #include "packet-pkcs1-ettarr.c"
63   };
64
65   /* Register protocol */
66   proto_pkcs1 = proto_register_protocol(PNAME, PSNAME, PFNAME);
67
68   /* Register fields and subtrees */
69   proto_register_field_array(proto_pkcs1, hf, array_length(hf));
70   proto_register_subtree_array(ett, array_length(ett));
71
72 }
73
74
75 /*--- proto_reg_handoff_pkcs1 -------------------------------------------*/
76 void proto_reg_handoff_pkcs1(void) {
77         register_ber_oid_dissector("1.2.840.113549.2.2", dissect_ber_oid_NULL_callback, proto_pkcs1, "md2");
78         register_ber_oid_dissector("1.2.840.113549.2.4", dissect_ber_oid_NULL_callback, proto_pkcs1, "md4");
79         register_ber_oid_dissector("1.2.840.113549.2.5", dissect_ber_oid_NULL_callback, proto_pkcs1, "md5");
80
81         register_ber_oid_dissector("1.2.840.113549.1.1.1", dissect_ber_oid_NULL_callback, proto_pkcs1, "rsaEncryption");
82         register_ber_oid_dissector("1.2.840.113549.1.1.2", dissect_ber_oid_NULL_callback, proto_pkcs1, "md2WithRSAEncryption");
83         register_ber_oid_dissector("1.2.840.113549.1.1.3", dissect_ber_oid_NULL_callback, proto_pkcs1, "md4WithRSAEncryption");
84         register_ber_oid_dissector("1.2.840.113549.1.1.4", dissect_ber_oid_NULL_callback, proto_pkcs1, "md5WithRSAEncryption");
85
86
87         /* these two are not from RFC2313  but pulled in from
88            http://www.alvestrand.no/objectid/1.2.840.113549.1.1.html
89         */
90         register_ber_oid_dissector("1.2.840.113549.1.1.5", dissect_ber_oid_NULL_callback, proto_pkcs1, "shaWithRSAEncryption");
91         register_ber_oid_dissector("1.2.840.113549.1.1.6", dissect_ber_oid_NULL_callback, proto_pkcs1, "rsaOAEPEncryptionSET");
92 }
93