2 * Scalar AES core transform
4 * Copyright (C) 2017 Linaro Ltd <ard.biesheuvel@linaro.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <crypto/aes.h>
12 #include <linux/crypto.h>
13 #include <linux/module.h>
15 asmlinkage
void __aes_arm64_encrypt(u32
*rk
, u8
*out
, const u8
*in
, int rounds
);
16 EXPORT_SYMBOL(__aes_arm64_encrypt
);
18 asmlinkage
void __aes_arm64_decrypt(u32
*rk
, u8
*out
, const u8
*in
, int rounds
);
19 EXPORT_SYMBOL(__aes_arm64_decrypt
);
21 static void aes_encrypt(struct crypto_tfm
*tfm
, u8
*out
, const u8
*in
)
23 struct crypto_aes_ctx
*ctx
= crypto_tfm_ctx(tfm
);
24 int rounds
= 6 + ctx
->key_length
/ 4;
26 __aes_arm64_encrypt(ctx
->key_enc
, out
, in
, rounds
);
29 static void aes_decrypt(struct crypto_tfm
*tfm
, u8
*out
, const u8
*in
)
31 struct crypto_aes_ctx
*ctx
= crypto_tfm_ctx(tfm
);
32 int rounds
= 6 + ctx
->key_length
/ 4;
34 __aes_arm64_decrypt(ctx
->key_dec
, out
, in
, rounds
);
37 static struct crypto_alg aes_alg
= {
39 .cra_driver_name
= "aes-arm64",
41 .cra_flags
= CRYPTO_ALG_TYPE_CIPHER
,
42 .cra_blocksize
= AES_BLOCK_SIZE
,
43 .cra_ctxsize
= sizeof(struct crypto_aes_ctx
),
44 .cra_module
= THIS_MODULE
,
46 .cra_cipher
.cia_min_keysize
= AES_MIN_KEY_SIZE
,
47 .cra_cipher
.cia_max_keysize
= AES_MAX_KEY_SIZE
,
48 .cra_cipher
.cia_setkey
= crypto_aes_set_key
,
49 .cra_cipher
.cia_encrypt
= aes_encrypt
,
50 .cra_cipher
.cia_decrypt
= aes_decrypt
53 static int __init
aes_init(void)
55 return crypto_register_alg(&aes_alg
);
58 static void __exit
aes_fini(void)
60 crypto_unregister_alg(&aes_alg
);
63 module_init(aes_init
);
64 module_exit(aes_fini
);
66 MODULE_DESCRIPTION("Scalar AES cipher for arm64");
67 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
68 MODULE_LICENSE("GPL v2");
69 MODULE_ALIAS_CRYPTO("aes");