crypto: Update the REQUIREMENTS
[samba.git] / lib / crypto / aesni.h
1 /*
2  * Copyright (C) 2008, Intel Corp.
3  *    Author: Huang Ying <ying.huang@intel.com>
4  *            Vinodh Gopal <vinodh.gopal@intel.com>
5  *            Kahraman Akdemir
6  *
7  * Ported x86_64 version to x86:
8  *    Author: Mathias Krause <minipli@googlemail.com>
9  *
10  * Modified for use in Samba by Justin Maggard <jmaggard@netgear.com>
11  * and Jeremy Allison <jra@samba.org>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  */
18
19 #ifndef LIB_CRYPTO_AESNI_H
20 #define LIB_CRYPTO_AESNI_H 1
21
22 #if defined(HAVE_AESNI_INTEL)
23
24 #define AES_MAX_KEYLENGTH      (15 * 16)
25 #define AES_MAX_KEYLENGTH_U32  (AES_MAX_KEYLENGTH / sizeof(uint32_t))
26
27 /*
28  * Please ensure that the first two fields are 16-byte aligned
29  * relative to the start of the structure, i.e., don't move them!
30  */
31 struct crypto_aes_ctx {
32         uint32_t key_enc[AES_MAX_KEYLENGTH_U32];
33         uint32_t key_dec[AES_MAX_KEYLENGTH_U32];
34         uint32_t key_length;
35 };
36
37 struct crypto_aesni_ctx {
38         uint8_t _acc_ctx[sizeof(struct crypto_aes_ctx) + 16];
39         struct crypto_aes_ctx *acc_ctx;
40 };
41
42 /*
43  * These next 4 functions are actually implemented
44  * in the assembly language file:
45  * third_party/aesni-intel/aesni-intel_asm.c
46  */
47
48 int aesni_set_key(struct crypto_aes_ctx *ctx,
49                 const uint8_t *in_key,
50                 unsigned int key_len);
51 void aesni_enc(struct crypto_aes_ctx *ctx, uint8_t *dst, const uint8_t *src);
52 void aesni_dec(struct crypto_aes_ctx *ctx, uint8_t *dst, const uint8_t *src);
53
54 #else /* #if defined(HAVE_AESNI_INTEL) */
55
56 /*
57  * We need a dummy definition of struct crypto_aesni_ctx to allow compiles.
58  */
59
60 struct crypto_aesni_ctx {
61         int dummy;
62 };
63
64 #endif /* #if defined(HAVE_AESNI_INTEL) */
65
66 #endif /* LIB_CRYPTO_AESNI_H */