aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/xsha1.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os/xsha1.c')
-rw-r--r--xorg-server/os/xsha1.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/xorg-server/os/xsha1.c b/xorg-server/os/xsha1.c
index fa66c7a06..24c0aa284 100644
--- a/xorg-server/os/xsha1.c
+++ b/xorg-server/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>