You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cbc_test.h 1.5KB

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