include "ipints.m"; ipints := load IPints IPints->PATH; IPint: import ipints; include "crypt.m"; crypt := load Crypt Crypt->PATH; DigestState: adt { # hidden state copy: fn(d: self ref DigestState): ref DigestState; }; sha1: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; sha224: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; sha256: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; sha384: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; sha512: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; md4: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; md5: fn(buf: array of byte, n: int, digest: array of byte, state: ref DigestState): ref DigestState; SHA1dlen, SHA224dlen, SHA256dlen, SHA384dlen, SHA512dlen, MD4dlen, MD5dlen: con ...; hmac_sha1: fn(buf: array of byte, n: int, key: array of byte, digest: array of byte, state: ref DigestState): ref DigestState; hmac_md5: fn(buf: array of byte, n: int, key: array of byte, digest: array of byte, state: ref DigestState): ref DigestState;
Hmac_sha1 and hmac_md5 are keyed versions of the hashing functions, following Internet RFC2104. The key must be provided in each call, but otherwise the calling conventions are those of sha1. The key must currently be no more than 64 bytes.
DigestState hides the state of partially completed hash functions during processing. Its copy operation returns a reference to a new copy of a given state.
state: ref DigestState = nil; while((n := sys->read(fd, buf, len buf)) > 0) state = kr->sha1(buf, n, nil, state); digest := array[kr->SHA1dlen] of byte; kr->sha1(buf, 0, digest, state);
CRYPT-SHA1(2 ) | Rev: Tue Mar 31 02:42:39 GMT 2015 |