#include <config.h>
+#include "secnet.h"
+
#include "sha512.h"
#include <stddef.h>
h = ctx->state[7] = u64plus (ctx->state[7], h);
}
}
+
+struct sha512 {
+ closure_t cl;
+ struct hash_if ops;
+};
+
+static void *sha512_init(void)
+ { struct sha512_ctx *ctx; NEW(ctx); sha512_init_ctx(ctx); return ctx; }
+
+static void sha512_update(void *st, const void *buf, int32_t len)
+ { struct sha512_ctx *ctx = st; sha512_process_bytes(buf, len, ctx); }
+
+static void sha512_final(void *st, uint8_t *digest)
+ { struct sha512_ctx *ctx = st; sha512_finish_ctx(ctx, digest); free(ctx); }
+
+void sha512_module(dict_t *dict)
+{
+ struct sha512 *st;
+
+ NEW(st);
+ st->cl.description="sha512";
+ st->cl.type=CL_HASH;
+ st->cl.apply=NULL;
+ st->cl.interface=&st->ops;
+ st->ops.len=64;
+ st->ops.init=sha512_init;
+ st->ops.update=sha512_update;
+ st->ops.final=sha512_final;
+
+ dict_add(dict,"sha512",new_closure(&st->cl));
+}