lrw.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _CRYPTO_LRW_H
  2. #define _CRYPTO_LRW_H
  3. #include <crypto/b128ops.h>
  4. struct scatterlist;
  5. struct gf128mul_64k;
  6. struct blkcipher_desc;
  7. #define LRW_BLOCK_SIZE 16
  8. struct lrw_table_ctx {
  9. /* optimizes multiplying a random (non incrementing, as at the
  10. * start of a new sector) value with key2, we could also have
  11. * used 4k optimization tables or no optimization at all. In the
  12. * latter case we would have to store key2 here */
  13. struct gf128mul_64k *table;
  14. /* stores:
  15. * key2*{ 0,0,...0,0,0,0,1 }, key2*{ 0,0,...0,0,0,1,1 },
  16. * key2*{ 0,0,...0,0,1,1,1 }, key2*{ 0,0,...0,1,1,1,1 }
  17. * key2*{ 0,0,...1,1,1,1,1 }, etc
  18. * needed for optimized multiplication of incrementing values
  19. * with key2 */
  20. be128 mulinc[128];
  21. };
  22. int lrw_init_table(struct lrw_table_ctx *ctx, const u8 *tweak);
  23. void lrw_free_table(struct lrw_table_ctx *ctx);
  24. struct lrw_crypt_req {
  25. be128 *tbuf;
  26. unsigned int tbuflen;
  27. struct lrw_table_ctx *table_ctx;
  28. void *crypt_ctx;
  29. void (*crypt_fn)(void *ctx, u8 *blks, unsigned int nbytes);
  30. };
  31. int lrw_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
  32. struct scatterlist *src, unsigned int nbytes,
  33. struct lrw_crypt_req *req);
  34. #endif /* _CRYPTO_LRW_H */