ref: e8a2cf6d1f84035a7af4766e6a7b2120ef5f16c1
parent: 7a4a066469be598f999f238ffc451257d6387769
author: Martin Storsjö <[email protected]>
date: Mon Feb 24 07:00:17 EST 2014
Make the SHA1Result function write the output into a byte array
--- a/test/sha1.c
+++ b/test/sha1.c
@@ -111,11 +111,13 @@
*
* Description:
* This function will return the 160-bit message digest into the
- * Message_Digest array within the SHA1Context provided
+ * digest array provided as a parameter.
*
* Parameters:
* context: [in/out]
* The context to use to calculate the SHA-1 hash.
+ * digest: [out]
+ * An array of characters where the digest is written.
*
* Returns:
* 1 if successful, 0 if it failed.
@@ -123,8 +125,9 @@
* Comments:
*
*/
-int SHA1Result(SHA1Context *context)
+int SHA1Result(SHA1Context *context, unsigned char *digest)
{
+ int i;
if (context->Corrupted)
{
@@ -136,6 +139,9 @@
SHA1PadMessage(context);
context->Computed = 1;
}
+
+ for (i = 0; i < SHA_DIGEST_LENGTH; i++)
+ digest[i] = context->Message_Digest[i / 4] >> (8 * (3 - (i % 4)));
return 1;
}
--- a/test/sha1.h
+++ b/test/sha1.h
@@ -72,7 +72,7 @@
* Function Prototypes
*/
void SHA1Reset(SHA1Context *);
-int SHA1Result(SHA1Context *);
+int SHA1Result(SHA1Context *, unsigned char *);
void SHA1Input( SHA1Context *,
const unsigned char *,
unsigned);