45 #define KEY(...) { __VA_ARGS__ } 48 #define IV(...) { __VA_ARGS__ } 51 #define ADDITIONAL(...) { __VA_ARGS__ } 54 #define PLAINTEXT(...) { __VA_ARGS__ } 57 #define CIPHERTEXT(...) { __VA_ARGS__ } 60 #define AUTH(...) { __VA_ARGS__ } 75 #define CIPHER_TEST( name, CIPHER, KEY, IV, ADDITIONAL, PLAINTEXT, \ 77 static const uint8_t name ## _key [] = KEY; \ 78 static const uint8_t name ## _iv [] = IV; \ 79 static const uint8_t name ## _additional [] = ADDITIONAL; \ 80 static const uint8_t name ## _plaintext [] = PLAINTEXT; \ 81 static const uint8_t name ## _ciphertext \ 82 [ sizeof ( name ## _plaintext ) ] = CIPHERTEXT; \ 83 static const uint8_t name ## _auth [] = AUTH; \ 84 static struct cipher_test name = { \ 86 .key = name ## _key, \ 87 .key_len = sizeof ( name ## _key ), \ 89 .iv_len = sizeof ( name ## _iv ), \ 90 .additional = name ## _additional, \ 91 .additional_len = sizeof ( name ## _additional ), \ 92 .plaintext = name ## _plaintext, \ 93 .ciphertext = name ## _ciphertext, \ 94 .len = sizeof ( name ## _plaintext ), \ 95 .auth = name ## _auth, \ 96 .auth_len = sizeof ( name ## _auth ), \ 115 #define cipher_encrypt_ok( test ) \ 116 cipher_encrypt_okx ( test, __FILE__, __LINE__ ) 123 #define cipher_decrypt_ok( test ) \ 124 cipher_decrypt_okx ( test, __FILE__, __LINE__ ) 131 #define cipher_ok( test ) \ 132 cipher_okx ( test, __FILE__, __LINE__ ) unsigned long cipher_cost_decrypt(struct cipher_algorithm *cipher, size_t key_len)
Calculate cipher decryption cost.
const void * additional
Additional data.
Self-test infrastructure.
void cipher_encrypt_okx(struct cipher_test *test, const char *file, unsigned int line)
Report a cipher encryption test result.
void cipher_decrypt_okx(struct cipher_test *test, const char *file, unsigned int line)
Report a cipher decryption test result.
size_t key_len
Length of key.
struct cipher_algorithm * cipher
Cipher algorithm.
size_t additional_len
Length of additional data.
const void * auth
Authentication tag.
const void * ciphertext
Ciphertext.
size_t auth_len
Length of authentication tag.
const void * iv
Initialisation vector.
void cipher_okx(struct cipher_test *test, const char *file, unsigned int line)
Report a cipher encryption and decryption test result.
size_t len
Length of text.
const void * plaintext
Plaintext.
size_t iv_len
Length of initialisation vector.
unsigned long cipher_cost_encrypt(struct cipher_algorithm *cipher, size_t key_len)
Calculate cipher encryption cost.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)