Make the SHA1Result function write the output into a byte array
This commit is contained in:
parent
7a4a066469
commit
e8a2cf6d1f
10
test/sha1.c
10
test/sha1.c
@ -111,11 +111,13 @@ void SHA1Reset(SHA1Context *context)
|
||||
*
|
||||
* 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 @@ void SHA1Reset(SHA1Context *context)
|
||||
* Comments:
|
||||
*
|
||||
*/
|
||||
int SHA1Result(SHA1Context *context)
|
||||
int SHA1Result(SHA1Context *context, unsigned char *digest)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (context->Corrupted)
|
||||
{
|
||||
@ -137,6 +140,9 @@ int SHA1Result(SHA1Context *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;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ typedef struct SHA1Context
|
||||
* Function Prototypes
|
||||
*/
|
||||
void SHA1Reset(SHA1Context *);
|
||||
int SHA1Result(SHA1Context *);
|
||||
int SHA1Result(SHA1Context *, unsigned char *);
|
||||
void SHA1Input( SHA1Context *,
|
||||
const unsigned char *,
|
||||
unsigned);
|
||||
|
Loading…
Reference in New Issue
Block a user