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