Add crypt.[ch] and update md5sum and sha1sum

Factor out the code from md5sum and sha1sum into a util function.

Use FILE * instead of a file descriptor.  This will make it a bit
easier/more consistent when we implement support for the -c option.
This commit is contained in:
sin
2013-07-07 15:29:45 +01:00
committed by David Galos
parent 48e6870bb7
commit 9ac01f59be
9 changed files with 98 additions and 83 deletions

6
sha1.h
View File

@@ -9,10 +9,10 @@ struct sha1 {
enum { SHA1_DIGEST_LENGTH = 20 };
/* reset state */
void sha1_init(struct sha1 *s);
void sha1_init(void *ctx);
/* process message */
void sha1_update(struct sha1 *s, const void *m, unsigned long len);
void sha1_update(void *ctx, const void *m, unsigned long len);
/* get message digest */
/* state is ruined after sum, keep a copy if multiple sum is needed */
/* part of the message might be left in s, zero it if secrecy is needed */
void sha1_sum(struct sha1 *s, uint8_t md[SHA1_DIGEST_LENGTH]);
void sha1_sum(void *ctx, uint8_t md[SHA1_DIGEST_LENGTH]);