From d3d32723b8101539e0fe7bceab07a696fb351431 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 20 Mar 2009 13:45:19 -0700 Subject: [PATCH] sha1: New function SHA1Bytes(). This is convenient for hashing an array with less work. --- lib/sha1.c | 10 ++++++++++ lib/sha1.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/lib/sha1.c b/lib/sha1.c index 81a9c2cb..5fc763f8 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -382,3 +382,13 @@ void SHA1PadMessage(SHA1Context *context) SHA1ProcessMessageBlock(context); } + +void +SHA1Bytes(const void *data, unsigned int n, + uint8_t Message_Digest[SHA1HashSize]) +{ + SHA1Context ctx; + SHA1Reset(&ctx); + SHA1Input(&ctx, data, n); + SHA1Result(&ctx, Message_Digest); +} diff --git a/lib/sha1.h b/lib/sha1.h index 05a5473b..382cf320 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -68,4 +68,7 @@ int SHA1Input( SHA1Context *, int SHA1Result( SHA1Context *, uint8_t Message_Digest[SHA1HashSize]); +void SHA1Bytes(const void *data, unsigned int n, + uint8_t Message_Digest[SHA1HashSize]); + #endif -- 2.30.2