17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 #include <linux/module.h>
23 #include <linux/types.h>
25 #include <crypto/aes.h>
80 u64 *output,
unsigned int len);
82 u64 *output,
unsigned int len);
84 u64 *output,
unsigned int len);
87 u64 *output,
unsigned int len);
89 u64 *output,
unsigned int len);
91 u64 *output,
unsigned int len);
94 u64 *output,
unsigned int len,
98 u64 *output,
unsigned int len,
102 u64 *output,
unsigned int len,
106 u64 *output,
unsigned int len,
110 u64 *output,
unsigned int len,
114 u64 *output,
unsigned int len,
118 u64 *output,
unsigned int len,
121 u64 *output,
unsigned int len,
124 u64 *output,
unsigned int len,
166 static int aes_set_key(
struct crypto_tfm *tfm,
const u8 *in_key,
203 ctx->
ops->encrypt(&ctx->
key[0], (
const u32 *) src, (
u32 *) dst);
206 static void aes_decrypt(
struct crypto_tfm *tfm,
u8 *dst,
const u8 *src)
210 ctx->
ops->decrypt(&ctx->
key[0], (
const u32 *) src, (
u32 *) dst);
213 #define AES_BLOCK_MASK (~(AES_BLOCK_SIZE-1))
223 blkcipher_walk_init(&walk, dst, src, nbytes);
226 ctx->
ops->load_encrypt_keys(&ctx->
key[0]);
227 while ((nbytes = walk.
nbytes)) {
231 ctx->
ops->ecb_encrypt(&ctx->
key[0],
252 blkcipher_walk_init(&walk, dst, src, nbytes);
255 ctx->
ops->load_decrypt_keys(&ctx->
key[0]);
257 while ((nbytes = walk.nbytes)) {
261 ctx->
ops->ecb_decrypt(key_end,
262 (
const u64 *) walk.src.virt.addr,
263 (
u64 *) walk.dst.virt.addr, block_len);
281 blkcipher_walk_init(&walk, dst, src, nbytes);
284 ctx->
ops->load_encrypt_keys(&ctx->
key[0]);
285 while ((nbytes = walk.nbytes)) {
289 ctx->
ops->cbc_encrypt(&ctx->
key[0],
290 (
const u64 *)walk.src.virt.addr,
291 (
u64 *) walk.dst.virt.addr,
292 block_len, (
u64 *) walk.iv);
310 blkcipher_walk_init(&walk, dst, src, nbytes);
313 ctx->
ops->load_decrypt_keys(&ctx->
key[0]);
315 while ((nbytes = walk.nbytes)) {
319 ctx->
ops->cbc_decrypt(key_end,
320 (
const u64 *) walk.src.virt.addr,
321 (
u64 *) walk.dst.virt.addr,
322 block_len, (
u64 *) walk.iv);
340 blkcipher_walk_init(&walk, dst, src, nbytes);
343 ctx->
ops->load_encrypt_keys(&ctx->
key[0]);
344 while ((nbytes = walk.nbytes)) {
348 ctx->
ops->ctr_crypt(&ctx->
key[0],
349 (
const u64 *)walk.src.virt.addr,
350 (
u64 *) walk.dst.virt.addr,
351 block_len, (
u64 *) walk.iv);
362 .cra_driver_name =
"aes-sparc64",
373 .cia_setkey = aes_set_key,
374 .cia_encrypt = aes_encrypt,
375 .cia_decrypt = aes_decrypt
379 .cra_name =
"ecb(aes)",
380 .cra_driver_name =
"ecb-aes-sparc64",
392 .setkey = aes_set_key,
393 .encrypt = ecb_encrypt,
394 .decrypt = ecb_decrypt,
398 .cra_name =
"cbc(aes)",
399 .cra_driver_name =
"cbc-aes-sparc64",
411 .setkey = aes_set_key,
412 .encrypt = cbc_encrypt,
413 .decrypt = cbc_decrypt,
417 .cra_name =
"ctr(aes)",
418 .cra_driver_name =
"ctr-aes-sparc64",
430 .setkey = aes_set_key,
431 .encrypt = ctr_crypt,
432 .decrypt = ctr_crypt,
437 static bool __init sparc64_has_aes_opcode(
void)
444 __asm__ __volatile__(
"rd %%asr26, %0" :
"=r" (cfr));
451 static int __init aes_sparc64_mod_init(
void)
456 INIT_LIST_HEAD(&algs[i].cra_list);
458 if (sparc64_has_aes_opcode()) {
459 pr_info(
"Using sparc64 aes opcodes optimized AES implementation\n");
462 pr_info(
"sparc64 aes opcodes not available.\n");
466 static void __exit aes_sparc64_mod_fini(
void)