mirror of
https://github.com/X11Libre/xserver.git
synced 2026-10-17 00:32:57 +00:00
os: Add libsha1 as a choice of SHA1 implementation
There are small systems which don't need OpenSSL or gcrypt. Add libsha1 (http://github.com/dottedmag/libsha1) as an alternative small SHA1 implementation. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
8613e4b0eb
commit
ccf4a69db7
3 changed files with 39 additions and 1 deletions
26
os/xsha1.c
26
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 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue