s3/service: use lp_const_servicename() where possible
[Samba.git] / lib / crypto / aes_ccm_128.h
blob1382ee704b98aaba5e798ccf79a594625892447f
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;
30 uint8_t nonce[AES_CCM_128_NONCE_SIZE];
32 size_t a_remain;
33 size_t m_remain;
35 uint64_t __align;
37 uint8_t X_i[AES_BLOCK_SIZE];
38 uint8_t B_i[AES_BLOCK_SIZE];
39 uint8_t A_i[AES_BLOCK_SIZE];
40 uint8_t S_i[AES_BLOCK_SIZE];
42 size_t B_i_ofs;
43 size_t S_i_ofs;
44 size_t S_i_ctr;
47 void aes_ccm_128_init(struct aes_ccm_128_context *ctx,
48 const uint8_t K[AES_BLOCK_SIZE],
49 const uint8_t N[AES_CCM_128_NONCE_SIZE],
50 size_t a_total, size_t m_total);
51 void aes_ccm_128_update(struct aes_ccm_128_context *ctx,
52 const uint8_t *v, size_t v_len);
53 void aes_ccm_128_crypt(struct aes_ccm_128_context *ctx,
54 uint8_t *m, size_t m_len);
55 void aes_ccm_128_digest(struct aes_ccm_128_context *ctx,
56 uint8_t digest[AES_BLOCK_SIZE]);
58 #endif /* LIB_CRYPTO_AES_CCM_128_H */