Commit 2f43e1c8 authored by Niels Möller's avatar Niels Möller

(md5_digest): Call md5_final and md5_init.

(md5_final): Declared static.
sha1.c, sha256.c: Analogous changes.

Rev: src/nettle/md5.c:1.4
Rev: src/nettle/md5.h:1.4
Rev: src/nettle/sha.h:1.2
Rev: src/nettle/sha1.c:1.6
Rev: src/nettle/sha256.c:1.2
parent 5725c1bf
...@@ -91,7 +91,7 @@ md5_update(struct md5_ctx *ctx, ...@@ -91,7 +91,7 @@ md5_update(struct md5_ctx *ctx,
/* Final wrapup - pad to MD5_DATA_SIZE-byte boundary with the bit /* Final wrapup - pad to MD5_DATA_SIZE-byte boundary with the bit
* pattern 1 0* (64-bit count of bits processed, LSB-first) */ * pattern 1 0* (64-bit count of bits processed, LSB-first) */
void static void
md5_final(struct md5_ctx *ctx) md5_final(struct md5_ctx *ctx)
{ {
uint32_t data[MD5_DATA_LENGTH]; uint32_t data[MD5_DATA_LENGTH];
...@@ -136,7 +136,7 @@ md5_final(struct md5_ctx *ctx) ...@@ -136,7 +136,7 @@ md5_final(struct md5_ctx *ctx)
} }
void void
md5_digest(const struct md5_ctx *ctx, md5_digest(struct md5_ctx *ctx,
unsigned length, unsigned length,
uint8_t *digest) uint8_t *digest)
{ {
...@@ -146,6 +146,8 @@ md5_digest(const struct md5_ctx *ctx, ...@@ -146,6 +146,8 @@ md5_digest(const struct md5_ctx *ctx,
assert(length <= MD5_DIGEST_SIZE); assert(length <= MD5_DIGEST_SIZE);
md5_final(ctx);
words = length / 4; words = length / 4;
leftover = length % 4; leftover = length % 4;
...@@ -165,6 +167,7 @@ md5_digest(const struct md5_ctx *ctx, ...@@ -165,6 +167,7 @@ md5_digest(const struct md5_ctx *ctx,
j++, word >>= 8) j++, word >>= 8)
digest[j] = word & 0xff; digest[j] = word & 0xff;
} }
md5_init(ctx);
} }
/* MD5 functions */ /* MD5 functions */
......
...@@ -51,10 +51,7 @@ md5_update(struct md5_ctx *ctx, ...@@ -51,10 +51,7 @@ md5_update(struct md5_ctx *ctx,
const uint8_t *data); const uint8_t *data);
void void
md5_final(struct md5_ctx *ctx); md5_digest(struct md5_ctx *ctx,
void
md5_digest(const struct md5_ctx *ctx,
unsigned length, unsigned length,
uint8_t *digest); uint8_t *digest);
......
...@@ -53,10 +53,7 @@ sha1_update(struct sha1_ctx *ctx, ...@@ -53,10 +53,7 @@ sha1_update(struct sha1_ctx *ctx,
const uint8_t *data); const uint8_t *data);
void void
sha1_final(struct sha1_ctx *ctx); sha1_digest(struct sha1_ctx *ctx,
void
sha1_digest(const struct sha1_ctx *ctx,
unsigned length, unsigned length,
uint8_t *digest); uint8_t *digest);
...@@ -85,10 +82,7 @@ sha256_update(struct sha256_ctx *ctx, ...@@ -85,10 +82,7 @@ sha256_update(struct sha256_ctx *ctx,
const uint8_t *data); const uint8_t *data);
void void
sha256_final(struct sha256_ctx *ctx); sha256_digest(struct sha256_ctx *ctx,
void
sha256_digest(const struct sha256_ctx *ctx,
unsigned length, unsigned length,
uint8_t *digest); uint8_t *digest);
......
...@@ -294,7 +294,7 @@ sha1_update(struct sha1_ctx *ctx, ...@@ -294,7 +294,7 @@ sha1_update(struct sha1_ctx *ctx,
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern /* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */ 1 0* (64-bit count of bits processed, MSB-first) */
void static void
sha1_final(struct sha1_ctx *ctx) sha1_final(struct sha1_ctx *ctx)
{ {
uint32_t data[SHA1_DATA_LENGTH]; uint32_t data[SHA1_DATA_LENGTH];
...@@ -338,7 +338,7 @@ sha1_final(struct sha1_ctx *ctx) ...@@ -338,7 +338,7 @@ sha1_final(struct sha1_ctx *ctx)
} }
void void
sha1_digest(const struct sha1_ctx *ctx, sha1_digest(struct sha1_ctx *ctx,
unsigned length, unsigned length,
uint8_t *digest) uint8_t *digest)
{ {
...@@ -348,6 +348,8 @@ sha1_digest(const struct sha1_ctx *ctx, ...@@ -348,6 +348,8 @@ sha1_digest(const struct sha1_ctx *ctx,
assert(length <= SHA1_DIGEST_SIZE); assert(length <= SHA1_DIGEST_SIZE);
sha1_final(ctx);
words = length / 4; words = length / 4;
leftover = length % 4; leftover = length % 4;
...@@ -377,4 +379,5 @@ sha1_digest(const struct sha1_ctx *ctx, ...@@ -377,4 +379,5 @@ sha1_digest(const struct sha1_ctx *ctx,
digest[--j] = (word >> 24) & 0xff; digest[--j] = (word >> 24) & 0xff;
} }
} }
sha1_init(ctx);
} }
...@@ -268,7 +268,7 @@ sha256_update(struct sha256_ctx *ctx, ...@@ -268,7 +268,7 @@ sha256_update(struct sha256_ctx *ctx,
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern /* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */ 1 0* (64-bit count of bits processed, MSB-first) */
void static void
sha256_final(struct sha256_ctx *ctx) sha256_final(struct sha256_ctx *ctx)
{ {
uint32_t data[SHA256_DATA_LENGTH]; uint32_t data[SHA256_DATA_LENGTH];
...@@ -312,7 +312,7 @@ sha256_final(struct sha256_ctx *ctx) ...@@ -312,7 +312,7 @@ sha256_final(struct sha256_ctx *ctx)
} }
void void
sha256_digest(const struct sha256_ctx *ctx, sha256_digest(struct sha256_ctx *ctx,
unsigned length, unsigned length,
uint8_t *digest) uint8_t *digest)
{ {
...@@ -322,6 +322,8 @@ sha256_digest(const struct sha256_ctx *ctx, ...@@ -322,6 +322,8 @@ sha256_digest(const struct sha256_ctx *ctx,
assert(length <= SHA256_DIGEST_SIZE); assert(length <= SHA256_DIGEST_SIZE);
sha256_final(ctx);
words = length / 4; words = length / 4;
leftover = length % 4; leftover = length % 4;
...@@ -351,4 +353,5 @@ sha256_digest(const struct sha256_ctx *ctx, ...@@ -351,4 +353,5 @@ sha256_digest(const struct sha256_ctx *ctx,
digest[--j] = (word >> 24) & 0xff; digest[--j] = (word >> 24) & 0xff;
} }
} }
sha256_init(ctx);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment