1*a0ee8cc6SDag-Erling Smørgrav /* $OpenBSD: hmac.h,v 1.9 2014/06/24 01:13:21 djm Exp $ */ 2b83788ffSDag-Erling Smørgrav /* 3b83788ffSDag-Erling Smørgrav * Copyright (c) 2014 Markus Friedl. All rights reserved. 4b83788ffSDag-Erling Smørgrav * 5b83788ffSDag-Erling Smørgrav * Permission to use, copy, modify, and distribute this software for any 6b83788ffSDag-Erling Smørgrav * purpose with or without fee is hereby granted, provided that the above 7b83788ffSDag-Erling Smørgrav * copyright notice and this permission notice appear in all copies. 8b83788ffSDag-Erling Smørgrav * 9b83788ffSDag-Erling Smørgrav * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10b83788ffSDag-Erling Smørgrav * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11b83788ffSDag-Erling Smørgrav * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12b83788ffSDag-Erling Smørgrav * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13b83788ffSDag-Erling Smørgrav * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14b83788ffSDag-Erling Smørgrav * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15b83788ffSDag-Erling Smørgrav * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16b83788ffSDag-Erling Smørgrav */ 17b83788ffSDag-Erling Smørgrav 18b83788ffSDag-Erling Smørgrav #ifndef _HMAC_H 19b83788ffSDag-Erling Smørgrav #define _HMAC_H 20b83788ffSDag-Erling Smørgrav 21b83788ffSDag-Erling Smørgrav /* Returns the algorithm's digest length in bytes or 0 for invalid algorithm */ 22b83788ffSDag-Erling Smørgrav size_t ssh_hmac_bytes(int alg); 23b83788ffSDag-Erling Smørgrav 24*a0ee8cc6SDag-Erling Smørgrav struct sshbuf; 25b83788ffSDag-Erling Smørgrav struct ssh_hmac_ctx; 26b83788ffSDag-Erling Smørgrav struct ssh_hmac_ctx *ssh_hmac_start(int alg); 27b83788ffSDag-Erling Smørgrav 28b83788ffSDag-Erling Smørgrav /* Sets the state of the HMAC or resets the state if key == NULL */ 29b83788ffSDag-Erling Smørgrav int ssh_hmac_init(struct ssh_hmac_ctx *ctx, const void *key, size_t klen) 30b83788ffSDag-Erling Smørgrav __attribute__((__bounded__(__buffer__, 2, 3))); 31b83788ffSDag-Erling Smørgrav int ssh_hmac_update(struct ssh_hmac_ctx *ctx, const void *m, size_t mlen) 32b83788ffSDag-Erling Smørgrav __attribute__((__bounded__(__buffer__, 2, 3))); 33*a0ee8cc6SDag-Erling Smørgrav int ssh_hmac_update_buffer(struct ssh_hmac_ctx *ctx, const struct sshbuf *b); 34b83788ffSDag-Erling Smørgrav int ssh_hmac_final(struct ssh_hmac_ctx *ctx, u_char *d, size_t dlen) 35b83788ffSDag-Erling Smørgrav __attribute__((__bounded__(__buffer__, 2, 3))); 36b83788ffSDag-Erling Smørgrav void ssh_hmac_free(struct ssh_hmac_ctx *ctx); 37b83788ffSDag-Erling Smørgrav 38b83788ffSDag-Erling Smørgrav #endif /* _HMAC_H */ 39