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.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef _GPXE_CBC_H
  2. #define _GPXE_CBC_H
  3. /** @file
  4. *
  5. * Cipher-block chaining
  6. *
  7. */
  8. #include <gpxe/crypto.h>
  9. /**
  10. * Set key
  11. *
  12. * @v ctx Context
  13. * @v key Key
  14. * @v keylen Key length
  15. * @v cipher Underlying cipher algorithm
  16. * @v cbc_ctx CBC context
  17. * @ret rc Return status code
  18. */
  19. static inline int cbc_setkey ( void *ctx, const void *key, size_t keylen,
  20. struct cipher_algorithm *cipher,
  21. void *cbc_ctx __unused ) {
  22. return cipher_setkey ( cipher, ctx, key, keylen );
  23. }
  24. /**
  25. * Set initialisation vector
  26. *
  27. * @v ctx Context
  28. * @v iv Initialisation vector
  29. * @v cipher Underlying cipher algorithm
  30. * @v cbc_ctx CBC context
  31. */
  32. static inline void cbc_setiv ( void *ctx __unused, const void *iv,
  33. struct cipher_algorithm *cipher,
  34. void *cbc_ctx ) {
  35. memcpy ( cbc_ctx, iv, cipher->blocksize );
  36. }
  37. extern void cbc_encrypt ( void *ctx, const void *src, void *dst,
  38. size_t len, struct cipher_algorithm *cipher,
  39. void *cbc_ctx );
  40. extern void cbc_decrypt ( void *ctx, const void *src, void *dst,
  41. size_t len, struct cipher_algorithm *cipher,
  42. void *cbc_ctx );
  43. #endif /* _GPXE_CBC_H */