blob: b0b6950cc8c8850d68366b869ca39e4250827013 [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
6#include <crypto/aes.h>
H Hartley Sweeten4a4cc2b2011-09-22 21:33:01 +10007#include <asm/aes.h>
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +11008
Huang Ying07bf44f2009-01-09 17:25:50 +11009asmlinkage void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
10asmlinkage void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out, const u8 *in);
11
12void crypto_aes_encrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
13{
14 aes_enc_blk(ctx, dst, src);
15}
16EXPORT_SYMBOL_GPL(crypto_aes_encrypt_x86);
17
18void crypto_aes_decrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
19{
20 aes_dec_blk(ctx, dst, src);
21}
22EXPORT_SYMBOL_GPL(crypto_aes_decrypt_x86);
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110023
24static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
25{
Huang Ying07bf44f2009-01-09 17:25:50 +110026 aes_enc_blk(crypto_tfm_ctx(tfm), dst, src);
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110027}
28
29static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
30{
Huang Ying07bf44f2009-01-09 17:25:50 +110031 aes_dec_blk(crypto_tfm_ctx(tfm), dst, src);
Sebastian Siewior06e1a8f2007-11-30 00:15:11 +110032}
33
34static struct crypto_alg aes_alg = {
35 .cra_name = "aes",
36 .cra_driver_name = "aes-asm",
37 .cra_priority = 200,
38 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
39 .cra_blocksize = AES_BLOCK_SIZE,
40 .cra_ctxsize = sizeof(struct crypto_aes_ctx),
41 .cra_module = THIS_MODULE,
42 .cra_list = LIST_HEAD_INIT(aes_alg.cra_list),
43 .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");
69MODULE_ALIAS("aes");
70MODULE_ALIAS("aes-asm");