diff options
Diffstat (limited to 'os')
-rw-r--r-- | os/xsha1.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/os/xsha1.c b/os/xsha1.c index 723521e05..94092caa7 100644 --- a/os/xsha1.c +++ b/os/xsha1.c @@ -72,6 +72,32 @@ int x_sha1_final(void *ctx, unsigned char result[20]) return 1; } +#elif defined(HAVE_SHA1_IN_LIBSHA1) /* Use libsha1 */ + +# include <libsha1.h> + +void *x_sha1_init(void) +{ + sha1_ctx *ctx = xalloc(sizeof(*ctx)); + if(!ctx) + return NULL; + sha1_begin(ctx); + return ctx; +} + +int x_sha1_update(void *ctx, void *data, int size) +{ + sha1_hash(data, size, ctx); + return 1; +} + +int x_sha1_final(void *ctx, unsigned char result[20]) +{ + sha1_end(result, ctx); + xfree(ctx); + return 1; +} + #else /* Use OpenSSL's libcrypto */ # include <stddef.h> /* buggy openssl/sha.h wants size_t */ |