xref: /dflybsd-src/crypto/openssh/mac.h (revision e9778795382169f8c6fde18d0565a1acef2cac8b)
1*e9778795SPeter Avalos /* $OpenBSD: mac.h,v 1.10 2016/07/08 03:44:42 djm Exp $ */
218de8d7fSPeter Avalos /*
318de8d7fSPeter Avalos  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
418de8d7fSPeter Avalos  *
518de8d7fSPeter Avalos  * Redistribution and use in source and binary forms, with or without
618de8d7fSPeter Avalos  * modification, are permitted provided that the following conditions
718de8d7fSPeter Avalos  * are met:
818de8d7fSPeter Avalos  * 1. Redistributions of source code must retain the above copyright
918de8d7fSPeter Avalos  *    notice, this list of conditions and the following disclaimer.
1018de8d7fSPeter Avalos  * 2. Redistributions in binary form must reproduce the above copyright
1118de8d7fSPeter Avalos  *    notice, this list of conditions and the following disclaimer in the
1218de8d7fSPeter Avalos  *    documentation and/or other materials provided with the distribution.
1318de8d7fSPeter Avalos  *
1418de8d7fSPeter Avalos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1518de8d7fSPeter Avalos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1618de8d7fSPeter Avalos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1718de8d7fSPeter Avalos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1818de8d7fSPeter Avalos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1918de8d7fSPeter Avalos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2018de8d7fSPeter Avalos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2118de8d7fSPeter Avalos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2218de8d7fSPeter Avalos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2318de8d7fSPeter Avalos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2418de8d7fSPeter Avalos  */
2518de8d7fSPeter Avalos 
26*e9778795SPeter Avalos #ifndef SSHMAC_H
27*e9778795SPeter Avalos #define SSHMAC_H
28*e9778795SPeter Avalos 
29*e9778795SPeter Avalos #include <sys/types.h>
30*e9778795SPeter Avalos 
31*e9778795SPeter Avalos struct sshmac {
32*e9778795SPeter Avalos 	char	*name;
33*e9778795SPeter Avalos 	int	enabled;
34*e9778795SPeter Avalos 	u_int	mac_len;
35*e9778795SPeter Avalos 	u_char	*key;
36*e9778795SPeter Avalos 	u_int	key_len;
37*e9778795SPeter Avalos 	int	type;
38*e9778795SPeter Avalos 	int	etm;		/* Encrypt-then-MAC */
39*e9778795SPeter Avalos 	struct ssh_hmac_ctx	*hmac_ctx;
40*e9778795SPeter Avalos 	struct umac_ctx		*umac_ctx;
41*e9778795SPeter Avalos };
42*e9778795SPeter Avalos 
4318de8d7fSPeter Avalos int	 mac_valid(const char *);
4436e94dc5SPeter Avalos char	*mac_alg_list(char);
45*e9778795SPeter Avalos int	 mac_setup(struct sshmac *, char *);
46*e9778795SPeter Avalos int	 mac_init(struct sshmac *);
47*e9778795SPeter Avalos int	 mac_compute(struct sshmac *, u_int32_t, const u_char *, int,
48*e9778795SPeter Avalos     u_char *, size_t);
49*e9778795SPeter Avalos int	 mac_check(struct sshmac *, u_int32_t, const u_char *, size_t,
50*e9778795SPeter Avalos     const u_char *, size_t);
51*e9778795SPeter Avalos void	 mac_clear(struct sshmac *);
52*e9778795SPeter Avalos 
53*e9778795SPeter Avalos #endif /* SSHMAC_H */
54