root / lab4 / .minix-src / include / x86 / via_padlock.h @ 13
History | View | Annotate | Download (2.79 KB)
1 |
/* $NetBSD: via_padlock.h,v 1.8 2015/04/13 16:03:51 riastradh Exp $ */
|
---|---|
2 |
|
3 |
/*-
|
4 |
* Copyright (c) 2003 Jason Wright
|
5 |
* Copyright (c) 2003, 2004 Theo de Raadt
|
6 |
* All rights reserved.
|
7 |
*
|
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.
|
11 |
*
|
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.
|
19 |
*/
|
20 |
|
21 |
#ifndef _X86_VIA_PADLOCK_H_
|
22 |
#define _X86_VIA_PADLOCK_H_
|
23 |
|
24 |
#if defined(_KERNEL)
|
25 |
|
26 |
#include <sys/rndsource.h> |
27 |
#include <sys/callout.h> |
28 |
#include <crypto/rijndael/rijndael.h> |
29 |
|
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 */ |
44 |
|
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 */ |
49 |
uint32_t ses_cw0; |
50 |
struct swcr_data *swd;
|
51 |
int ses_klen;
|
52 |
int ses_used;
|
53 |
}; |
54 |
|
55 |
struct via_padlock_softc {
|
56 |
device_t sc_dev; |
57 |
|
58 |
uint32_t op_cw[4]; /* 128 bit aligned */ |
59 |
uint8_t op_iv[16]; /* 128 bit aligned */ |
60 |
void *op_buf;
|
61 |
|
62 |
int sc_rnd_hz;
|
63 |
struct callout sc_rnd_co;
|
64 |
krndsource_t sc_rnd_source; |
65 |
bool sc_rnd_attached;
|
66 |
|
67 |
/* normal softc stuff */
|
68 |
int32_t sc_cid; |
69 |
bool sc_cid_attached;
|
70 |
int sc_nsessions;
|
71 |
struct via_padlock_session *sc_sessions;
|
72 |
}; |
73 |
|
74 |
#define VIAC3_SESSION(sid) ((sid) & 0x0fffffff) |
75 |
#define VIAC3_SID(crd,ses) (((crd) << 28) | ((ses) & 0x0fffffff)) |
76 |
|
77 |
#define VIAC3_RNG_BUFSIZ 16 |
78 |
|
79 |
#endif /* _KERNEL */ |
80 |
|
81 |
#if defined(_KERNEL) || defined(_KMEMUSER)
|
82 |
struct cpu_info;
|
83 |
|
84 |
struct via_padlock {
|
85 |
struct cpu_info *vp_ci;
|
86 |
int vp_freq;
|
87 |
}; |
88 |
|
89 |
#endif /* _KERNEL || _KMEMUSER */ |
90 |
#endif /* _X86_VIA_PADLOCK_H_ */ |