Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _IPXE_ECB_H
  2. #define _IPXE_ECB_H
  3. /** @file
  4. *
  5. * Electronic codebook (ECB)
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <ipxe/crypto.h>
  10. extern void ecb_encrypt ( void *ctx, const void *src, void *dst,
  11. size_t len, struct cipher_algorithm *raw_cipher );
  12. extern void ecb_decrypt ( void *ctx, const void *src, void *dst,
  13. size_t len, struct cipher_algorithm *raw_cipher );
  14. /**
  15. * Create a cipher-block chaining mode of behaviour of an existing cipher
  16. *
  17. * @v _ecb_name Name for the new ECB cipher
  18. * @v _ecb_cipher New cipher algorithm
  19. * @v _raw_cipher Underlying cipher algorithm
  20. * @v _raw_context Context structure for the underlying cipher
  21. * @v _blocksize Cipher block size
  22. */
  23. #define ECB_CIPHER( _ecb_name, _ecb_cipher, _raw_cipher, _raw_context, \
  24. _blocksize ) \
  25. static int _ecb_name ## _setkey ( void *ctx, const void *key, \
  26. size_t keylen ) { \
  27. return cipher_setkey ( &_raw_cipher, ctx, key, keylen ); \
  28. } \
  29. static void _ecb_name ## _setiv ( void *ctx, const void *iv ) { \
  30. cipher_setiv ( &_raw_cipher, ctx, iv ); \
  31. } \
  32. static void _ecb_name ## _encrypt ( void *ctx, const void *src, \
  33. void *dst, size_t len ) { \
  34. ecb_encrypt ( ctx, src, dst, len, &_raw_cipher ); \
  35. } \
  36. static void _ecb_name ## _decrypt ( void *ctx, const void *src, \
  37. void *dst, size_t len ) { \
  38. ecb_decrypt ( ctx, src, dst, len, &_raw_cipher ); \
  39. } \
  40. struct cipher_algorithm _ecb_cipher = { \
  41. .name = #_ecb_name, \
  42. .ctxsize = sizeof ( _raw_context ), \
  43. .blocksize = _blocksize, \
  44. .setkey = _ecb_name ## _setkey, \
  45. .setiv = _ecb_name ## _setiv, \
  46. .encrypt = _ecb_name ## _encrypt, \
  47. .decrypt = _ecb_name ## _decrypt, \
  48. };
  49. #endif /* _IPXE_ECB_H */