1*076ad2f8SDag-Erling Smørgrav /* $OpenBSD: mac.h,v 1.10 2016/07/08 03:44:42 djm Exp $ */ 21e8db6e2SBrian Feldman /* 31e8db6e2SBrian Feldman * Copyright (c) 2001 Markus Friedl. All rights reserved. 41e8db6e2SBrian Feldman * 51e8db6e2SBrian Feldman * Redistribution and use in source and binary forms, with or without 61e8db6e2SBrian Feldman * modification, are permitted provided that the following conditions 71e8db6e2SBrian Feldman * are met: 81e8db6e2SBrian Feldman * 1. Redistributions of source code must retain the above copyright 91e8db6e2SBrian Feldman * notice, this list of conditions and the following disclaimer. 101e8db6e2SBrian Feldman * 2. Redistributions in binary form must reproduce the above copyright 111e8db6e2SBrian Feldman * notice, this list of conditions and the following disclaimer in the 121e8db6e2SBrian Feldman * documentation and/or other materials provided with the distribution. 131e8db6e2SBrian Feldman * 141e8db6e2SBrian Feldman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 151e8db6e2SBrian Feldman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 161e8db6e2SBrian Feldman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 171e8db6e2SBrian Feldman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 181e8db6e2SBrian Feldman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 191e8db6e2SBrian Feldman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 201e8db6e2SBrian Feldman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 211e8db6e2SBrian Feldman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 221e8db6e2SBrian Feldman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 231e8db6e2SBrian Feldman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 241e8db6e2SBrian Feldman */ 251e8db6e2SBrian Feldman 26bc5531deSDag-Erling Smørgrav #ifndef SSHMAC_H 27bc5531deSDag-Erling Smørgrav #define SSHMAC_H 28bc5531deSDag-Erling Smørgrav 29bc5531deSDag-Erling Smørgrav #include <sys/types.h> 30bc5531deSDag-Erling Smørgrav 31bc5531deSDag-Erling Smørgrav struct sshmac { 32bc5531deSDag-Erling Smørgrav char *name; 33bc5531deSDag-Erling Smørgrav int enabled; 34bc5531deSDag-Erling Smørgrav u_int mac_len; 35bc5531deSDag-Erling Smørgrav u_char *key; 36bc5531deSDag-Erling Smørgrav u_int key_len; 37bc5531deSDag-Erling Smørgrav int type; 38bc5531deSDag-Erling Smørgrav int etm; /* Encrypt-then-MAC */ 39bc5531deSDag-Erling Smørgrav struct ssh_hmac_ctx *hmac_ctx; 40bc5531deSDag-Erling Smørgrav struct umac_ctx *umac_ctx; 41bc5531deSDag-Erling Smørgrav }; 42bc5531deSDag-Erling Smørgrav 43ae1f160dSDag-Erling Smørgrav int mac_valid(const char *); 44f7167e0eSDag-Erling Smørgrav char *mac_alg_list(char); 45bc5531deSDag-Erling Smørgrav int mac_setup(struct sshmac *, char *); 46bc5531deSDag-Erling Smørgrav int mac_init(struct sshmac *); 47bc5531deSDag-Erling Smørgrav int mac_compute(struct sshmac *, u_int32_t, const u_char *, int, 48bc5531deSDag-Erling Smørgrav u_char *, size_t); 49*076ad2f8SDag-Erling Smørgrav int mac_check(struct sshmac *, u_int32_t, const u_char *, size_t, 50*076ad2f8SDag-Erling Smørgrav const u_char *, size_t); 51bc5531deSDag-Erling Smørgrav void mac_clear(struct sshmac *); 52bc5531deSDag-Erling Smørgrav 53bc5531deSDag-Erling Smørgrav #endif /* SSHMAC_H */ 54