Paul Tagliamonte <[email protected]> writes:

> Here's a minimal example:
>
> /
> | #include <stdio.h>
> | #include <nettle/rsa.h>
> | 
> | int main ( int argc, char ** argv ) {
> |     struct sha1_ctx hash_ctx;
> |     uint8_t headers[] = {
> |         0xDE, 0xEA, 0xAD,
> |         0xBE, 0xEF
> |     };
> |     sha1_update(&hash_ctx, 5, headers);

You must call sha1_init(&hash_ctx) before the first sha1_update.

> Does doing the sha1_digest alter state in some way? I can't image it is, but
> then how does this behavior crop up?

sha1_digest implies a sha1_init. So with sha1_digest(...);
sha1_digest(...), the second call gives you the sha1 digest of the empty
string. I think this is explained in the manual,
http://www.lysator.liu.se/~nisse/nettle/nettle.html#Legacy-hash-functions

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to