s3:lib/events: s/EVENT_FD/TEVENT_FD
[Samba/gebeck_regimport.git] / lib / crypto / aes_ccm_128.h
bloba98c75443353b554b2439546b6da567b2edbce90
1 /*
2 AES-CCM-128 (rfc 3610)
4 Copyright (C) Stefan Metzmacher 2012
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_CCM_128_H
21 #define LIB_CRYPTO_AES_CCM_128_H
23 #define AES_CCM_128_M 16
24 #define AES_CCM_128_L 4
25 #define AES_CCM_128_NONCE_SIZE (15 - AES_CCM_128_L)
27 struct aes_ccm_128_context {
28 AES_KEY aes_key;
29 uint8_t nonce[AES_CCM_128_NONCE_SIZE];
31 size_t a_remain;
32 size_t m_remain;
34 uint8_t X_i[AES_BLOCK_SIZE];
35 uint8_t B_i[AES_BLOCK_SIZE];
36 size_t B_i_ofs;
38 uint8_t S_i[AES_BLOCK_SIZE];
39 size_t S_i_ofs;
40 size_t S_i_ctr;
43 void aes_ccm_128_init(struct aes_ccm_128_context *ctx,
44 const uint8_t K[AES_BLOCK_SIZE],
45 const uint8_t N[AES_CCM_128_NONCE_SIZE],
46 size_t a_total, size_t m_total);
47 void aes_ccm_128_update(struct aes_ccm_128_context *ctx,
48 const uint8_t *v, size_t v_len);
49 void aes_ccm_128_crypt(struct aes_ccm_128_context *ctx,
50 uint8_t *m, size_t m_len);
51 void aes_ccm_128_digest(struct aes_ccm_128_context *ctx,
52 uint8_t digest[AES_BLOCK_SIZE]);
54 #endif /* LIB_CRYPTO_AES_CCM_128_H */