sum-sha1.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
#pragma prototyped
/*
* SHA-1 in C
* By Steve Reid <steve@edmweb.com>
* 100% Public Domain
*
* Test Vectors (from FIPS PUB 180-1)
* "abc"
* A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
* "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
* 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
* A million repetitions of "a"
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
#define sha1_description "FIPS 180-1 SHA-1 secure hash algorithm 1."
#define sha1_options "[+(version)?sha1 (FIPS 180-1) 1996-09-26]\
[+(author)?Steve Reid <steve@edmweb.com>]"
#define sha1_match "sha1|SHA1|sha-1|SHA-1"
#define sha1_scale 0
#define sha1_padding md5_pad
typedef struct Sha1_s
{
} Sha1_t;
/*
* blk0() and blk() perform the initial expand.
* I got the idea of expanding during the round function from SSLeay
*/
#if _ast_intswap
# define blk0(i) \
#else
#endif
#define blk(i) \
/*
* (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
*/
#define R0(v,w,x,y,z,i) \
w = rol(w, 30);
#define R1(v,w,x,y,z,i) \
w = rol(w, 30);
#define R2(v,w,x,y,z,i) \
w = rol(w, 30);
#define R3(v,w,x,y,z,i) \
w = rol(w, 30);
#define R4(v,w,x,y,z,i) \
w = rol(w, 30);
typedef union {
unsigned char c[64];
unsigned int l[16];
} CHAR64LONG16;
#ifdef __sparc_v9__
static void
{
}
static void
{
}
static void
{
}
static void
{
}
#endif
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
static void
uint32_t a, b, c, d, e;
/* Copy sha->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
#ifdef __sparc_v9__
#else
/* 4 rounds of 20 operations each. Loop unrolled. */
#endif
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}
static int
{
unsigned int i, j;
if (len) {
j = (j >> 3) & 63;
if ((j + len) > 63) {
j = 0;
} else {
i = 0;
}
}
return 0;
}
static int
{
return 0;
}
static Sum_t*
{
{
}
}
/*
* Add padding and return the message digest.
*/
static const unsigned char final_200 = 128;
static const unsigned char final_0 = 0;
static int
{
unsigned int i;
unsigned char finalcount[8];
for (i = 0; i < 8; i++) {
/* Endian independent */
finalcount[i] = (unsigned char)
>> ((3 - (i & 3)) * 8)) & 255);
}
/* The next Update should cause a sha1_transform() */
{
}
return 0;
}
static int
{
register unsigned char* d;
register int n;
return 0;
}
static int
{
return 0;
}