From f50d5b40a767bc3373abb60af0ac51e29f618a3e Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 16 Nov 2017 01:37:19 +0000 Subject: [PATCH] rename sha1 functions --- mutt/sha1.c | 38 +++++++++++++++++++------------------- mutt/sha1.h | 8 ++++---- pgppubring.c | 12 ++++++------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/mutt/sha1.c b/mutt/sha1.c index fe9357244..141d93e6d 100644 --- a/mutt/sha1.c +++ b/mutt/sha1.c @@ -15,12 +15,12 @@ * * Calculate the SHA1 cryptographic hash of a string, according to RFC3174. * - * | Function | Description - * | :--------------- | :---------------------------------------- - * | sha1_final() | Add padding and return the message digest - * | sha1_init() | Initialize new context - * | sha1_transform() | Hash a single 512-bit block - * | sha1_update() | Run your data through this + * | Function | Description + * | :-------------------- | :---------------------------------------- + * | mutt_sha1_final() | Add padding and return the message digest + * | mutt_sha1_init() | Initialize new context + * | mutt_sha1_transform() | Hash a single 512-bit block + * | mutt_sha1_update() | Run your data through this * * Test Vectors (from FIPS PUB 180-1): * - "abc" yields `A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D` @@ -66,13 +66,13 @@ w = rol(w, 30); /** - * sha1_transform - Hash a single 512-bit block + * mutt_sha1_transform - Hash a single 512-bit block * @param state Internal state of the transform * @param buffer Data to transform * * This is the core of the algorithm. */ -void sha1_transform(uint32_t state[5], const unsigned char buffer[64]) +void mutt_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) { uint32_t a, b, c, d, e; typedef union { @@ -180,10 +180,10 @@ void sha1_transform(uint32_t state[5], const unsigned char buffer[64]) } /** - * sha1_init - Initialize new context + * mutt_sha1_init - Initialize new context * @param context SHA1 context */ -void sha1_init(struct Sha1Ctx *context) +void mutt_sha1_init(struct Sha1Ctx *context) { /* SHA1 initialization constants */ context->state[0] = 0x67452301; @@ -195,12 +195,12 @@ void sha1_init(struct Sha1Ctx *context) } /** - * sha1_update - Run your data through this + * mutt_sha1_update - Run your data through this * @param context SHA1 context * @param data Data to be hashed * @param len Length of data */ -void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len) +void mutt_sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len) { uint32_t i; uint32_t j; @@ -213,10 +213,10 @@ void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t le if ((j + len) > 63) { memcpy(&context->buffer[j], data, (i = 64 - j)); - sha1_transform(context->state, context->buffer); + mutt_sha1_transform(context->state, context->buffer); for (; i + 63 < len; i += 64) { - sha1_transform(context->state, &data[i]); + mutt_sha1_transform(context->state, &data[i]); } j = 0; } @@ -226,11 +226,11 @@ void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t le } /** - * sha1_final - Add padding and return the message digest + * mutt_sha1_final - Add padding and return the message digest * @param[out] digest Message digest (SHA1 sum) * @param[in] context SHA1 context */ -void sha1_final(unsigned char digest[20], struct Sha1Ctx *context) +void mutt_sha1_final(unsigned char digest[20], struct Sha1Ctx *context) { unsigned char finalcount[8]; unsigned char c; @@ -242,13 +242,13 @@ void sha1_final(unsigned char digest[20], struct Sha1Ctx *context) } c = 0200; - sha1_update(context, &c, 1); + mutt_sha1_update(context, &c, 1); while ((context->count[0] & 504) != 448) { c = 0000; - sha1_update(context, &c, 1); + mutt_sha1_update(context, &c, 1); } - sha1_update(context, finalcount, 8); /* Should cause a sha1_transform() */ + mutt_sha1_update(context, finalcount, 8); /* Should cause a mutt_sha1_transform() */ for (unsigned int i = 0; i < 20; i++) { digest[i] = (unsigned char) ((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); diff --git a/mutt/sha1.h b/mutt/sha1.h index 47449598b..a2fb108c7 100644 --- a/mutt/sha1.h +++ b/mutt/sha1.h @@ -37,10 +37,10 @@ struct Sha1Ctx unsigned char buffer[64]; }; -void sha1_final(unsigned char digest[20], struct Sha1Ctx *context); -void sha1_init(struct Sha1Ctx *context); -void sha1_transform(uint32_t state[5], const unsigned char buffer[64]); -void sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len); +void mutt_sha1_final(unsigned char digest[20], struct Sha1Ctx *context); +void mutt_sha1_init(struct Sha1Ctx *context); +void mutt_sha1_transform(uint32_t state[5], const unsigned char buffer[64]); +void mutt_sha1_update(struct Sha1Ctx *context, const unsigned char *data, uint32_t len); #define SHA_DIGEST_LENGTH 20 diff --git a/pgppubring.c b/pgppubring.c index 3eb894b13..3915ad11c 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -313,7 +313,7 @@ static void pgp_make_pgp3_fingerprint(unsigned char *buff, size_t l, unsigned ch unsigned char dummy; struct Sha1Ctx context; - sha1_init(&context); + mutt_sha1_init(&context); dummy = buff[0] & 0x3f; @@ -321,13 +321,13 @@ static void pgp_make_pgp3_fingerprint(unsigned char *buff, size_t l, unsigned ch dummy = PT_PUBKEY; dummy = (dummy << 2) | 0x81; - sha1_update(&context, &dummy, 1); + mutt_sha1_update(&context, &dummy, 1); dummy = ((l - 1) >> 8) & 0xff; - sha1_update(&context, &dummy, 1); + mutt_sha1_update(&context, &dummy, 1); dummy = (l - 1) & 0xff; - sha1_update(&context, &dummy, 1); - sha1_update(&context, buff + 1, l - 1); - sha1_final(digest, &context); + mutt_sha1_update(&context, &dummy, 1); + mutt_sha1_update(&context, buff + 1, l - 1); + mutt_sha1_final(digest, &context); } static void skip_bignum(unsigned char *buff, size_t l, size_t j, size_t *toff, size_t n) -- 2.40.0