Go to the source code of this file.
Data Structures | |
struct | sha1_ctxt |
Defines | |
#define | SHA1Init(x) sha1_init((x)) |
#define | SHA1Update(x, y, z) sha1_loop((x), (y), (z)) |
#define | SHA1Final(x, y) sha1_result((y), (x)) |
#define | SHA1_RESULTLEN (160/8) |
Typedefs | |
typedef struct sha1_ctxt | SHA1_CTX |
Functions | |
void | sha1_init (struct sha1_ctxt *) |
void | sha1_pad (struct sha1_ctxt *) |
void | sha1_loop (struct sha1_ctxt *, const uint8 *, size_t) |
void | sha1_result (struct sha1_ctxt *, uint8 *) |
#define SHA1Final | ( | x, | ||
y | ||||
) | sha1_result((y), (x)) |
Definition at line 71 of file sha1.h.
Referenced by int_sha1_finish().
#define SHA1Init | ( | x | ) | sha1_init((x)) |
Definition at line 69 of file sha1.h.
Referenced by int_sha1_reset().
#define SHA1Update | ( | x, | ||
y, | ||||
z | ||||
) | sha1_loop((x), (y), (z)) |
Definition at line 70 of file sha1.h.
Referenced by int_sha1_update().
void sha1_init | ( | struct sha1_ctxt * | ) |
Definition at line 283 of file sha1.c.
References sha1_ctxt::b64, sha1_ctxt::b8, sha1_ctxt::c, COUNT, sha1_ctxt::m, memmove, and sha1_step().
{ const uint8 *input; size_t gaplen; size_t gapstart; size_t off; size_t copysiz; input = (const uint8 *) input0; off = 0; while (off < len) { gapstart = COUNT % 64; gaplen = 64 - gapstart; copysiz = (gaplen < len - off) ? gaplen : len - off; memmove(&ctxt->m.b8[gapstart], &input[off], copysiz); COUNT += copysiz; COUNT %= 64; ctxt->c.b64[0] += copysiz * 8; if (COUNT % 64 == 0) sha1_step(ctxt); off += copysiz; } }
void sha1_pad | ( | struct sha1_ctxt * | ) |
Definition at line 240 of file sha1.c.
References sha1_ctxt::b8, sha1_ctxt::c, COUNT, sha1_ctxt::m, PUTPAD, and sha1_step().
Referenced by sha1_result().
{ size_t padlen; /* pad length in bytes */ size_t padstart; PUTPAD(0x80); padstart = COUNT % 64; padlen = 64 - padstart; if (padlen < 8) { memset(&ctxt->m.b8[padstart], 0, padlen); COUNT += padlen; COUNT %= 64; sha1_step(ctxt); padstart = COUNT % 64; /* should be 0 */ padlen = 64 - padstart; /* should be 64 */ } memset(&ctxt->m.b8[padstart], 0, padlen - 8); COUNT += (padlen - 8); COUNT %= 64; #ifdef WORDS_BIGENDIAN PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]); #else PUTPAD(ctxt->c.b8[7]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[0]); #endif }
Definition at line 311 of file sha1.c.
References sha1_ctxt::b8, sha1_ctxt::h, memmove, and sha1_pad().
{ uint8 *digest; digest = (uint8 *) digest0; sha1_pad(ctxt); #ifdef WORDS_BIGENDIAN memmove(digest, &ctxt->h.b8[0], 20); #else digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2]; digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0]; digest[4] = ctxt->h.b8[7]; digest[5] = ctxt->h.b8[6]; digest[6] = ctxt->h.b8[5]; digest[7] = ctxt->h.b8[4]; digest[8] = ctxt->h.b8[11]; digest[9] = ctxt->h.b8[10]; digest[10] = ctxt->h.b8[9]; digest[11] = ctxt->h.b8[8]; digest[12] = ctxt->h.b8[15]; digest[13] = ctxt->h.b8[14]; digest[14] = ctxt->h.b8[13]; digest[15] = ctxt->h.b8[12]; digest[16] = ctxt->h.b8[19]; digest[17] = ctxt->h.b8[18]; digest[18] = ctxt->h.b8[17]; digest[19] = ctxt->h.b8[16]; #endif }