Source
6
6
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7
7
* Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
8
8
*
9
9
* This program is free software; you can redistribute it and/or modify it
10
10
* under the terms of the GNU General Public License as published by the Free
11
11
* Software Foundation; either version 2 of the License, or (at your option)
12
12
* any later version.
13
13
*
14
14
*/
15
15
16
+
#include <crypto/algapi.h>
16
17
#include <linux/kernel.h>
17
18
#include <linux/crypto.h>
18
19
#include <linux/errno.h>
19
20
#include <linux/slab.h>
20
21
#include <linux/string.h>
21
22
#include "internal.h"
22
23
23
24
static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key,
24
25
unsigned int keylen)
25
26
{
60
61
return cia->cia_setkey(tfm, key, keylen);
61
62
}
62
63
63
64
static void cipher_crypt_unaligned(void (*fn)(struct crypto_tfm *, u8 *,
64
65
const u8 *),
65
66
struct crypto_tfm *tfm,
66
67
u8 *dst, const u8 *src)
67
68
{
68
69
unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
69
70
unsigned int size = crypto_tfm_alg_blocksize(tfm);
70
-
u8 buffer[size + alignmask];
71
+
u8 buffer[MAX_CIPHER_BLOCKSIZE + MAX_CIPHER_ALIGNMASK];
71
72
u8 *tmp = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
72
73
73
74
memcpy(tmp, src, size);
74
75
fn(tfm, tmp, tmp);
75
76
memcpy(dst, tmp, size);
76
77
}
77
78
78
79
static void cipher_encrypt_unaligned(struct crypto_tfm *tfm,
79
80
u8 *dst, const u8 *src)
80
81
{