summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2002-01-09 15:58:32 +0100
committerNiels Möller <nisse@lysator.liu.se>2002-01-09 15:58:32 +0100
commit2f43e1c87876e07d35970cd9f6514f503d518e49 (patch)
tree4ed5fa1a8e0b77ac7157513b7bdae1f7d3b29794
parent5725c1bf093767c276e02a33a00246c2aa5f81bb (diff)
downloadnettle-2f43e1c87876e07d35970cd9f6514f503d518e49.tar.gz
(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
-rw-r--r--md5.c7
-rw-r--r--md5.h5
-rw-r--r--sha.h10
-rw-r--r--sha1.c7
-rw-r--r--sha256.c7
5 files changed, 18 insertions, 18 deletions
diff --git a/md5.c b/md5.c
index 932f6ca1..20568d90 100644
--- a/md5.c
+++ b/md5.c
@@ -91,7 +91,7 @@ md5_update(struct md5_ctx *ctx,
/* Final wrapup - pad to MD5_DATA_SIZE-byte boundary with the bit
* pattern 1 0* (64-bit count of bits processed, LSB-first) */
-void
+static void
md5_final(struct md5_ctx *ctx)
{
uint32_t data[MD5_DATA_LENGTH];
@@ -136,7 +136,7 @@ md5_final(struct md5_ctx *ctx)
}
void
-md5_digest(const struct md5_ctx *ctx,
+md5_digest(struct md5_ctx *ctx,
unsigned length,
uint8_t *digest)
{
@@ -146,6 +146,8 @@ md5_digest(const struct md5_ctx *ctx,
assert(length <= MD5_DIGEST_SIZE);
+ md5_final(ctx);
+
words = length / 4;
leftover = length % 4;
@@ -165,6 +167,7 @@ md5_digest(const struct md5_ctx *ctx,
j++, word >>= 8)
digest[j] = word & 0xff;
}
+ md5_init(ctx);
}
/* MD5 functions */
diff --git a/md5.h b/md5.h
index b376f7db..c93bcc19 100644
--- a/md5.h
+++ b/md5.h
@@ -51,10 +51,7 @@ md5_update(struct md5_ctx *ctx,
const uint8_t *data);
void
-md5_final(struct md5_ctx *ctx);
-
-void
-md5_digest(const struct md5_ctx *ctx,
+md5_digest(struct md5_ctx *ctx,
unsigned length,
uint8_t *digest);
diff --git a/sha.h b/sha.h
index 0cf9b8ca..f9eb69bd 100644
--- a/sha.h
+++ b/sha.h
@@ -53,10 +53,7 @@ sha1_update(struct sha1_ctx *ctx,
const uint8_t *data);
void
-sha1_final(struct sha1_ctx *ctx);
-
-void
-sha1_digest(const struct sha1_ctx *ctx,
+sha1_digest(struct sha1_ctx *ctx,
unsigned length,
uint8_t *digest);
@@ -85,10 +82,7 @@ sha256_update(struct sha256_ctx *ctx,
const uint8_t *data);
void
-sha256_final(struct sha256_ctx *ctx);
-
-void
-sha256_digest(const struct sha256_ctx *ctx,
+sha256_digest(struct sha256_ctx *ctx,
unsigned length,
uint8_t *digest);
diff --git a/sha1.c b/sha1.c
index a0982fb4..f1c18c63 100644
--- a/sha1.c
+++ b/sha1.c
@@ -294,7 +294,7 @@ sha1_update(struct sha1_ctx *ctx,
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
-void
+static void
sha1_final(struct sha1_ctx *ctx)
{
uint32_t data[SHA1_DATA_LENGTH];
@@ -338,7 +338,7 @@ sha1_final(struct sha1_ctx *ctx)
}
void
-sha1_digest(const struct sha1_ctx *ctx,
+sha1_digest(struct sha1_ctx *ctx,
unsigned length,
uint8_t *digest)
{
@@ -348,6 +348,8 @@ sha1_digest(const struct sha1_ctx *ctx,
assert(length <= SHA1_DIGEST_SIZE);
+ sha1_final(ctx);
+
words = length / 4;
leftover = length % 4;
@@ -377,4 +379,5 @@ sha1_digest(const struct sha1_ctx *ctx,
digest[--j] = (word >> 24) & 0xff;
}
}
+ sha1_init(ctx);
}
diff --git a/sha256.c b/sha256.c
index ec8fb509..76ce5f35 100644
--- a/sha256.c
+++ b/sha256.c
@@ -268,7 +268,7 @@ sha256_update(struct sha256_ctx *ctx,
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
1 0* (64-bit count of bits processed, MSB-first) */
-void
+static void
sha256_final(struct sha256_ctx *ctx)
{
uint32_t data[SHA256_DATA_LENGTH];
@@ -312,7 +312,7 @@ sha256_final(struct sha256_ctx *ctx)
}
void
-sha256_digest(const struct sha256_ctx *ctx,
+sha256_digest(struct sha256_ctx *ctx,
unsigned length,
uint8_t *digest)
{
@@ -322,6 +322,8 @@ sha256_digest(const struct sha256_ctx *ctx,
assert(length <= SHA256_DIGEST_SIZE);
+ sha256_final(ctx);
+
words = length / 4;
leftover = length % 4;
@@ -351,4 +353,5 @@ sha256_digest(const struct sha256_ctx *ctx,
digest[--j] = (word >> 24) & 0xff;
}
}
+ sha256_init(ctx);
}