1 /* $NetBSD: via_padlock.h,v 1.4 2009/04/01 03:56:54 tls Exp $ */
4 * Copyright (c) 2003 Jason Wright
5 * Copyright (c) 2003, 2004 Theo de Raadt
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #ifndef _X86_VIA_PADLOCK_H_
22 #define _X86_VIA_PADLOCK_H_
27 #include <sys/callout.h>
28 #include <crypto/rijndael/rijndael.h>
30 /* VIA C3 xcrypt-* instruction context control options */
31 #define C3_CRYPT_CWLO_ROUND_M 0x0000000f
32 #define C3_CRYPT_CWLO_ALG_M 0x00000070
33 #define C3_CRYPT_CWLO_ALG_AES 0x00000000
34 #define C3_CRYPT_CWLO_KEYGEN_M 0x00000080
35 #define C3_CRYPT_CWLO_KEYGEN_HW 0x00000000
36 #define C3_CRYPT_CWLO_KEYGEN_SW 0x00000080
37 #define C3_CRYPT_CWLO_NORMAL 0x00000000
38 #define C3_CRYPT_CWLO_INTERMEDIATE 0x00000100
39 #define C3_CRYPT_CWLO_ENCRYPT 0x00000000
40 #define C3_CRYPT_CWLO_DECRYPT 0x00000200
41 #define C3_CRYPT_CWLO_KEY128 0x0000000a /* 128bit, 10 rds */
42 #define C3_CRYPT_CWLO_KEY192 0x0000040c /* 192bit, 12 rds */
43 #define C3_CRYPT_CWLO_KEY256 0x0000080e /* 256bit, 15 rds */
45 struct via_padlock_session
{
46 uint32_t ses_ekey
[4 * (RIJNDAEL_MAXNR
+ 1) + 4]; /* 128 bit aligned */
47 uint32_t ses_dkey
[4 * (RIJNDAEL_MAXNR
+ 1) + 4]; /* 128 bit aligned */
48 uint8_t ses_iv
[16]; /* 128 bit aligned */
50 struct swcr_data
*swd
;
55 struct via_padlock_softc
{
56 uint32_t op_cw
[4]; /* 128 bit aligned */
57 uint8_t op_iv
[16]; /* 128 bit aligned */
61 struct callout sc_rnd_co
;
62 rndsource_element_t sc_rnd_source
;
64 /* normal softc stuff */
67 struct via_padlock_session
*sc_sessions
;
70 #define VIAC3_SESSION(sid) ((sid) & 0x0fffffff)
71 #define VIAC3_SID(crd,ses) (((crd) << 28) | ((ses) & 0x0fffffff))
73 #define VIAC3_RNG_BUFSIZ 16
75 void via_padlock_attach(void);
79 #if defined(_KERNEL) || defined(_KMEMUSER)
83 struct cpu_info
*vp_ci
;
87 #endif /* _KERNEL || _KMEMUSER */
88 #endif /* _X86_VIA_PADLOCK_H_ */