mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 10:52:44 +01:00
crypto/modes/ccm: update api to const input buffers
Input buffers are not modified, so can be declared const arguments.
This commit is contained in:
parent
9e6782afb4
commit
c87fe94ec1
@ -144,10 +144,11 @@ static inline int _fits_in_nbytes(size_t value, uint8_t num_bytes)
|
||||
}
|
||||
|
||||
|
||||
int cipher_encrypt_ccm(cipher_t* cipher, uint8_t* auth_data, uint32_t auth_data_len,
|
||||
int cipher_encrypt_ccm(cipher_t* cipher,
|
||||
const uint8_t* auth_data, uint32_t auth_data_len,
|
||||
uint8_t mac_length, uint8_t length_encoding,
|
||||
uint8_t* nonce, size_t nonce_len,
|
||||
uint8_t* input, size_t input_len,
|
||||
const uint8_t* nonce, size_t nonce_len,
|
||||
const uint8_t* input, size_t input_len,
|
||||
uint8_t* output)
|
||||
{
|
||||
int len = -1;
|
||||
@ -207,10 +208,12 @@ int cipher_encrypt_ccm(cipher_t* cipher, uint8_t* auth_data, uint32_t auth_data_
|
||||
}
|
||||
|
||||
|
||||
int cipher_decrypt_ccm(cipher_t* cipher, uint8_t* auth_data,
|
||||
uint32_t auth_data_len, uint8_t mac_length,
|
||||
uint8_t length_encoding, uint8_t* nonce, size_t nonce_len,
|
||||
uint8_t* input, size_t input_len, uint8_t* plain)
|
||||
int cipher_decrypt_ccm(cipher_t* cipher,
|
||||
const uint8_t* auth_data, uint32_t auth_data_len,
|
||||
uint8_t mac_length, uint8_t length_encoding,
|
||||
const uint8_t* nonce, size_t nonce_len,
|
||||
const uint8_t* input, size_t input_len,
|
||||
uint8_t* plain)
|
||||
{
|
||||
int len = -1;
|
||||
uint8_t nonce_counter[16] = {0}, mac_iv[16] = {0}, mac[16] = {0},
|
||||
|
@ -57,10 +57,12 @@ extern "C" {
|
||||
* @return Length of encrypted data on a successful encryption
|
||||
* @return A negative error code if something went wrong
|
||||
*/
|
||||
int cipher_encrypt_ccm(cipher_t* cipher, uint8_t* auth_data,
|
||||
uint32_t auth_data_len, uint8_t mac_length,
|
||||
uint8_t length_encoding, uint8_t* nonce, size_t nonce_len,
|
||||
uint8_t* input, size_t input_len, uint8_t* output);
|
||||
int cipher_encrypt_ccm(cipher_t* cipher,
|
||||
const uint8_t* auth_data, uint32_t auth_data_len,
|
||||
uint8_t mac_length, uint8_t length_encoding,
|
||||
const uint8_t* nonce, size_t nonce_len,
|
||||
const uint8_t* input, size_t input_len,
|
||||
uint8_t* output);
|
||||
|
||||
|
||||
/**
|
||||
@ -84,10 +86,12 @@ int cipher_encrypt_ccm(cipher_t* cipher, uint8_t* auth_data,
|
||||
* @return Length of the decrypted data on a successful decryption
|
||||
* @return A negative error code if something went wrong
|
||||
*/
|
||||
int cipher_decrypt_ccm(cipher_t* cipher, uint8_t* auth_data,
|
||||
uint32_t auth_data_len, uint8_t mac_length,
|
||||
uint8_t length_encoding, uint8_t* nonce, size_t nonce_len,
|
||||
uint8_t* input, size_t input_len, uint8_t* output);
|
||||
int cipher_decrypt_ccm(cipher_t* cipher,
|
||||
const uint8_t* auth_data, uint32_t auth_data_len,
|
||||
uint8_t mac_length, uint8_t length_encoding,
|
||||
const uint8_t* nonce, size_t nonce_len,
|
||||
const uint8_t* input, size_t input_len,
|
||||
uint8_t* output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -190,8 +190,9 @@ static void test_crypto_modes_ccm_decrypt(void)
|
||||
}
|
||||
|
||||
|
||||
typedef int (*func_ccm_t)(cipher_t*, uint8_t*, uint32_t, uint8_t, uint8_t,
|
||||
uint8_t*, size_t, uint8_t*, size_t, uint8_t*);
|
||||
typedef int (*func_ccm_t)(cipher_t*, const uint8_t*, uint32_t,
|
||||
uint8_t, uint8_t, const uint8_t*, size_t,
|
||||
const uint8_t*, size_t, uint8_t*);
|
||||
|
||||
static int _test_ccm_len(func_ccm_t func, uint8_t len_encoding,
|
||||
uint8_t *input, size_t input_len, size_t adata_len)
|
||||
|
Loading…
Reference in New Issue
Block a user