Home | History | Annotate | Line # | Download | only in include
      1  1.10  riastrad /*	$NetBSD: via_padlock.h,v 1.10 2020/06/29 23:38:02 riastradh 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.5  drochner #if defined(_KERNEL)
     25   1.1    daniel 
     26   1.8  riastrad #include <sys/rndsource.h>
     27   1.4       tls #include <sys/callout.h>
     28  1.10  riastrad 
     29  1.10  riastrad #include <crypto/aes/aes.h>
     30   1.1    daniel 
     31   1.1    daniel /* VIA C3 xcrypt-* instruction context control options */
     32   1.1    daniel #define C3_CRYPT_CWLO_ROUND_M		0x0000000f
     33   1.1    daniel #define C3_CRYPT_CWLO_ALG_M		0x00000070
     34   1.1    daniel #define C3_CRYPT_CWLO_ALG_AES		0x00000000
     35   1.1    daniel #define C3_CRYPT_CWLO_KEYGEN_M		0x00000080
     36   1.1    daniel #define C3_CRYPT_CWLO_KEYGEN_HW		0x00000000
     37   1.1    daniel #define C3_CRYPT_CWLO_KEYGEN_SW		0x00000080
     38   1.1    daniel #define C3_CRYPT_CWLO_NORMAL		0x00000000
     39   1.1    daniel #define C3_CRYPT_CWLO_INTERMEDIATE	0x00000100
     40   1.1    daniel #define C3_CRYPT_CWLO_ENCRYPT		0x00000000
     41   1.1    daniel #define C3_CRYPT_CWLO_DECRYPT		0x00000200
     42   1.1    daniel #define C3_CRYPT_CWLO_KEY128		0x0000000a      /* 128bit, 10 rds */
     43   1.1    daniel #define C3_CRYPT_CWLO_KEY192		0x0000040c      /* 192bit, 12 rds */
     44   1.1    daniel #define C3_CRYPT_CWLO_KEY256		0x0000080e      /* 256bit, 15 rds */
     45   1.1    daniel 
     46   1.1    daniel struct via_padlock_session {
     47  1.10  riastrad         uint32_t	ses_ekey[4*(AES_256_NROUNDS + 1)];
     48  1.10  riastrad         uint32_t	ses_dkey[4*(AES_256_NROUNDS + 1)];
     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.6  jmcneill 	device_t	sc_dev;
     57   1.6  jmcneill 
     58   1.2    cegger 	uint32_t	op_cw[4];	/* 128 bit aligned */
     59   1.2    cegger 	uint8_t	op_iv[16];	/* 128 bit aligned */
     60   1.1    daniel 	void		*op_buf;
     61   1.1    daniel 
     62   1.1    daniel 	/* normal softc stuff */
     63   1.1    daniel 	int32_t		sc_cid;
     64   1.6  jmcneill 	bool		sc_cid_attached;
     65   1.1    daniel 	int		sc_nsessions;
     66   1.1    daniel 	struct via_padlock_session *sc_sessions;
     67   1.1    daniel };
     68   1.1    daniel 
     69   1.1    daniel #define VIAC3_SESSION(sid)	((sid) & 0x0fffffff)
     70   1.1    daniel #define VIAC3_SID(crd,ses)	(((crd) << 28) | ((ses) & 0x0fffffff))
     71   1.1    daniel 
     72   1.5  drochner #endif /* _KERNEL */
     73   1.5  drochner 
     74   1.5  drochner #if defined(_KERNEL) || defined(_KMEMUSER)
     75   1.1    daniel struct cpu_info;
     76   1.1    daniel 
     77   1.1    daniel struct via_padlock {
     78   1.1    daniel 	struct cpu_info		*vp_ci;
     79   1.1    daniel 	int			vp_freq;
     80   1.1    daniel };
     81   1.1    daniel 
     82   1.3        ad #endif /* _KERNEL || _KMEMUSER */
     83   1.1    daniel #endif /* _X86_VIA_PADLOCK_H_ */
     84