6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/module.h>
12 #include <linux/types.h>
21 #define CAMELLIA_MIN_KEY_SIZE 16
22 #define CAMELLIA_MAX_KEY_SIZE 32
23 #define CAMELLIA_BLOCK_SIZE 16
24 #define CAMELLIA_TABLE_BYTE_LEN 272
35 static int camellia_set_key(
struct crypto_tfm *tfm,
const u8 *_in_key,
39 const u32 *in_key = (
const u32 *) _in_key;
42 if (key_len != 16 && key_len != 24 && key_len != 32) {
55 u32 *output,
unsigned int key_len);
83 #define CAMELLIA_BLOCK_MASK (~(CAMELLIA_BLOCK_SIZE - 1))
95 op = camellia_sparc64_ecb_crypt_3_grand_rounds;
97 op = camellia_sparc64_ecb_crypt_4_grand_rounds;
99 blkcipher_walk_init(&walk, dst, src, nbytes);
107 while ((nbytes = walk.
nbytes)) {
116 op(src64, dst64, block_len, key);
129 return __ecb_crypt(desc, dst, src, nbytes,
true);
136 return __ecb_crypt(desc, dst, src, nbytes,
false);
157 op = camellia_sparc64_cbc_encrypt_3_grand_rounds;
159 op = camellia_sparc64_cbc_encrypt_4_grand_rounds;
161 blkcipher_walk_init(&walk, dst, src, nbytes);
166 while ((nbytes = walk.nbytes)) {
173 src64 = (
const u64 *)walk.src.virt.addr;
174 dst64 = (
u64 *) walk.dst.virt.addr;
175 op(src64, dst64, block_len, key,
195 op = camellia_sparc64_cbc_decrypt_3_grand_rounds;
197 op = camellia_sparc64_cbc_decrypt_4_grand_rounds;
199 blkcipher_walk_init(&walk, dst, src, nbytes);
204 while ((nbytes = walk.nbytes)) {
211 src64 = (
const u64 *)walk.src.virt.addr;
212 dst64 = (
u64 *) walk.dst.virt.addr;
213 op(src64, dst64, block_len, key,
224 .cra_name =
"camellia",
225 .cra_driver_name =
"camellia-sparc64",
236 .cia_setkey = camellia_set_key,
237 .cia_encrypt = camellia_encrypt,
238 .cia_decrypt = camellia_decrypt
242 .cra_name =
"ecb(camellia)",
243 .cra_driver_name =
"ecb-camellia-sparc64",
255 .setkey = camellia_set_key,
256 .encrypt = ecb_encrypt,
257 .decrypt = ecb_decrypt,
261 .cra_name =
"cbc(camellia)",
262 .cra_driver_name =
"cbc-camellia-sparc64",
274 .setkey = camellia_set_key,
275 .encrypt = cbc_encrypt,
276 .decrypt = cbc_decrypt,
282 static bool __init sparc64_has_camellia_opcode(
void)
289 __asm__ __volatile__(
"rd %%asr26, %0" :
"=r" (cfr));
296 static int __init camellia_sparc64_mod_init(
void)
301 INIT_LIST_HEAD(&algs[i].cra_list);
303 if (sparc64_has_camellia_opcode()) {
304 pr_info(
"Using sparc64 camellia opcodes optimized CAMELLIA implementation\n");
307 pr_info(
"sparc64 camellia opcodes not available.\n");
311 static void __exit camellia_sparc64_mod_fini(
void)