From: Ben Pfaff Date: Fri, 20 Mar 2009 20:45:19 +0000 (-0700) Subject: sha1: New function SHA1Bytes(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3d32723b8101539e0fe7bceab07a696fb351431;p=openvswitch sha1: New function SHA1Bytes(). This is convenient for hashing an array with less work. --- 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