aes_glue.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Glue Code for the asm optimized version of the AES Cipher Algorithm
  3. *
  4. */
  5. #include <linux/module.h>
  6. #include <crypto/aes.h>
  7. #include <asm/crypto/aes.h>
  8. asmlinkage void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
  9. asmlinkage void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
  10. void crypto_aes_encrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
  11. {
  12. aes_enc_blk(ctx, dst, src);
  13. }
  14. EXPORT_SYMBOL_GPL(crypto_aes_encrypt_x86);
  15. void crypto_aes_decrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
  16. {
  17. aes_dec_blk(ctx, dst, src);
  18. }
  19. EXPORT_SYMBOL_GPL(crypto_aes_decrypt_x86);
  20. static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
  21. {
  22. aes_enc_blk(crypto_tfm_ctx(tfm), dst, src);
  23. }
  24. static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
  25. {
  26. aes_dec_blk(crypto_tfm_ctx(tfm), dst, src);
  27. }
  28. static struct crypto_alg aes_alg = {
  29. .cra_name = "aes",
  30. .cra_driver_name = "aes-asm",
  31. .cra_priority = 200,
  32. .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
  33. .cra_blocksize = AES_BLOCK_SIZE,
  34. .cra_ctxsize = sizeof(struct crypto_aes_ctx),
  35. .cra_module = THIS_MODULE,
  36. .cra_u = {
  37. .cipher = {
  38. .cia_min_keysize = AES_MIN_KEY_SIZE,
  39. .cia_max_keysize = AES_MAX_KEY_SIZE,
  40. .cia_setkey = crypto_aes_set_key,
  41. .cia_encrypt = aes_encrypt,
  42. .cia_decrypt = aes_decrypt
  43. }
  44. }
  45. };
  46. static int __init aes_init(void)
  47. {
  48. return crypto_register_alg(&aes_alg);
  49. }
  50. static void __exit aes_fini(void)
  51. {
  52. crypto_unregister_alg(&aes_alg);
  53. }
  54. module_init(aes_init);
  55. module_exit(aes_fini);
  56. MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm, asm optimized");
  57. MODULE_LICENSE("GPL");
  58. MODULE_ALIAS_CRYPTO("aes");
  59. MODULE_ALIAS_CRYPTO("aes-asm");