1263635Sdes/* $OpenBSD: hmac.h,v 1.6 2014/01/27 18:58:14 markus Exp $ */
2263635Sdes/*
3263635Sdes * Copyright (c) 2014 Markus Friedl.  All rights reserved.
4263635Sdes *
5263635Sdes * Permission to use, copy, modify, and distribute this software for any
6263635Sdes * purpose with or without fee is hereby granted, provided that the above
7263635Sdes * copyright notice and this permission notice appear in all copies.
8263635Sdes *
9263635Sdes * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10263635Sdes * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11263635Sdes * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12263635Sdes * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13263635Sdes * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14263635Sdes * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15263635Sdes * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16263635Sdes */
17263635Sdes
18263635Sdes#ifndef _HMAC_H
19263635Sdes#define _HMAC_H
20263635Sdes
21263635Sdes/* Returns the algorithm's digest length in bytes or 0 for invalid algorithm */
22263635Sdessize_t ssh_hmac_bytes(int alg);
23263635Sdes
24263635Sdesstruct ssh_hmac_ctx;
25263635Sdesstruct ssh_hmac_ctx *ssh_hmac_start(int alg);
26263635Sdes
27263635Sdes/* Sets the state of the HMAC or resets the state if key == NULL */
28263635Sdesint ssh_hmac_init(struct ssh_hmac_ctx *ctx, const void *key, size_t klen)
29263635Sdes	__attribute__((__bounded__(__buffer__, 2, 3)));
30263635Sdesint ssh_hmac_update(struct ssh_hmac_ctx *ctx, const void *m, size_t mlen)
31263635Sdes	__attribute__((__bounded__(__buffer__, 2, 3)));
32263635Sdesint ssh_hmac_update_buffer(struct ssh_hmac_ctx *ctx, const Buffer *b);
33263635Sdesint ssh_hmac_final(struct ssh_hmac_ctx *ctx, u_char *d, size_t dlen)
34263635Sdes	__attribute__((__bounded__(__buffer__, 2, 3)));
35263635Sdesvoid ssh_hmac_free(struct ssh_hmac_ctx *ctx);
36263635Sdes
37263635Sdes#endif /* _HMAC_H */
38