crypto_aes.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef CRYPTO_AES_H_
  2. #define CRYPTO_AES_H_
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. /* Opaque structure. */
  6. struct crypto_aes_key;
  7. /**
  8. * crypto_aes_can_use_intrinsics(void):
  9. * Test whether hardware intrinsics are safe to use. Return 1 if x86 AESNI
  10. * operations are available, 2 if ARM-AES operations are available, or 0 if
  11. * none are available.
  12. */
  13. int crypto_aes_can_use_intrinsics(void);
  14. /**
  15. * crypto_aes_key_expand(key_unexpanded, len):
  16. * Expand the ${len}-byte unexpanded AES key ${key_unexpanded} into a
  17. * structure which can be passed to crypto_aes_encrypt_block(). The length
  18. * must be 16 or 32.
  19. */
  20. struct crypto_aes_key * crypto_aes_key_expand(const uint8_t *, size_t);
  21. /**
  22. * crypto_aes_encrypt_block(in, out, key):
  23. * Using the expanded AES key ${key}, encrypt the block ${in} and write the
  24. * resulting ciphertext to ${out}. ${in} and ${out} can overlap.
  25. */
  26. void crypto_aes_encrypt_block(const uint8_t[16], uint8_t[16],
  27. const struct crypto_aes_key *);
  28. /**
  29. * crypto_aes_key_free(key):
  30. * Free the expanded AES key ${key}.
  31. */
  32. void crypto_aes_key_free(struct crypto_aes_key *);
  33. #endif /* !CRYPTO_AES_H_ */