ccm.h¶
Counter with CBC-MAC mode of operation for block ciphers.
-
CCM_ERR_INVALID_NONCE_LENGTH
¶ 1
(-2)
-
CCM_ERR_INVALID_CBC_MAC
¶ 1
(-3)
-
CCM_ERR_INVALID_DATA_LENGTH
¶ 1
(-3)
-
CCM_ERR_INVALID_LENGTH_ENCODING
¶ 1
(-4)
-
CCM_ERR_INVALID_MAC_LENGTH
¶ 1
(-5)
-
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,msp430_types.h::size_t
nonce_len, const uint8_t * input,msp430_types.h::size_t
input_len, uint8_t * output)¶ Encrypt and authenticate data of arbitrary length in ccm mode.
Parameters
cipher: Already initialized cipher struct auth_data: Additional data to authenticate in MAC auth_data_len: Length of additional data mac_length: length of the appended MAC (between 4 and 16 - only even values) length_encoding: maximal supported length of plaintext (2^(8*length_enc)). nonce: Nounce for ctr mode encryption nonce_len: Length of the nonce in octets (maximum: 15-length_encoding) input: pointer to input data to encrypt input_len: length of the input data output: pointer to allocated memory for encrypted data. It has to be of size data_len + mac_length. Return values
- Length of encrypted data on a successful encryption
- A negative error code if something went wrong
-
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,msp430_types.h::size_t
nonce_len, const uint8_t * input,msp430_types.h::size_t
input_len, uint8_t * output)¶ Decrypt data of arbitrary length in ccm mode.
Parameters
cipher: Already initialized cipher struct auth_data: Additional data to authenticate in MAC auth_data_len: Length of additional data mac_length: length of the appended MAC (between 4 and 16 - only even values) length_encoding: maximal supported length of plaintext (2^(8*length_enc)). nonce: Nounce for ctr mode encryption nonce_len: Length of the nonce in octets (maximum: 15-length_encoding) input: pointer to input data to decrypt input_len: length of the input data output: pointer to allocated memory for decrypted data. It has to be of size data_len - mac_length. Return values
- Length of the decrypted data on a successful decryption
- A negative error code if something went wrong