blob: e26984f7ab8d2fa838168be1893c5eacdc375d33 [file] [log] [blame]
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +11001/*
2 * Glue Code for the asm optimized version of the AES Cipher Algorithm
3 *
4 */
5
Paul Gortmaker7c52d552011-05-27 12:33:10 -04006#include <linux/module.h>
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +11007#include <crypto/aes.h>
Jussi Kivilinna70ef2602012-06-18 14:07:50 +03008#include <asm/crypto/aes.h>
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +11009
Huang Ying07bf44f2009-01-09 17:25:50 +110010asmlinkage void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
11asmlinkage void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
12
13void crypto_aes_encrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
14{
15 aes_enc_blk(ctx, dst, src);
16}
17EXPORT_SYMBOL_GPL(crypto_aes_encrypt_x86);
18
19void crypto_aes_decrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
20{
21 aes_dec_blk(ctx, dst, src);
22}
23EXPORT_SYMBOL_GPL(crypto_aes_decrypt_x86);
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110024
25static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
26{
Huang Ying07bf44f2009-01-09 17:25:50 +110027 aes_enc_blk(crypto_tfm_ctx(tfm), dst, src);
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110028}
29
30static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
31{
Huang Ying07bf44f2009-01-09 17:25:50 +110032 aes_dec_blk(crypto_tfm_ctx(tfm), dst, src);
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110033}
34
35static struct crypto_alg aes_alg = {
36 .cra_name = "aes",
37 .cra_driver_name = "aes-asm",
38 .cra_priority = 200,
39 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
40 .cra_blocksize = AES_BLOCK_SIZE,
41 .cra_ctxsize = sizeof(struct crypto_aes_ctx),
42 .cra_module = THIS_MODULE,
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110043 .cra_u = {
44 .cipher = {
45 .cia_min_keysize = AES_MIN_KEY_SIZE,
46 .cia_max_keysize = AES_MAX_KEY_SIZE,
47 .cia_setkey = crypto_aes_set_key,
48 .cia_encrypt = aes_encrypt,
49 .cia_decrypt = aes_decrypt
50 }
51 }
52};
53
54static int __init aes_init(void)
55{
56 return crypto_register_alg(&aes_alg);
57}
58
59static void __exit aes_fini(void)
60{
61 crypto_unregister_alg(&aes_alg);
62}
63
64module_init(aes_init);
65module_exit(aes_fini);
66
67MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm, asm optimized");
68MODULE_LICENSE("GPL");
Kees Cook5d26a102014-11-20 17:05:53 -080069MODULE_ALIAS_CRYPTO("aes");
70MODULE_ALIAS_CRYPTO("aes-asm");