Sebastian Siewior | 06e1a8f | 2007-11-30 00:15:11 +1100 | [diff] [blame] | 1 | /* |
| 2 | * Glue Code for the asm optimized version of the AES Cipher Algorithm |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | #include <crypto/aes.h> |
| 7 | |
Huang Ying | 07bf44f | 2009-01-09 17:25:50 +1100 | [diff] [blame] | 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 | |
| 11 | void crypto_aes_encrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src) |
| 12 | { |
| 13 | aes_enc_blk(ctx, dst, src); |
| 14 | } |
| 15 | EXPORT_SYMBOL_GPL(crypto_aes_encrypt_x86); |
| 16 | |
| 17 | void crypto_aes_decrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src) |
| 18 | { |
| 19 | aes_dec_blk(ctx, dst, src); |
| 20 | } |
| 21 | EXPORT_SYMBOL_GPL(crypto_aes_decrypt_x86); |
Sebastian Siewior | 06e1a8f | 2007-11-30 00:15:11 +1100 | [diff] [blame] | 22 | |
| 23 | static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
| 24 | { |
Huang Ying | 07bf44f | 2009-01-09 17:25:50 +1100 | [diff] [blame] | 25 | aes_enc_blk(crypto_tfm_ctx(tfm), dst, src); |
Sebastian Siewior | 06e1a8f | 2007-11-30 00:15:11 +1100 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
| 29 | { |
Huang Ying | 07bf44f | 2009-01-09 17:25:50 +1100 | [diff] [blame] | 30 | aes_dec_blk(crypto_tfm_ctx(tfm), dst, src); |
Sebastian Siewior | 06e1a8f | 2007-11-30 00:15:11 +1100 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static struct crypto_alg aes_alg = { |
| 34 | .cra_name = "aes", |
| 35 | .cra_driver_name = "aes-asm", |
| 36 | .cra_priority = 200, |
| 37 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
| 38 | .cra_blocksize = AES_BLOCK_SIZE, |
| 39 | .cra_ctxsize = sizeof(struct crypto_aes_ctx), |
| 40 | .cra_module = THIS_MODULE, |
| 41 | .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), |
| 42 | .cra_u = { |
| 43 | .cipher = { |
| 44 | .cia_min_keysize = AES_MIN_KEY_SIZE, |
| 45 | .cia_max_keysize = AES_MAX_KEY_SIZE, |
| 46 | .cia_setkey = crypto_aes_set_key, |
| 47 | .cia_encrypt = aes_encrypt, |
| 48 | .cia_decrypt = aes_decrypt |
| 49 | } |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | static int __init aes_init(void) |
| 54 | { |
| 55 | return crypto_register_alg(&aes_alg); |
| 56 | } |
| 57 | |
| 58 | static void __exit aes_fini(void) |
| 59 | { |
| 60 | crypto_unregister_alg(&aes_alg); |
| 61 | } |
| 62 | |
| 63 | module_init(aes_init); |
| 64 | module_exit(aes_fini); |
| 65 | |
| 66 | MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm, asm optimized"); |
| 67 | MODULE_LICENSE("GPL"); |
| 68 | MODULE_ALIAS("aes"); |
| 69 | MODULE_ALIAS("aes-asm"); |