xform_auth.h revision 275732
1104476Ssam/*	$FreeBSD: head/sys/opencrypto/xform.h 275732 2014-12-12 19:56:36Z jmg $	*/
2104476Ssam/*	$OpenBSD: xform.h,v 1.8 2001/08/28 12:20:43 ben Exp $	*/
3104476Ssam
4139825Simp/*-
5104476Ssam * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
6104476Ssam *
7104476Ssam * This code was written by Angelos D. Keromytis in Athens, Greece, in
8104476Ssam * February 2000. Network Security Technologies Inc. (NSTI) kindly
9104476Ssam * supported the development of this code.
10104476Ssam *
11104476Ssam * Copyright (c) 2000 Angelos D. Keromytis
12275732Sjmg * Copyright (c) 2014 The FreeBSD Foundation
13275732Sjmg * All rights reserved.
14104476Ssam *
15275732Sjmg * Portions of this software were developed by John-Mark Gurney
16275732Sjmg * under sponsorship of the FreeBSD Foundation and
17275732Sjmg * Rubicon Communications, LLC (Netgate).
18275732Sjmg *
19104476Ssam * Permission to use, copy, and modify this software without fee
20104476Ssam * is hereby granted, provided that this entire notice is included in
21104476Ssam * all source code copies of any software which is or includes a copy or
22104476Ssam * modification of this software.
23104476Ssam *
24104476Ssam * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
25104476Ssam * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
26104476Ssam * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
27104476Ssam * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
28104476Ssam * PURPOSE.
29104476Ssam */
30104476Ssam
31104476Ssam#ifndef _CRYPTO_XFORM_H_
32104476Ssam#define _CRYPTO_XFORM_H_
33104476Ssam
34104476Ssam#include <sys/md5.h>
35104476Ssam#include <crypto/sha1.h>
36104476Ssam#include <crypto/sha2/sha2.h>
37104476Ssam#include <opencrypto/rmd160.h>
38275732Sjmg#include <opencrypto/gmac.h>
39104476Ssam
40104476Ssam/* Declarations */
41104476Ssamstruct auth_hash {
42104476Ssam	int type;
43104476Ssam	char *name;
44104476Ssam	u_int16_t keysize;
45104476Ssam	u_int16_t hashsize;
46275732Sjmg	u_int16_t ctxsize;
47158703Spjd	u_int16_t blocksize;
48104476Ssam	void (*Init) (void *);
49275732Sjmg	void (*Setkey) (void *, const u_int8_t *, u_int16_t);
50275732Sjmg	void (*Reinit) (void *, const u_int8_t *, u_int16_t);
51275732Sjmg	int  (*Update) (void *, const u_int8_t *, u_int16_t);
52104476Ssam	void (*Final) (u_int8_t *, void *);
53104476Ssam};
54104476Ssam
55219026Svanhu/* XXX use a define common with other hash stuff ! */
56219026Svanhu#define	AH_ALEN_MAX	64	/* max authenticator hash length */
57104476Ssam
58104476Ssamstruct enc_xform {
59104476Ssam	int type;
60104476Ssam	char *name;
61104476Ssam	u_int16_t blocksize;
62275732Sjmg	u_int16_t ivsize;
63104476Ssam	u_int16_t minkey, maxkey;
64104476Ssam	void (*encrypt) (caddr_t, u_int8_t *);
65104476Ssam	void (*decrypt) (caddr_t, u_int8_t *);
66104476Ssam	int (*setkey) (u_int8_t **, u_int8_t *, int len);
67104476Ssam	void (*zerokey) (u_int8_t **);
68213068Spjd	void (*reinit) (caddr_t, u_int8_t *);
69104476Ssam};
70104476Ssam
71104476Ssamstruct comp_algo {
72104476Ssam	int type;
73104476Ssam	char *name;
74104476Ssam	size_t minlen;
75104476Ssam	u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
76104476Ssam	u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
77104476Ssam};
78104476Ssam
79104476Ssamunion authctx {
80104476Ssam	MD5_CTX md5ctx;
81104476Ssam	SHA1_CTX sha1ctx;
82104476Ssam	RMD160_CTX rmd160ctx;
83104476Ssam	SHA256_CTX sha256ctx;
84104476Ssam	SHA384_CTX sha384ctx;
85104476Ssam	SHA512_CTX sha512ctx;
86275732Sjmg	struct aes_gmac_ctx aes_gmac_ctx;
87104476Ssam};
88104476Ssam
89104476Ssamextern struct enc_xform enc_xform_null;
90104476Ssamextern struct enc_xform enc_xform_des;
91104476Ssamextern struct enc_xform enc_xform_3des;
92104476Ssamextern struct enc_xform enc_xform_blf;
93104476Ssamextern struct enc_xform enc_xform_cast5;
94104476Ssamextern struct enc_xform enc_xform_skipjack;
95104476Ssamextern struct enc_xform enc_xform_rijndael128;
96275732Sjmgextern struct enc_xform enc_xform_aes_icm;
97275732Sjmgextern struct enc_xform enc_xform_aes_nist_gcm;
98275732Sjmgextern struct enc_xform enc_xform_aes_nist_gmac;
99213068Spjdextern struct enc_xform enc_xform_aes_xts;
100104476Ssamextern struct enc_xform enc_xform_arc4;
101169425Sgnnextern struct enc_xform enc_xform_camellia;
102104476Ssam
103104476Ssamextern struct auth_hash auth_hash_null;
104104476Ssamextern struct auth_hash auth_hash_key_md5;
105104476Ssamextern struct auth_hash auth_hash_key_sha1;
106158703Spjdextern struct auth_hash auth_hash_hmac_md5;
107158703Spjdextern struct auth_hash auth_hash_hmac_sha1;
108158703Spjdextern struct auth_hash auth_hash_hmac_ripemd_160;
109104476Ssamextern struct auth_hash auth_hash_hmac_sha2_256;
110104476Ssamextern struct auth_hash auth_hash_hmac_sha2_384;
111104476Ssamextern struct auth_hash auth_hash_hmac_sha2_512;
112275732Sjmgextern struct auth_hash auth_hash_nist_gmac_aes_128;
113275732Sjmgextern struct auth_hash auth_hash_nist_gmac_aes_192;
114275732Sjmgextern struct auth_hash auth_hash_nist_gmac_aes_256;
115104476Ssam
116104476Ssamextern struct comp_algo comp_algo_deflate;
117104476Ssam
118104476Ssam#ifdef _KERNEL
119104476Ssam#include <sys/malloc.h>
120104476SsamMALLOC_DECLARE(M_XDATA);
121104476Ssam#endif
122104476Ssam#endif /* _CRYPTO_XFORM_H_ */
123