diff options
-rw-r--r-- | crypto/crypto_null.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c index f691d31fa9ee..3fcf6e887e87 100644 --- a/crypto/crypto_null.c +++ b/crypto/crypto_null.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <asm/scatterlist.h> | 22 | #include <asm/scatterlist.h> |
23 | #include <linux/crypto.h> | 23 | #include <linux/crypto.h> |
24 | #include <linux/string.h> | ||
24 | 25 | ||
25 | #define NULL_KEY_SIZE 0 | 26 | #define NULL_KEY_SIZE 0 |
26 | #define NULL_BLOCK_SIZE 1 | 27 | #define NULL_BLOCK_SIZE 1 |
@@ -28,11 +29,13 @@ | |||
28 | 29 | ||
29 | static int null_compress(void *ctx, const u8 *src, unsigned int slen, | 30 | static int null_compress(void *ctx, const u8 *src, unsigned int slen, |
30 | u8 *dst, unsigned int *dlen) | 31 | u8 *dst, unsigned int *dlen) |
31 | { return 0; } | 32 | { |
32 | 33 | if (slen > *dlen) | |
33 | static int null_decompress(void *ctx, const u8 *src, unsigned int slen, | 34 | return -EINVAL; |
34 | u8 *dst, unsigned int *dlen) | 35 | memcpy(dst, src, slen); |
35 | { return 0; } | 36 | *dlen = slen; |
37 | return 0; | ||
38 | } | ||
36 | 39 | ||
37 | static void null_init(void *ctx) | 40 | static void null_init(void *ctx) |
38 | { } | 41 | { } |
@@ -47,11 +50,10 @@ static int null_setkey(void *ctx, const u8 *key, | |||
47 | unsigned int keylen, u32 *flags) | 50 | unsigned int keylen, u32 *flags) |
48 | { return 0; } | 51 | { return 0; } |
49 | 52 | ||
50 | static void null_encrypt(void *ctx, u8 *dst, const u8 *src) | 53 | static void null_crypt(void *ctx, u8 *dst, const u8 *src) |
51 | { } | 54 | { |
52 | 55 | memcpy(dst, src, NULL_BLOCK_SIZE); | |
53 | static void null_decrypt(void *ctx, u8 *dst, const u8 *src) | 56 | } |
54 | { } | ||
55 | 57 | ||
56 | static struct crypto_alg compress_null = { | 58 | static struct crypto_alg compress_null = { |
57 | .cra_name = "compress_null", | 59 | .cra_name = "compress_null", |
@@ -62,7 +64,7 @@ static struct crypto_alg compress_null = { | |||
62 | .cra_list = LIST_HEAD_INIT(compress_null.cra_list), | 64 | .cra_list = LIST_HEAD_INIT(compress_null.cra_list), |
63 | .cra_u = { .compress = { | 65 | .cra_u = { .compress = { |
64 | .coa_compress = null_compress, | 66 | .coa_compress = null_compress, |
65 | .coa_decompress = null_decompress } } | 67 | .coa_decompress = null_compress } } |
66 | }; | 68 | }; |
67 | 69 | ||
68 | static struct crypto_alg digest_null = { | 70 | static struct crypto_alg digest_null = { |
@@ -90,8 +92,8 @@ static struct crypto_alg cipher_null = { | |||
90 | .cia_min_keysize = NULL_KEY_SIZE, | 92 | .cia_min_keysize = NULL_KEY_SIZE, |
91 | .cia_max_keysize = NULL_KEY_SIZE, | 93 | .cia_max_keysize = NULL_KEY_SIZE, |
92 | .cia_setkey = null_setkey, | 94 | .cia_setkey = null_setkey, |
93 | .cia_encrypt = null_encrypt, | 95 | .cia_encrypt = null_crypt, |
94 | .cia_decrypt = null_decrypt } } | 96 | .cia_decrypt = null_crypt } } |
95 | }; | 97 | }; |
96 | 98 | ||
97 | MODULE_ALIAS("compress_null"); | 99 | MODULE_ALIAS("compress_null"); |