SECHASH(2)SECHASH(2)
NAME
md4, md5, ripemd160, sha1, sha2_224, sha2_256, sha2_384, sha2_512, hmac_x, hmac_md5, hmac_sha1, hmac_sha2_224, hmac_sha2_256, hmac_sha2_384, hmac_sha2_512, poly1305 – cryptographically secure hashes
SYNOPSIS
unhandled troff command .nr
unhandled troff command .nr
unhandled troff command .de
unhandled troff command .in
unhandled troff command .ti
unhandled troff command .nh
unhandled troff command ..
#include <u.h> #include <libc.h> #include <mp.h> #include <libsec.h> #define DS DigestState /* only to abbreviate SYNOPSIS */
unhandled troff command .Ti
DS* md4(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* md5(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* ripemd160(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* sha1(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* sha2_224(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* sha2_256(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* sha2_384(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* sha2_512(uchar *data, ulong dlen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* hmac_x(uchar *p, ulong len, uchar *key, ulong klen, uchar *digest, DS *s, DS*(*x)(uchar*, ulong, uchar*, DS*), int xlen)
unhandled troff command .Ti
DS* hmac_md5(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* hmac_sha1(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* hmac_sha2_224(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* hmac_sha2_256(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* hmac_sha2_384(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* hmac_sha2_512(uchar *data, ulong dlen, uchar *key, ulong klen, uchar *digest, DS *state)
unhandled troff command .Ti
DS* poly1305(uchar *p, ulong len, uchar *key, ulong klen, uchar *digest, DS *state)
DESCRIPTION
unhandled troff command .DT
The output of a hash is called a
The routines
The constants
EXAMPLES
To hash a single buffer using
uchar digest[MD5dlen]; md5(data, len, digest, nil);
To chain a number of buffers together, bounded on each end by some secret:
char buf[256]; uchar digest[MD5dlen]; DigestState *s; s = md5("my password", 11, nil, nil); while((n = read(fd, buf, 256)) > 0) md5(buf, n, nil, s); md5("drowssap ym", 11, digest, s);
SOURCE
SEE
HMAC specification