1
0
mirror of git://git.suckless.org/sbase synced 2024-12-28 01:52:23 +00:00
sbase/sha1.h
sin 9ac01f59be 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.
2013-07-18 09:51:17 -04:00

19 lines
615 B
C

/* public domain sha1 implementation based on rfc3174 and libtomcrypt */
struct sha1 {
uint64_t len; /* processed message length */
uint32_t h[5]; /* hash state */
uint8_t buf[64]; /* message block buffer */
};
enum { SHA1_DIGEST_LENGTH = 20 };
/* reset state */
void sha1_init(void *ctx);
/* process message */
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(void *ctx, uint8_t md[SHA1_DIGEST_LENGTH]);