diff options
author | Yaakov Selkowitz <yselkowitz@users.sourceforge.net> | 2012-10-29 22:37:37 -0500 |
---|---|---|
committer | Yaakov Selkowitz <yselkowitz@users.sourceforge.net> | 2012-11-05 13:34:18 -0600 |
commit | 54ba26cb1f9c59559cc3c449abeb31b2ce23bdba (patch) | |
tree | 9706c9ce63926343a35fcae56b24975333e62549 /os | |
parent | 2ff56033de2b493a11d2bdf411b7057b1b3a22d7 (diff) |
os: Add libnettle as a choice of SHA1 implementation
libnettle is smaller than libgcrypt, currently being released more
frequently, and has replaced the latter in gnutls-3.x (which is used
by TigerVNC, so they can avoid pulling in two crypto libraries
simultaneously).
Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'os')
-rw-r--r-- | os/xsha1.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/os/xsha1.c b/os/xsha1.c index fa66c7a06..24c0aa284 100644 --- a/os/xsha1.c +++ b/os/xsha1.c @@ -116,6 +116,36 @@ x_sha1_final(void *ctx, unsigned char result[20]) return 1; } +#elif defined(HAVE_SHA1_IN_LIBNETTLE) /* Use libnettle for SHA1 */ + +#include <nettle/sha.h> + +void * +x_sha1_init(void) +{ + struct sha1_ctx *ctx = malloc(sizeof(*ctx)); + + if (!ctx) + return NULL; + sha1_init(ctx); + return ctx; +} + +int +x_sha1_update(void *ctx, void *data, int size) +{ + sha1_update(ctx, size, data); + return 1; +} + +int +x_sha1_final(void *ctx, unsigned char result[20]) +{ + sha1_digest(ctx, 20, result); + free(ctx); + return 1; +} + #elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */ #include <gcrypt.h> |