mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 18:52:44 +01:00
sys/crypto/modes/ccm: accept input_len=0
CCM may be used on messages with no plaintext data.
This commit is contained in:
parent
3b5067b5d0
commit
8372286591
@ -43,6 +43,12 @@ static int ccm_compute_cbc_mac(cipher_t *cipher, const uint8_t iv[16],
|
|||||||
block_size = cipher_get_block_size(cipher);
|
block_size = cipher_get_block_size(cipher);
|
||||||
memmove(mac, iv, 16);
|
memmove(mac, iv, 16);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
/* no input message */
|
||||||
|
if(length == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
uint8_t block_size_input = (length - offset > block_size) ?
|
uint8_t block_size_input = (length - offset > block_size) ?
|
||||||
block_size : length - offset;
|
block_size : length - offset;
|
||||||
|
@ -57,10 +57,12 @@ extern "C" {
|
|||||||
* @param nonce_len Length of the nonce in octets
|
* @param nonce_len Length of the nonce in octets
|
||||||
* (maximum: 15-length_encoding)
|
* (maximum: 15-length_encoding)
|
||||||
* @param input pointer to input data to encrypt
|
* @param input pointer to input data to encrypt
|
||||||
* @param input_len length of the input data, max 2^32
|
* @param input_len length of the input data, [0, 2^32]
|
||||||
* @param output pointer to allocated memory for encrypted data. It
|
* @param output pointer to allocated memory for encrypted data. It
|
||||||
* has to be of size data_len + mac_length.
|
* has to be of size data_len + mac_length.
|
||||||
* @return Length of encrypted data on a successful encryption
|
*
|
||||||
|
* @return Length of encrypted data on a successful encryption,
|
||||||
|
* can be 0 if input_len=0 (no plaintext)
|
||||||
* @return A negative error code if something went wrong
|
* @return A negative error code if something went wrong
|
||||||
*/
|
*/
|
||||||
int cipher_encrypt_ccm(cipher_t *cipher,
|
int cipher_encrypt_ccm(cipher_t *cipher,
|
||||||
@ -85,11 +87,12 @@ int cipher_encrypt_ccm(cipher_t *cipher,
|
|||||||
* @param nonce_len Length of the nonce in octets
|
* @param nonce_len Length of the nonce in octets
|
||||||
* (maximum: 15-length_encoding)
|
* (maximum: 15-length_encoding)
|
||||||
* @param input pointer to input data to decrypt
|
* @param input pointer to input data to decrypt
|
||||||
* @param input_len length of the input data, max 2^32
|
* @param input_len length of the input data, [0, 2^32]
|
||||||
* @param output pointer to allocated memory for decrypted data. It
|
* @param output pointer to allocated memory for decrypted data. It
|
||||||
* has to be of size data_len - mac_length.
|
* has to be of size data_len - mac_length.
|
||||||
*
|
*
|
||||||
* @return Length of the decrypted data on a successful decryption
|
* @return Length of the decrypted data on a successful decryption,
|
||||||
|
* can be 0 if only auth_data and MAC is present.
|
||||||
* @return A negative error code if something went wrong
|
* @return A negative error code if something went wrong
|
||||||
*/
|
*/
|
||||||
int cipher_decrypt_ccm(cipher_t *cipher,
|
int cipher_decrypt_ccm(cipher_t *cipher,
|
||||||
|
Loading…
Reference in New Issue
Block a user