Changeset View
Changeset View
Standalone View
Standalone View
contrib/ldns/sha1.c
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | #endif | ||||
/* Add the working vars back into context.state[] */ | /* Add the working vars back into context.state[] */ | ||||
state[0] += a; | state[0] += a; | ||||
state[1] += b; | state[1] += b; | ||||
state[2] += c; | state[2] += c; | ||||
state[3] += d; | state[3] += d; | ||||
state[4] += e; | state[4] += e; | ||||
/* Wipe variables */ | /* Wipe variables */ | ||||
a = b = c = d = e = 0; | a = b = c = d = e = 0; | ||||
(void)a; | |||||
} | } | ||||
/* SHA1Init - Initialize new context */ | /* SHA1Init - Initialize new context */ | ||||
void | void | ||||
ldns_sha1_init(ldns_sha1_ctx *context) | ldns_sha1_init(ldns_sha1_ctx *context) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (digest != NULL) | ||||
((3 - (i & 3)) * 8)) & 255); | ((3 - (i & 3)) * 8)) & 255); | ||||
} | } | ||||
#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */ | #ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */ | ||||
ldns_sha1_transform(context->state, context->buffer); | ldns_sha1_transform(context->state, context->buffer); | ||||
#endif | #endif | ||||
} | } | ||||
unsigned char * | unsigned char * | ||||
ldns_sha1(unsigned char *data, unsigned int data_len, unsigned char *digest) | ldns_sha1(const unsigned char *data, unsigned int data_len, unsigned char *digest) | ||||
{ | { | ||||
ldns_sha1_ctx ctx; | ldns_sha1_ctx ctx; | ||||
ldns_sha1_init(&ctx); | ldns_sha1_init(&ctx); | ||||
ldns_sha1_update(&ctx, data, data_len); | ldns_sha1_update(&ctx, data, data_len); | ||||
ldns_sha1_final(digest, &ctx); | ldns_sha1_final(digest, &ctx); | ||||
return digest; | return digest; | ||||
} | } |