Home | History | Annotate | Line # | Download | only in include
via_padlock.h revision 1.2.18.1
      1  1.2.18.1     jym /*	$NetBSD: via_padlock.h,v 1.2.18.1 2009/05/13 17:18:44 jym Exp $	*/
      2       1.1  daniel 
      3       1.1  daniel /*-
      4       1.1  daniel  * Copyright (c) 2003 Jason Wright
      5       1.1  daniel  * Copyright (c) 2003, 2004 Theo de Raadt
      6       1.1  daniel  * All rights reserved.
      7       1.1  daniel  *
      8       1.1  daniel  * Permission to use, copy, modify, and distribute this software for any
      9       1.1  daniel  * purpose with or without fee is hereby granted, provided that the above
     10       1.1  daniel  * copyright notice and this permission notice appear in all copies.
     11       1.1  daniel  *
     12       1.1  daniel  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13       1.1  daniel  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14       1.1  daniel  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15       1.1  daniel  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16       1.1  daniel  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17       1.1  daniel  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18       1.1  daniel  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19       1.1  daniel  */
     20       1.1  daniel 
     21       1.1  daniel #ifndef _X86_VIA_PADLOCK_H_
     22       1.1  daniel #define _X86_VIA_PADLOCK_H_
     23       1.1  daniel 
     24  1.2.18.1     jym #if defined(_KERNEL)
     25       1.1  daniel 
     26  1.2.18.1     jym #include <sys/rnd.h>
     27  1.2.18.1     jym #include <sys/callout.h>
     28       1.1  daniel #include <crypto/rijndael/rijndael.h>
     29       1.1  daniel 
     30       1.1  daniel /* VIA C3 xcrypt-* instruction context control options */
     31       1.1  daniel #define C3_CRYPT_CWLO_ROUND_M		0x0000000f
     32       1.1  daniel #define C3_CRYPT_CWLO_ALG_M		0x00000070
     33       1.1  daniel #define C3_CRYPT_CWLO_ALG_AES		0x00000000
     34       1.1  daniel #define C3_CRYPT_CWLO_KEYGEN_M		0x00000080
     35       1.1  daniel #define C3_CRYPT_CWLO_KEYGEN_HW		0x00000000
     36       1.1  daniel #define C3_CRYPT_CWLO_KEYGEN_SW		0x00000080
     37       1.1  daniel #define C3_CRYPT_CWLO_NORMAL		0x00000000
     38       1.1  daniel #define C3_CRYPT_CWLO_INTERMEDIATE	0x00000100
     39       1.1  daniel #define C3_CRYPT_CWLO_ENCRYPT		0x00000000
     40       1.1  daniel #define C3_CRYPT_CWLO_DECRYPT		0x00000200
     41       1.1  daniel #define C3_CRYPT_CWLO_KEY128		0x0000000a      /* 128bit, 10 rds */
     42       1.1  daniel #define C3_CRYPT_CWLO_KEY192		0x0000040c      /* 192bit, 12 rds */
     43       1.1  daniel #define C3_CRYPT_CWLO_KEY256		0x0000080e      /* 256bit, 15 rds */
     44       1.1  daniel 
     45       1.1  daniel struct via_padlock_session {
     46       1.2  cegger         uint32_t	ses_ekey[4 * (RIJNDAEL_MAXNR + 1) + 4];	/* 128 bit aligned */
     47       1.2  cegger         uint32_t	ses_dkey[4 * (RIJNDAEL_MAXNR + 1) + 4];	/* 128 bit aligned */
     48       1.2  cegger         uint8_t	ses_iv[16];				/* 128 bit aligned */
     49       1.2  cegger         uint32_t	ses_cw0;
     50       1.1  daniel         struct swcr_data	*swd;
     51       1.1  daniel         int	ses_klen;
     52       1.1  daniel         int	ses_used;
     53       1.1  daniel };
     54       1.1  daniel 
     55       1.1  daniel struct via_padlock_softc {
     56       1.2  cegger 	uint32_t	op_cw[4];	/* 128 bit aligned */
     57       1.2  cegger 	uint8_t	op_iv[16];	/* 128 bit aligned */
     58       1.1  daniel 	void		*op_buf;
     59       1.1  daniel 
     60  1.2.18.1     jym 	int			sc_rnd_hz;
     61  1.2.18.1     jym 	struct callout		sc_rnd_co;
     62  1.2.18.1     jym 	rndsource_element_t	sc_rnd_source;
     63  1.2.18.1     jym 
     64       1.1  daniel 	/* normal softc stuff */
     65       1.1  daniel 	int32_t		sc_cid;
     66       1.1  daniel 	int		sc_nsessions;
     67       1.1  daniel 	struct via_padlock_session *sc_sessions;
     68       1.1  daniel };
     69       1.1  daniel 
     70       1.1  daniel #define VIAC3_SESSION(sid)	((sid) & 0x0fffffff)
     71       1.1  daniel #define VIAC3_SID(crd,ses)	(((crd) << 28) | ((ses) & 0x0fffffff))
     72       1.1  daniel 
     73  1.2.18.1     jym #define VIAC3_RNG_BUFSIZ	16
     74  1.2.18.1     jym 
     75  1.2.18.1     jym void    via_padlock_attach(void);
     76  1.2.18.1     jym 
     77  1.2.18.1     jym #endif /* _KERNEL */
     78  1.2.18.1     jym 
     79  1.2.18.1     jym #if defined(_KERNEL) || defined(_KMEMUSER)
     80       1.1  daniel struct cpu_info;
     81       1.1  daniel 
     82       1.1  daniel struct via_padlock {
     83       1.1  daniel 	struct cpu_info		*vp_ci;
     84       1.1  daniel 	int			vp_freq;
     85       1.1  daniel };
     86       1.1  daniel 
     87  1.2.18.1     jym #endif /* _KERNEL || _KMEMUSER */
     88       1.1  daniel #endif /* _X86_VIA_PADLOCK_H_ */
     89