From 62ac0c33cd8a350e5e6563e0c87195af8a07028d Mon Sep 17 00:00:00 2001 From: jakob Date: Fri, 15 Jan 2010 19:24:49 +0000 Subject: NSD v3.2.4 --- usr.sbin/nsd/iterated_hash.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 usr.sbin/nsd/iterated_hash.c (limited to 'usr.sbin/nsd/iterated_hash.c') diff --git a/usr.sbin/nsd/iterated_hash.c b/usr.sbin/nsd/iterated_hash.c new file mode 100644 index 00000000000..da29482087f --- /dev/null +++ b/usr.sbin/nsd/iterated_hash.c @@ -0,0 +1,43 @@ +/* + * iterated_hash.c -- nsec3 hash calculation. + * + * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. + * + * See LICENSE for the license. + * + * With thanks to Ben Laurie. + */ +#include +#ifdef NSEC3 +#include +#include +#include + +#include "iterated_hash.h" + +int +iterated_hash(unsigned char out[SHA_DIGEST_LENGTH], + const unsigned char *salt, int saltlength, + const unsigned char *in, int inlength, int iterations) +{ +#if defined(NSEC3) && defined(HAVE_SSL) + SHA_CTX ctx; + int n; + assert(in && inlength > 0 && iterations >= 0); + for(n=0 ; n <= iterations ; ++n) + { + SHA1_Init(&ctx); + SHA1_Update(&ctx, in, inlength); + if(saltlength > 0) + SHA1_Update(&ctx, salt, saltlength); + SHA1_Final(out, &ctx); + in=out; + inlength=SHA_DIGEST_LENGTH; + } + return SHA_DIGEST_LENGTH; +#else + return 0; +#endif +} + +#endif /* NSEC3 */ -- cgit v1.2.3-59-g8ed1b