0001
0002
0003
0004
0005
0006
0007
0008 #include <crypto/aes.h>
0009 #include <linux/crypto.h>
0010 #include <linux/module.h>
0011
0012 asmlinkage void __aes_arm64_encrypt(u32 *rk, u8 *out, const u8 *in, int rounds);
0013 asmlinkage void __aes_arm64_decrypt(u32 *rk, u8 *out, const u8 *in, int rounds);
0014
0015 static void aes_arm64_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
0016 {
0017 struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
0018 int rounds = 6 + ctx->key_length / 4;
0019
0020 __aes_arm64_encrypt(ctx->key_enc, out, in, rounds);
0021 }
0022
0023 static void aes_arm64_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
0024 {
0025 struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
0026 int rounds = 6 + ctx->key_length / 4;
0027
0028 __aes_arm64_decrypt(ctx->key_dec, out, in, rounds);
0029 }
0030
0031 static struct crypto_alg aes_alg = {
0032 .cra_name = "aes",
0033 .cra_driver_name = "aes-arm64",
0034 .cra_priority = 200,
0035 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
0036 .cra_blocksize = AES_BLOCK_SIZE,
0037 .cra_ctxsize = sizeof(struct crypto_aes_ctx),
0038 .cra_module = THIS_MODULE,
0039
0040 .cra_cipher.cia_min_keysize = AES_MIN_KEY_SIZE,
0041 .cra_cipher.cia_max_keysize = AES_MAX_KEY_SIZE,
0042 .cra_cipher.cia_setkey = crypto_aes_set_key,
0043 .cra_cipher.cia_encrypt = aes_arm64_encrypt,
0044 .cra_cipher.cia_decrypt = aes_arm64_decrypt
0045 };
0046
0047 static int __init aes_init(void)
0048 {
0049 return crypto_register_alg(&aes_alg);
0050 }
0051
0052 static void __exit aes_fini(void)
0053 {
0054 crypto_unregister_alg(&aes_alg);
0055 }
0056
0057 module_init(aes_init);
0058 module_exit(aes_fini);
0059
0060 MODULE_DESCRIPTION("Scalar AES cipher for arm64");
0061 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
0062 MODULE_LICENSE("GPL v2");
0063 MODULE_ALIAS_CRYPTO("aes");