NVbit : Accessing Bitlocker volumes from linux.
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.

104 lines
2.7KB

  1. /**
  2. * \file aes.h
  3. */
  4. #ifndef XYSSL_AES_H
  5. #define XYSSL_AES_H
  6. #define AES_ENCRYPT 0
  7. #define AES_DECRYPT 1
  8. /**
  9. * \brief AES context structure
  10. */
  11. typedef struct
  12. {
  13. int nr; /*!< number of rounds */
  14. unsigned long *rk; /*!< AES round keys */
  15. unsigned long buf[68]; /*!< unaligned data */
  16. }
  17. aes_context;
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * \brief AES key schedule (encryption)
  23. *
  24. * \param ctx AES context to be initialized
  25. * \param key encryption key
  26. * \param keysize must be 128, 192 or 256
  27. */
  28. void aes_setkey_enc( aes_context *ctx, unsigned char *key, int keysize );
  29. /**
  30. * \brief AES key schedule (decryption)
  31. *
  32. * \param ctx AES context to be initialized
  33. * \param key decryption key
  34. * \param keysize must be 128, 192 or 256
  35. */
  36. void aes_setkey_dec( aes_context *ctx, unsigned char *key, int keysize );
  37. /**
  38. * \brief AES-ECB block encryption/decryption
  39. *
  40. * \param ctx AES context
  41. * \param mode AES_ENCRYPT or AES_DECRYPT
  42. * \param input 16-byte input block
  43. * \param output 16-byte output block
  44. */
  45. void aes_crypt_ecb( aes_context *ctx,
  46. int mode,
  47. unsigned char input[16],
  48. unsigned char output[16] );
  49. /**
  50. * \brief AES-CBC buffer encryption/decryption
  51. *
  52. * \param ctx AES context
  53. * \param mode AES_ENCRYPT or AES_DECRYPT
  54. * \param length length of the input data
  55. * \param iv initialization vector (updated after use)
  56. * \param input buffer holding the input data
  57. * \param output buffer holding the output data
  58. */
  59. void aes_crypt_cbc( aes_context *ctx,
  60. int mode,
  61. int length,
  62. unsigned char iv[16],
  63. unsigned char *input,
  64. unsigned char *output );
  65. /**
  66. * \brief AES-CFB buffer encryption/decryption
  67. *
  68. * \param ctx AES context
  69. * \param mode AES_ENCRYPT or AES_DECRYPT
  70. * \param length length of the input data
  71. * \param iv_off offset in IV (updated after use)
  72. * \param iv initialization vector (updated after use)
  73. * \param input buffer holding the input data
  74. * \param output buffer holding the output data
  75. */
  76. void aes_crypt_cfb( aes_context *ctx,
  77. int mode,
  78. int length,
  79. int *iv_off,
  80. unsigned char iv[16],
  81. unsigned char *input,
  82. unsigned char *output );
  83. /**
  84. * \brief Checkup routine
  85. *
  86. * \return 0 if successful, or 1 if the test failed
  87. */
  88. int aes_self_test( int verbose );
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* aes.h */