summaryrefslogtreecommitdiffstats
path: root/signature.c
diff options
context:
space:
mode:
Diffstat (limited to 'signature.c')
-rw-r--r--signature.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/signature.c b/signature.c
index c55645f..324035f 100644
--- a/signature.c
+++ b/signature.c
@@ -1,4 +1,4 @@
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -11,15 +11,11 @@
* FOR A PARTICULAR PURPOSE.
*
* Functions for signature and digest verification.
- *
+ *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/signature.c,v 1.2 2008-09-22 20:22:10 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -48,9 +44,10 @@ const struct tok signature_check_values[] = {
* Compute a HMAC MD5 sum.
* Taken from rfc2104, Appendix.
*/
+USES_APPLE_DEPRECATED_API
static void
-signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *key,
- unsigned int key_len, u_int8_t *digest)
+signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key,
+ unsigned int key_len, uint8_t *digest)
{
MD5_CTX context;
unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */
@@ -110,6 +107,7 @@ signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *ke
MD5_Update(&context, digest, 16); /* then results of 1st hash */
MD5_Final(digest, &context); /* finish up 2nd pass */
}
+USES_APPLE_RST
#endif
#ifdef HAVE_LIBCRYPTO
@@ -118,10 +116,11 @@ signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *ke
* Currently only MD5 is supported.
*/
int
-signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
+signature_verify(netdissect_options *ndo,
+ const u_char *pptr, u_int plen, u_char *sig_ptr)
{
- u_int8_t rcvsig[16];
- u_int8_t sig[16];
+ uint8_t rcvsig[16];
+ uint8_t sig[16];
unsigned int i;
/*
@@ -130,12 +129,12 @@ signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
memcpy(rcvsig, sig_ptr, sizeof(rcvsig));
memset(sig_ptr, 0, sizeof(rcvsig));
- if (!sigsecret) {
+ if (!ndo->ndo_sigsecret) {
return (CANT_CHECK_SIGNATURE);
}
- signature_compute_hmac_md5(pptr, plen, (unsigned char *)sigsecret,
- strlen(sigsecret), sig);
+ signature_compute_hmac_md5(pptr, plen, (unsigned char *)ndo->ndo_sigsecret,
+ strlen(ndo->ndo_sigsecret), sig);
if (memcmp(rcvsig, sig, sizeof(sig)) == 0) {
return (SIGNATURE_VALID);
@@ -143,7 +142,7 @@ signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
} else {
for (i = 0; i < sizeof(sig); ++i) {
- (void)printf("%02x", sig[i]);
+ ND_PRINT((ndo, "%02x", sig[i]));
}
return (SIGNATURE_INVALID);
OpenPOWER on IntegriCloud