Module Name: src Committed By: christos Date: Wed Jun 29 21:40:20 UTC 2016
Modified Files: src/usr.sbin/npf/npfctl: npfctl.c Log Message: use sha1 from libc To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/npf/npfctl/npfctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/npf/npfctl/npfctl.c diff -u src/usr.sbin/npf/npfctl/npfctl.c:1.46 src/usr.sbin/npf/npfctl/npfctl.c:1.47 --- src/usr.sbin/npf/npfctl/npfctl.c:1.46 Sun Jan 4 15:02:15 2015 +++ src/usr.sbin/npf/npfctl/npfctl.c Wed Jun 29 17:40:20 2016 @@ -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 @@ __RCSID("$NetBSD: npfctl.c,v 1.46 2015/0 #include <fcntl.h> #include <unistd.h> #include <errno.h> - -#include <openssl/sha.h> +#include <sha1.h> #include "npfctl.h" @@ -386,6 +385,17 @@ npfctl_parse_rule(int argc, char **argv) } 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 @@ npfctl_generate_key(nl_rule_t *rl, void 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); }