Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/npf/npfctl use sha1 from libc



details:   https://anonhg.NetBSD.org/src/rev/580ed789d7a7
branches:  trunk
changeset: 346163:580ed789d7a7
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jun 29 21:40:20 2016 +0000

description:
use sha1 from libc

diffstat:

 usr.sbin/npf/npfctl/npfctl.c |  22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (58 lines):

diff -r 64ae31096d11 -r 580ed789d7a7 usr.sbin/npf/npfctl/npfctl.c
--- a/usr.sbin/npf/npfctl/npfctl.c      Wed Jun 29 21:40:10 2016 +0000
+++ b/usr.sbin/npf/npfctl/npfctl.c      Wed Jun 29 21:40:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npfctl.c,v 1.46 2015/01/04 20:02:15 christos Exp $     */
+/*     $NetBSD: npfctl.c,v 1.47 2016/06/29 21:40:20 christos Exp $     */
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: npfctl.c,v 1.46 2015/01/04 20:02:15 christos Exp $");
+__RCSID("$NetBSD: npfctl.c,v 1.47 2016/06/29 21:40:20 christos Exp $");
 
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -44,8 +44,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-
-#include <openssl/sha.h>
+#include <sha1.h>
 
 #include "npfctl.h"
 
@@ -386,6 +385,17 @@
 }
 
 static void
+SHA1(const uint8_t *d, unsigned int n, uint8_t *md)
+{
+    SHA1_CTX c;
+
+    SHA1Init(&c);
+    SHA1Update(&c, d, n);
+    SHA1Final(md, &c);
+    memset(&c, 0, sizeof(c));
+}
+
+static void
 npfctl_generate_key(nl_rule_t *rl, void *key)
 {
        void *meta;
@@ -394,9 +404,9 @@
        if ((meta = npf_rule_export(rl, &len)) == NULL) {
                errx(EXIT_FAILURE, "error generating rule key");
        }
-       __CTASSERT(NPF_RULE_MAXKEYLEN >= SHA_DIGEST_LENGTH);
+       __CTASSERT(NPF_RULE_MAXKEYLEN >= SHA1_DIGEST_LENGTH);
        memset(key, 0, NPF_RULE_MAXKEYLEN);
-       SHA1(meta, len, key);
+       SHA1(meta, (unsigned int)len, key);
        free(meta);
 }
 



Home | Main Index | Thread Index | Old Index