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
{
29 uint8_t nonce
[AES_CCM_128_NONCE_SIZE
];
34 uint8_t X_i
[AES_BLOCK_SIZE
];
35 uint8_t B_i
[AES_BLOCK_SIZE
];
38 uint8_t S_i
[AES_BLOCK_SIZE
];
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 */