/* HMAC */ static void hmac_gen(hash_t hash, int iter, const char *out, int nout, const char *msg, int nmsg, const char *pass, int npass, const char *salt, int nsalt); { // iter - ?? uint8_t *opad = alloc0(nout); uint8_t *ipad = alloc0(nout); uint8_t *buf = alloc0(nout); uint8_t *tmp1 = alloc0(nout+nmsg); uint8_t *tmp2 = alloc0(nout+2); if (npass > nout) hash(buf, key); else if (npass < nout) memcpy(buf, key, npass); for (int i = 0; i < nout; i++) { opad[i] = 0x5c ^ key[i]; ipad[i] = 0x36 ^ key[i]; } memcpy(tmp1, ipad, message); hash(tmp, ipad + message); hash(out, opad + tmp) }