ctr.h¶
Counter mode of operation for block ciphers.
-
int
cipher_encrypt_ctr
(cipher_t * cipher, uint8_t nonce_counter, uint8_t nonce_len, const uint8_t * input,msp430_types.h::size_t
length, uint8_t * output)¶ Encrypt data of arbitrary length in counter mode.
Parameters
cipher: Already initialized cipher struct nonce_counter: A nounce and a counter encoded in 16 octets. The counter will be modified in each block encryption. nonce_len: Length of the nonce in octets. As nounce and counter have to fit in one aligned 16 octet block, maximum length of nonce is limited by input_len: 16 - log_2(input_len) input: pointer to input data to encrypt length: length of the input data output: pointer to allocated memory for encrypted data. It has to be of size data_len. Return values
- Length of encrypted data on a successful encryption
- A negative error code if something went wrong
-
int
cipher_decrypt_ctr
(cipher_t * cipher, uint8_t nonce_counter, uint8_t nonce_len, const uint8_t * input,msp430_types.h::size_t
length, uint8_t * output)¶ Decrypt data of arbitrary length in counter mode.
Encryption and decryption in ctr mode are basically the same.
Parameters
cipher: Already initialized cipher struct nonce_counter: A nounce and a counter encoded in 16 octets. The counter will be modified in each block encryption. nonce_len: Length of the nonce in octets. As nounce and counter have to fit in one aligned 16 octet block, maximum length of nonce is limited by input_len: 16 - log_2(input_len) input: pointer to input data to encrypt length: length of the input data output: pointer to allocated memory for encrypted data. It has to be of size data_len. Return values
- Length of decrypted data on a successful decryption
- A negative error code if something went wrong