lib/crypto: optimize aes_gcm_128
[Samba.git] / lib / crypto / aes_gcm_128.h
blob8df11c2f6bd7c224f545010e5609e355b9ba684c
1 /*
2 AES-GCM-128
4 Copyright (C) Stefan Metzmacher 2014
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIB_CRYPTO_AES_GCM_128_H
21 #define LIB_CRYPTO_AES_GCM_128_H
23 #define AES_GCM_128_IV_SIZE (12)
25 struct aes_gcm_128_context {
26 AES_KEY aes_key;
28 uint64_t __align;
30 struct aes_gcm_128_tmp {
31 size_t ofs;
32 size_t total;
33 uint8_t block[AES_BLOCK_SIZE];
34 } A, C, c, v, y;
36 uint8_t H[AES_BLOCK_SIZE];
37 uint8_t J0[AES_BLOCK_SIZE];
38 uint8_t CB[AES_BLOCK_SIZE];
39 uint8_t Y[AES_BLOCK_SIZE];
40 uint8_t AC[AES_BLOCK_SIZE];
43 void aes_gcm_128_init(struct aes_gcm_128_context *ctx,
44 const uint8_t K[AES_BLOCK_SIZE],
45 const uint8_t IV[AES_GCM_128_IV_SIZE]);
46 void aes_gcm_128_updateA(struct aes_gcm_128_context *ctx,
47 const uint8_t *a, size_t a_len);
48 void aes_gcm_128_updateC(struct aes_gcm_128_context *ctx,
49 const uint8_t *c, size_t c_len);
50 void aes_gcm_128_crypt(struct aes_gcm_128_context *ctx,
51 uint8_t *m, size_t m_len);
52 void aes_gcm_128_digest(struct aes_gcm_128_context *ctx,
53 uint8_t T[AES_BLOCK_SIZE]);
55 #endif /* LIB_CRYPTO_AES_GCM_128_H */