Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / tests / cbc_test.h
1 #ifndef _CBC_TEST_H
2 #define _CBC_TEST_H
3
4 FILE_LICENCE ( GPL2_OR_LATER );
5
6 #include <stdint.h>
7 #include <ipxe/crypto.h>
8 #include <ipxe/test.h>
9
10 extern int cbc_test_encrypt ( struct cipher_algorithm *cipher, const void *key,
11                               size_t key_len, const void *iv,
12                               const void *plaintext,
13                               const void *expected_ciphertext, size_t len );
14 extern int cbc_test_decrypt ( struct cipher_algorithm *cipher, const void *key,
15                               size_t key_len, const void *iv,
16                               const void *ciphertext,
17                               const void *expected_plaintext, size_t len );
18 extern unsigned long cbc_cost_encrypt ( struct cipher_algorithm *cipher,
19                                         size_t key_len );
20 extern unsigned long cbc_cost_decrypt ( struct cipher_algorithm *cipher,
21                                         size_t key_len );
22
23 /**
24  * Report CBC encryption test result
25  *
26  * @v cipher                    Cipher algorithm
27  * @v key                       Key
28  * @v key_len                   Length of key
29  * @v iv                        Initialisation vector
30  * @v plaintext                 Plaintext data
31  * @v expected_ciphertext       Expected ciphertext data
32  * @v len                       Length of data
33  */
34 #define cbc_encrypt_ok( cipher, key, key_len, iv, plaintext,            \
35                         expected_ciphertext, len ) do {                 \
36         ok ( cbc_test_encrypt ( cipher, key, key_len, iv, plaintext,    \
37                                 expected_ciphertext, len ) );           \
38         } while ( 0 )
39
40 /**
41  * Report CBC decryption test result
42  *
43  * @v cipher                    Cipher algorithm
44  * @v key                       Key
45  * @v key_len                   Length of key
46  * @v iv                        Initialisation vector
47  * @v ciphertext                Ciphertext data
48  * @v expected_plaintext        Expected plaintext data
49  * @v len                       Length of data
50  */
51 #define cbc_decrypt_ok( cipher, key, key_len, iv, ciphertext,           \
52                         expected_plaintext, len ) do {                  \
53         ok ( cbc_test_decrypt ( cipher, key, key_len, iv, ciphertext,   \
54                                 expected_plaintext, len ) );            \
55         } while ( 0 )
56
57 #endif /* _CBC_TEST_H */