1 /*
2  * Octeon Crypto for OCF
3  *
4  * Written by David McCullough <[email protected]>
5  * Copyright (C) 2009 David McCullough
6  *
7  * LICENSE TERMS
8  *
9  * The free distribution and use of this software in both source and binary
10  * form is allowed (with or without changes) provided that:
11  *
12  *   1. distributions of this source code include the above copyright
13  *      notice, this list of conditions and the following disclaimer;
14  *
15  *   2. distributions in binary form include the above copyright
16  *      notice, this list of conditions and the following disclaimer
17  *      in the documentation and/or other associated materials;
18  *
19  *   3. the copyright holder's name is not used to endorse products
20  *      built using this software without specific written permission.
21  *
22  * DISCLAIMER
23  *
24  * This software is provided 'as is' with no explicit or implied warranties
25  * in respect of its properties, including, but not limited to, correctness
26  * and/or fitness for purpose.
27  * ---------------------------------------------------------------------------
28  *
29  * $FreeBSD$
30  */
31 
32 #ifndef	_MIPS_CAVIUM_CRYPTOCTEON_CRYPTOCTEONVAR_H_
33 #define	_MIPS_CAVIUM_CRYPTOCTEON_CRYPTOCTEONVAR_H_
34 
35 struct octo_sess;
36 
37 typedef	int octo_encrypt_t(struct octo_sess *od, struct iovec *iov, size_t iovcnt, size_t iovlen, int auth_off, int auth_len, int crypt_off, int crypt_len, uint8_t *icv, uint8_t *ivp);
38 typedef	int octo_decrypt_t(struct octo_sess *od, struct iovec *iov, size_t iovcnt, size_t iovlen, int auth_off, int auth_len, int crypt_off, int crypt_len, uint8_t *icv, uint8_t *ivp);
39 
40 struct octo_sess {
41 	#define MAX_CIPHER_KEYLEN	64
42 	char				 octo_enckey[MAX_CIPHER_KEYLEN];
43 	int					 octo_encklen;
44 
45 	int					 octo_mlen;
46 
47 	octo_encrypt_t				*octo_encrypt;
48 	octo_decrypt_t				*octo_decrypt;
49 
50 	uint64_t			 octo_hminner[3];
51 	uint64_t			 octo_hmouter[3];
52 
53 	struct iovec				octo_iov[UIO_MAXIOV];
54 };
55 
56 #define	dprintf(fmt, ...)						\
57 	do {								\
58 		if (cryptocteon_debug)					\
59 			printf("%s: " fmt, __func__, ## __VA_ARGS__);	\
60 	} while (0)
61 
62 extern int cryptocteon_debug;
63 
64 void octo_calc_hash(uint8_t, unsigned char *, uint64_t *, uint64_t *);
65 
66 /* XXX Actually just hashing functions, not encryption.  */
67 octo_encrypt_t octo_null_sha1_encrypt;
68 
69 octo_encrypt_t octo_aes_cbc_encrypt;
70 octo_encrypt_t octo_aes_cbc_sha1_encrypt;
71 
72 octo_decrypt_t octo_aes_cbc_decrypt;
73 octo_decrypt_t octo_aes_cbc_sha1_decrypt;
74 
75 #endif /* !_MIPS_CAVIUM_CRYPTOCTEON_CRYPTOCTEONVAR_H_ */
76