hash HASH-NAME
Assigns the HASH-NAME to the `hash' key. The HASH-NAME
- must be one of `md5' or `sha1', and the corresponding
- hash closure is used. Acceptable at all levels;
- required at site level.
+ must be one of `md5', `sha1', or `sha512', and the
+ corresponding hash closure is used. Acceptable at all
+ levels; required at site level.
key-lifetime INT
setup-timeout INT
def __init__(self,w):
hname=w[1]
self.ht=hname.raw()
- if (self.ht!='md5' and self.ht!='sha1'):
+ if (self.ht not in ('md5', 'sha1', 'sha512')):
complain("unknown hash type %s"%(self.ht))
self.ht=None
else:
slip_module(dict);
tun_module(dict);
sha1_module(dict);
+ sha512_module(dict);
log_module(dict);
privcache_module(dict);
}
.SS sha1
\fBsha1\fR is a \fIhash closure\fR implementing the SHA-1 algorithm.
+.SS sha512
+\fBsha512\fR is a \fIhash closure\fR implementing the SHA-512 algorithm.
+
.SS site
\fBsite(\fIDICT\fB)\fR => \fIsite closure\fR
.PP
extern init_module slip_module;
extern init_module tun_module;
extern init_module sha1_module;
+extern init_module sha512_module;
extern init_module log_module;
extern init_module privcache_module;
#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 *sst)
+ { struct sha512_ctx *ctx=sst; sha512_init_ctx(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); }
+
+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.hlen=64;
+ st->ops.slen=sizeof(struct sha512_ctx);
+ st->ops.init=sha512_init;
+ st->ops.update=sha512_update;
+ st->ops.final=sha512_final;
+
+ dict_add(dict,"sha512",new_closure(&st->cl));
+}