padlock.h revision 303975
1214152Sed/*- 2214152Sed * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> 3214152Sed * All rights reserved. 4214152Sed * 5222656Sed * Redistribution and use in source and binary forms, with or without 6222656Sed * modification, are permitted provided that the following conditions 7214152Sed * are met: 8214152Sed * 1. Redistributions of source code must retain the above copyright 9214152Sed * notice, this list of conditions and the following disclaimer. 10214152Sed * 2. Redistributions in binary form must reproduce the above copyright 11214152Sed * notice, this list of conditions and the following disclaimer in the 12214152Sed * documentation and/or other materials provided with the distribution. 13214152Sed * 14214152Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 15239138Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16239138Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17263763Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 18214152Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19214152Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20214152Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21214152Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22214152Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23214152Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24214152Sed * SUCH DAMAGE. 25214152Sed * 26214152Sed * $FreeBSD: releng/11.0/sys/crypto/via/padlock.h 230426 2012-01-21 17:45:27Z kib $ 27214152Sed */ 28214152Sed 29214152Sed#ifndef _PADLOCK_H_ 30263763Sdim#define _PADLOCK_H_ 31 32#include <opencrypto/cryptodev.h> 33#include <crypto/rijndael/rijndael.h> 34 35#if defined(__i386__) 36#include <machine/npx.h> 37#elif defined(__amd64__) 38#include <machine/fpu.h> 39#endif 40 41union padlock_cw { 42 uint64_t raw; 43 struct { 44 u_int round_count : 4; 45 u_int algorithm_type : 3; 46 u_int key_generation : 1; 47 u_int intermediate : 1; 48 u_int direction : 1; 49 u_int key_size : 2; 50 u_int filler0 : 20; 51 u_int filler1 : 32; 52 u_int filler2 : 32; 53 u_int filler3 : 32; 54 } __field; 55}; 56#define cw_round_count __field.round_count 57#define cw_algorithm_type __field.algorithm_type 58#define cw_key_generation __field.key_generation 59#define cw_intermediate __field.intermediate 60#define cw_direction __field.direction 61#define cw_key_size __field.key_size 62#define cw_filler0 __field.filler0 63#define cw_filler1 __field.filler1 64#define cw_filler2 __field.filler2 65#define cw_filler3 __field.filler3 66 67struct padlock_session { 68 union padlock_cw ses_cw __aligned(16); 69 uint32_t ses_ekey[4 * (RIJNDAEL_MAXNR + 1) + 4] __aligned(16); /* 128 bit aligned */ 70 uint32_t ses_dkey[4 * (RIJNDAEL_MAXNR + 1) + 4] __aligned(16); /* 128 bit aligned */ 71 uint8_t ses_iv[16] __aligned(16); /* 128 bit aligned */ 72 struct auth_hash *ses_axf; 73 uint8_t *ses_ictx; 74 uint8_t *ses_octx; 75 int ses_mlen; 76 int ses_used; 77 uint32_t ses_id; 78 TAILQ_ENTRY(padlock_session) ses_next; 79 struct fpu_kern_ctx *ses_fpu_ctx; 80}; 81 82#define PADLOCK_ALIGN(p) (void *)(roundup2((uintptr_t)(p), 16)) 83 84int padlock_cipher_setup(struct padlock_session *ses, 85 struct cryptoini *encini); 86int padlock_cipher_process(struct padlock_session *ses, 87 struct cryptodesc *enccrd, struct cryptop *crp); 88int padlock_hash_setup(struct padlock_session *ses, 89 struct cryptoini *macini); 90int padlock_hash_process(struct padlock_session *ses, 91 struct cryptodesc *maccrd, struct cryptop *crp); 92void padlock_hash_free(struct padlock_session *ses); 93 94#endif /* !_PADLOCK_H_ */ 95