The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/crypto/aesni/aesni.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2010 Konstantin Belousov <kib@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #ifndef _AESNI_H_
   30 #define _AESNI_H_
   31 
   32 #include <sys/types.h>
   33 #include <sys/malloc.h>
   34 #include <sys/queue.h>
   35 
   36 #include <opencrypto/cryptodev.h>
   37 
   38 #if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
   39 #include <machine/cpufunc.h>
   40 #include <machine/cputypes.h>
   41 #include <machine/md_var.h>
   42 #include <machine/specialreg.h>
   43 #endif
   44 #if defined(__i386__)
   45 #include <machine/npx.h>
   46 #elif defined(__amd64__)
   47 #include <machine/fpu.h>
   48 #endif
   49 
   50 #define AES128_ROUNDS   10
   51 #define AES192_ROUNDS   12
   52 #define AES256_ROUNDS   14
   53 #define AES_SCHED_LEN   ((AES256_ROUNDS + 1) * AES_BLOCK_LEN)
   54 
   55 struct aesni_session {
   56         uint8_t enc_schedule[AES_SCHED_LEN] __aligned(16);
   57         uint8_t dec_schedule[AES_SCHED_LEN] __aligned(16);
   58         uint8_t xts_schedule[AES_SCHED_LEN] __aligned(16);
   59         uint8_t iv[AES_BLOCK_LEN];
   60         int algo;
   61         int rounds;
   62         /* uint8_t *ses_ictx; */
   63         /* uint8_t *ses_octx; */
   64         /* int ses_mlen; */
   65         int used;
   66         uint32_t id;
   67         TAILQ_ENTRY(aesni_session) next;
   68 };
   69 
   70 /*
   71  * Internal functions, implemented in assembler.
   72  */
   73 void aesni_set_enckey(const uint8_t *userkey,
   74     uint8_t *encrypt_schedule /*__aligned(16)*/, int number_of_rounds);
   75 void aesni_set_deckey(const uint8_t *encrypt_schedule /*__aligned(16)*/,
   76     uint8_t *decrypt_schedule /*__aligned(16)*/, int number_of_rounds);
   77 
   78 /*
   79  * Slightly more public interfaces.
   80  */
   81 void aesni_encrypt_cbc(int rounds, const void *key_schedule /*__aligned(16)*/,
   82     size_t len, const uint8_t *from, uint8_t *to,
   83     const uint8_t iv[AES_BLOCK_LEN]);
   84 void aesni_decrypt_cbc(int rounds, const void *key_schedule /*__aligned(16)*/,
   85     size_t len, uint8_t *buf, const uint8_t iv[AES_BLOCK_LEN]);
   86 void aesni_encrypt_ecb(int rounds, const void *key_schedule /*__aligned(16)*/,
   87     size_t len, const uint8_t *from, uint8_t *to);
   88 void aesni_decrypt_ecb(int rounds, const void *key_schedule /*__aligned(16)*/,
   89     size_t len, const uint8_t *from, uint8_t *to);
   90 
   91 void aesni_encrypt_xts(int rounds, const void *data_schedule /*__aligned(16)*/,
   92     const void *tweak_schedule /*__aligned(16)*/, size_t len,
   93     const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
   94 void aesni_decrypt_xts(int rounds, const void *data_schedule /*__aligned(16)*/,
   95     const void *tweak_schedule /*__aligned(16)*/, size_t len,
   96     const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
   97 
   98 int aesni_cipher_setup_common(struct aesni_session *ses, const uint8_t *key,
   99     int keylen);
  100 uint8_t *aesni_cipher_alloc(struct cryptodesc *enccrd, struct cryptop *crp,
  101     int *allocated);
  102 
  103 #endif /* _AESNI_H_ */

Cache object: 6d498b2a0bee7e6c0f7f424ac10392a2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.