sha1.c revision 70e5a7403f0e0a3bd292b8287c5fed5772c15270
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * Permission to use, copy, modify, and/or distribute this software for any
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * purpose with or without fee is hereby granted, provided that the above
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * copyright notice and this permission notice appear in all copies.
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * PERFORMANCE OF THIS SOFTWARE.
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse/* $Id: sha1.c,v 1.18 2007/06/19 23:47:17 tbox Exp $ */
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse/* $NetBSD: sha1.c,v 1.5 2000/01/22 22:19:14 mycroft Exp $ */
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * \author By Steve Reid <steve@edmweb.com>
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * 100% Public Domain
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * Test Vectors (from FIPS PUB 180-1)
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * A million repetitions of "a"
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * \endverbatim
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse * blk0() and blk() perform the initial expand.
f5e5a2c4965aa1013184568ca3140cdcba93e44bToomas Soome * I got the idea of expanding during the round function from SSLeay
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) \
f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2Glenn Lagasse (block->l[i & 15] = rol(block->l[(i + 13) & 15] \
#define R0(v,w,x,y,z,i) \
#define R1(v,w,x,y,z,i) \
#define R2(v,w,x,y,z,i) \
#define R3(v,w,x,y,z,i) \
#define R4(v,w,x,y,z,i) \
} CHAR64LONG16;
#ifdef __sparc_v9__
isc_uint32_t a, b, c, d, e;
a = state[0];
#ifdef __sparc_v9__
/* Add the working vars back into context.state[] */
state[0] += a;
unsigned int len)
static const unsigned char final_0 = 0;
finalcount[i] = (unsigned char)
if (digest) {
digest[i] = (unsigned char)