|
iPXE
|
Cipher self-tests. More...
#include <stdint.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <ipxe/crypto.h>#include <ipxe/profile.h>#include <ipxe/test.h>#include "cipher_test.h"Go to the source code of this file.
Macros | |
| #define | PROFILE_COUNT 16 |
| Number of sample iterations for profiling. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| void | cipher_encrypt_okx (struct cipher_test *test, const char *file, unsigned int line) |
| Report a cipher encryption test result. More... | |
| void | cipher_decrypt_okx (struct cipher_test *test, const char *file, unsigned int line) |
| Report a cipher decryption test result. More... | |
| void | cipher_okx (struct cipher_test *test, const char *file, unsigned int line) |
| Report a cipher encryption and decryption test result. More... | |
| static unsigned long | cipher_cost (struct cipher_algorithm *cipher, size_t key_len, void(*op)(struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len)) |
| Calculate cipher encryption or decryption cost. More... | |
| unsigned long | cipher_cost_encrypt (struct cipher_algorithm *cipher, size_t key_len) |
| Calculate cipher encryption cost. More... | |
| unsigned long | cipher_cost_decrypt (struct cipher_algorithm *cipher, size_t key_len) |
| Calculate cipher decryption cost. More... | |
Cipher self-tests.
Definition in file cipher_test.c.
| #define PROFILE_COUNT 16 |
Number of sample iterations for profiling.
Definition at line 45 of file cipher_test.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| void cipher_encrypt_okx | ( | struct cipher_test * | test, |
| const char * | file, | ||
| unsigned int | line | ||
| ) |
Report a cipher encryption test result.
| test | Cipher test |
| file | Test code file |
| line | Test code line |
Definition at line 54 of file cipher_test.c.
References cipher_algorithm::auth, cipher_algorithm::authsize, cipher_auth(), cipher_encrypt, cipher_setiv(), cipher_setkey(), ctx, cipher_algorithm::ctxsize, is_auth_cipher(), len, memcmp(), memcpy(), NULL, okx, and test.
Referenced by cipher_okx().
| void cipher_decrypt_okx | ( | struct cipher_test * | test, |
| const char * | file, | ||
| unsigned int | line | ||
| ) |
Report a cipher decryption test result.
| test | Cipher test |
| file | Test code file |
| line | Test code line |
Definition at line 113 of file cipher_test.c.
References cipher_algorithm::auth, cipher_algorithm::authsize, cipher_auth(), cipher_decrypt, cipher_setiv(), cipher_setkey(), ctx, cipher_algorithm::ctxsize, is_auth_cipher(), len, memcmp(), memcpy(), NULL, okx, and test.
Referenced by cipher_okx().
| void cipher_okx | ( | struct cipher_test * | test, |
| const char * | file, | ||
| unsigned int | line | ||
| ) |
Report a cipher encryption and decryption test result.
| test | Cipher test |
| file | Test code file |
| line | Test code line |
Definition at line 172 of file cipher_test.c.
References cipher_algorithm::alignsize, cipher_algorithm::blocksize, cipher_decrypt_okx(), cipher_encrypt_okx(), len, okx, and test.
|
static |
Calculate cipher encryption or decryption cost.
| cipher | Cipher algorithm |
| key_len | Length of key |
| op | Encryption or decryption operation |
| cost | Cost (in cycles per byte) |
Definition at line 198 of file cipher_test.c.
References assert(), cipher_algorithm::blocksize, cipher_setiv(), cipher_setkey(), cost, ctx, cipher_algorithm::ctxsize, iv, key, memset(), op, PROFILE_COUNT, profile_mean(), profile_start(), profile_stop(), rand(), random(), rc, and srand().
Referenced by cipher_cost_decrypt(), and cipher_cost_encrypt().
| unsigned long cipher_cost_encrypt | ( | struct cipher_algorithm * | cipher, |
| size_t | key_len | ||
| ) |
Calculate cipher encryption cost.
| cipher | Cipher algorithm |
| key_len | Length of key |
| cost | Cost (in cycles per byte) |
Definition at line 246 of file cipher_test.c.
References cipher_cost(), and cipher_encrypt.
Referenced by aes_test_exec(), des_test_exec(), and gcm_test_exec().
| unsigned long cipher_cost_decrypt | ( | struct cipher_algorithm * | cipher, |
| size_t | key_len | ||
| ) |
Calculate cipher decryption cost.
| cipher | Cipher algorithm |
| key_len | Length of key |
| cost | Cost (in cycles per byte) |
Definition at line 258 of file cipher_test.c.
References cipher_cost(), and cipher_decrypt.
Referenced by aes_test_exec(), des_test_exec(), and gcm_test_exec().
1.8.15