cryptocteonvar.h revision 210312
142660Smarkm/*
2146515Sru * Octeon Crypto for OCF
321495Sjmacd *
442660Smarkm * Written by David McCullough <david_mccullough@securecomputing.com>
521495Sjmacd * Copyright (C) 2009 David McCullough
621495Sjmacd *
7146515Sru * LICENSE TERMS
821495Sjmacd *
921495Sjmacd * The free distribution and use of this software in both source and binary
1021495Sjmacd * form is allowed (with or without changes) provided that:
1121495Sjmacd *
1221495Sjmacd *   1. distributions of this source code include the above copyright
1321495Sjmacd *      notice, this list of conditions and the following disclaimer;
1421495Sjmacd *
1521495Sjmacd *   2. distributions in binary form include the above copyright
1621495Sjmacd *      notice, this list of conditions and the following disclaimer
1721495Sjmacd *      in the documentation and/or other associated materials;
1821495Sjmacd *
1921495Sjmacd *   3. the copyright holder's name is not used to endorse products
2021495Sjmacd *      built using this software without specific written permission.
2121495Sjmacd *
2221495Sjmacd * DISCLAIMER
2321495Sjmacd *
2421495Sjmacd * This software is provided 'as is' with no explicit or implied warranties
2542660Smarkm * in respect of its properties, including, but not limited to, correctness
2642660Smarkm * and/or fitness for purpose.
2721495Sjmacd * ---------------------------------------------------------------------------
2821495Sjmacd *
2921495Sjmacd * $FreeBSD: head/sys/mips/cavium/cryptocteon/cryptocteonvar.h 210312 2010-07-20 19:32:25Z jmallett $
30146515Sru */
31146515Sru
32146515Sru#ifndef	_MIPS_CAVIUM_CRYPTOCTEON_CRYPTOCTEONVAR_H_
33146515Sru#define	_MIPS_CAVIUM_CRYPTOCTEON_CRYPTOCTEONVAR_H_
34146515Sru
35146515Srustruct octo_sess;
36146515Sru
37146515Srutypedef	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, int icv_off, uint8_t *ivp);
3821495Sjmacdtypedef	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, int icv_off, uint8_t *ivp);
3942660Smarkm
40struct octo_sess {
41	int					 octo_encalg;
42	#define MAX_CIPHER_KEYLEN	64
43	char				 octo_enckey[MAX_CIPHER_KEYLEN];
44	int					 octo_encklen;
45
46	int					 octo_macalg;
47	#define MAX_HASH_KEYLEN	64
48	char				 octo_mackey[MAX_HASH_KEYLEN];
49	int					 octo_macklen;
50	int					 octo_mackey_set;
51
52	int					 octo_mlen;
53	int					 octo_ivsize;
54
55	octo_encrypt_t				*octo_encrypt;
56	octo_decrypt_t				*octo_decrypt;
57
58	uint64_t			 octo_hminner[3];
59	uint64_t			 octo_hmouter[3];
60
61	struct iovec				octo_iov[UIO_MAXIOV];
62};
63
64#define	dprintf(fmt, ...)						\
65	do {								\
66		if (cryptocteon_debug)					\
67			printf("%s: " fmt, __func__, ## __VA_ARGS__);	\
68	} while (0)
69
70extern int cryptocteon_debug;
71
72void octo_calc_hash(uint8_t, unsigned char *, uint64_t *, uint64_t *);
73
74/* XXX Actually just hashing functions, not encryption.  */
75octo_encrypt_t octo_null_md5_encrypt;
76octo_encrypt_t octo_null_sha1_encrypt;
77
78octo_encrypt_t octo_des_cbc_encrypt;
79octo_encrypt_t octo_des_cbc_md5_encrypt;
80octo_encrypt_t octo_des_cbc_sha1_encrypt;
81
82octo_decrypt_t octo_des_cbc_decrypt;
83octo_decrypt_t octo_des_cbc_md5_decrypt;
84octo_decrypt_t octo_des_cbc_sha1_decrypt;
85
86octo_encrypt_t octo_aes_cbc_encrypt;
87octo_encrypt_t octo_aes_cbc_md5_encrypt;
88octo_encrypt_t octo_aes_cbc_sha1_encrypt;
89
90octo_decrypt_t octo_aes_cbc_decrypt;
91octo_decrypt_t octo_aes_cbc_md5_decrypt;
92octo_decrypt_t octo_aes_cbc_sha1_decrypt;
93
94#endif /* !_MIPS_CAVIUM_CRYPTOCTEON_CRYPTOCTEONVAR_H_ */
95