aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cms.c
diff options
context:
space:
mode:
authorErik de Jong <erikdejong@gmail.com>2017-02-13 19:31:26 +0100
committerPeter Wu <peter@lekensteyn.nl>2017-03-02 23:58:05 +0000
commitf1c75cf6ef7e9f9de1ec7fd798df941b972ec71c (patch)
tree7d7c2f66bf7595e010026d6f4d3b3a53175af824 /epan/dissectors/packet-cms.c
parent4bd3c4d44ddcdf8e98fdf08a425e3a68e9b18395 (diff)
Rewrite dissectors to use Libgcrypt functions.
As discussed on the mailinglist, rewriting dissectors to use Libgcrypt functions as Libgcrypt will be mandatory after change 20030. Removal of following functions: - crypt_md4 - crypt_rc4* - aes_cmac_encrypt_* - md5_* - sha1_* - sha256_* Further candidates: - aes_* - rijndael_* - ... Added functions: - ws_hmac_buffer Added const macros: - HASH_MD5_LENGTH - HASH_SHA1_LENGTH Changes on epan/crypt/* verified with captures from https://wiki.wireshark.org/HowToDecrypt802.11 Changes on packet-snmp.c and packet-radius.c verified with captures from https://wiki.wireshark.org/SampleCapture Changes on packet-tacacs.c verified with capture from http://ccie-in-3-months.blogspot.nl/2009/04/decoding-login-credentials-regardless.html Change-Id: Iea6ba2bf207cf0f1bf2117068fb1abcfeaafaa46 Link: https://www.wireshark.org/lists/wireshark-dev/201702/msg00011.html Reviewed-on: https://code.wireshark.org/review/20095 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/dissectors/packet-cms.c')
-rw-r--r--epan/dissectors/packet-cms.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/epan/dissectors/packet-cms.c b/epan/dissectors/packet-cms.c
index aafa52e46c..3cbdbe5c9d 100644
--- a/epan/dissectors/packet-cms.c
+++ b/epan/dissectors/packet-cms.c
@@ -35,8 +35,7 @@
#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
-#include <wsutil/sha1.h>
-#include <wsutil/md5.h>
+#include <wsutil/wsgcrypt.h>
#include "packet-ber.h"
#include "packet-cms.h"
@@ -184,7 +183,7 @@ static int hf_cms_issuerUniqueID = -1; /* UniqueIdentifier */
static int hf_cms_extensions = -1; /* Extensions */
/*--- End of included file: packet-cms-hf.c ---*/
-#line 52 "./asn1/cms/packet-cms-template.c"
+#line 51 "./asn1/cms/packet-cms-template.c"
/* Initialize the subtree pointers */
@@ -247,7 +246,7 @@ static gint ett_cms_T_subject = -1;
static gint ett_cms_SEQUENCE_OF_Attribute = -1;
/*--- End of included file: packet-cms-ett.c ---*/
-#line 55 "./asn1/cms/packet-cms-template.c"
+#line 54 "./asn1/cms/packet-cms-template.c"
static int dissect_cms_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) ; /* XXX kill a compiler warning until asn2wrs stops generating these silly wrappers */
@@ -261,7 +260,6 @@ static proto_tree *cap_tree=NULL;
#define HASH_SHA1 "1.3.14.3.2.26"
#define HASH_MD5 "1.2.840.113549.2.5"
-#define MD5_BUFFER_SIZE 16
/* SHA-2 variants */
@@ -270,39 +268,23 @@ static proto_tree *cap_tree=NULL;
#define HASH_SHA256 "2.16.840.1.101.3.4.2.1"
#define SHA256_BUFFER_SIZE 32
-unsigned char digest_buf[MAX(SHA1_DIGEST_LEN, MD5_BUFFER_SIZE)];
+unsigned char digest_buf[MAX(HASH_SHA1_LENGTH, HASH_MD5_LENGTH)];
static void
cms_verify_msg_digest(proto_item *pi, tvbuff_t *content, const char *alg, tvbuff_t *tvb, int offset)
{
- sha1_context sha1_ctx;
- md5_state_t md5_ctx;
int i= 0, buffer_size = 0;
/* we only support two algorithms at the moment - if we do add SHA2
we should add a registration process to use a registration process */
if(strcmp(alg, HASH_SHA1) == 0) {
-
- sha1_starts(&sha1_ctx);
-
- sha1_update(&sha1_ctx, tvb_get_ptr(content, 0, tvb_captured_length(content)),
- tvb_captured_length(content));
-
- sha1_finish(&sha1_ctx, digest_buf);
-
- buffer_size = SHA1_DIGEST_LEN;
+ gcry_md_hash_buffer(GCRY_MD_SHA1, digest_buf, tvb_get_ptr(content, 0, tvb_captured_length(content)), tvb_captured_length(content));
+ buffer_size = HASH_SHA1_LENGTH;
} else if(strcmp(alg, HASH_MD5) == 0) {
-
- md5_init(&md5_ctx);
-
- md5_append(&md5_ctx, tvb_get_ptr(content, 0, tvb_captured_length(content)),
- tvb_captured_length(content));
-
- md5_finish(&md5_ctx, digest_buf);
-
- buffer_size = MD5_BUFFER_SIZE;
+ gcry_md_hash_buffer(GCRY_MD_MD5, digest_buf, tvb_get_ptr(content, 0, tvb_captured_length(content)), tvb_captured_length(content));
+ buffer_size = HASH_MD5_LENGTH;
}
if(buffer_size) {
@@ -1868,7 +1850,7 @@ static int dissect_RC2CBCParameters_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U
/*--- End of included file: packet-cms-fn.c ---*/
-#line 132 "./asn1/cms/packet-cms-template.c"
+#line 114 "./asn1/cms/packet-cms-template.c"
/*--- proto_register_cms ----------------------------------------------*/
void proto_register_cms(void) {
@@ -2376,7 +2358,7 @@ void proto_register_cms(void) {
NULL, HFILL }},
/*--- End of included file: packet-cms-hfarr.c ---*/
-#line 143 "./asn1/cms/packet-cms-template.c"
+#line 125 "./asn1/cms/packet-cms-template.c"
};
/* List of subtrees */
@@ -2441,7 +2423,7 @@ void proto_register_cms(void) {
&ett_cms_SEQUENCE_OF_Attribute,
/*--- End of included file: packet-cms-ettarr.c ---*/
-#line 148 "./asn1/cms/packet-cms-template.c"
+#line 130 "./asn1/cms/packet-cms-template.c"
};
/* Register protocol */
@@ -2488,7 +2470,7 @@ void proto_reg_handoff_cms(void) {
/*--- End of included file: packet-cms-dis-tab.c ---*/
-#line 171 "./asn1/cms/packet-cms-template.c"
+#line 153 "./asn1/cms/packet-cms-template.c"
oid_add_from_string("id-data","1.2.840.113549.1.7.1");
oid_add_from_string("id-alg-des-ede3-cbc","1.2.840.113549.3.7");