16 #include <linux/kernel.h>
18 #include <linux/errno.h>
19 #include <linux/slab.h>
20 #include <linux/string.h>
27 unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
32 absize = keylen + alignmask;
37 alignbuffer = (
u8 *)
ALIGN((
unsigned long)
buffer, alignmask + 1);
38 memcpy(alignbuffer, key, keylen);
39 ret = cia->
cia_setkey(tfm, alignbuffer, keylen);
40 memset(alignbuffer, 0, keylen);
49 unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
57 if ((
unsigned long)key & alignmask)
58 return setkey_unaligned(tfm, key, keylen);
63 static void cipher_crypt_unaligned(
void (*
fn)(
struct crypto_tfm *,
u8 *,
68 unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
69 unsigned int size = crypto_tfm_alg_blocksize(tfm);
70 u8 buffer[size + alignmask];
78 static void cipher_encrypt_unaligned(
struct crypto_tfm *tfm,
79 u8 *dst,
const u8 *src)
81 unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
84 if (
unlikely(((
unsigned long)dst | (
unsigned long)src) & alignmask)) {
85 cipher_crypt_unaligned(cipher->
cia_encrypt, tfm, dst, src);
92 static void cipher_decrypt_unaligned(
struct crypto_tfm *tfm,
93 u8 *dst,
const u8 *src)
95 unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
98 if (
unlikely(((
unsigned long)dst | (
unsigned long)src) & alignmask)) {
99 cipher_crypt_unaligned(cipher->
cia_decrypt, tfm, dst, src);