diff options
Diffstat (limited to 'crypto/salsa20_generic.c')
-rw-r--r-- | crypto/salsa20_generic.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c index 00fce32ae17a..c81a44404086 100644 --- a/crypto/salsa20_generic.c +++ b/crypto/salsa20_generic.c | |||
@@ -86,18 +86,17 @@ static void salsa20_docrypt(u32 *state, u8 *dst, const u8 *src, | |||
86 | { | 86 | { |
87 | __le32 stream[SALSA20_BLOCK_SIZE / sizeof(__le32)]; | 87 | __le32 stream[SALSA20_BLOCK_SIZE / sizeof(__le32)]; |
88 | 88 | ||
89 | if (dst != src) | ||
90 | memcpy(dst, src, bytes); | ||
91 | |||
92 | while (bytes >= SALSA20_BLOCK_SIZE) { | 89 | while (bytes >= SALSA20_BLOCK_SIZE) { |
93 | salsa20_block(state, stream); | 90 | salsa20_block(state, stream); |
94 | crypto_xor(dst, (const u8 *)stream, SALSA20_BLOCK_SIZE); | 91 | crypto_xor_cpy(dst, src, (const u8 *)stream, |
92 | SALSA20_BLOCK_SIZE); | ||
95 | bytes -= SALSA20_BLOCK_SIZE; | 93 | bytes -= SALSA20_BLOCK_SIZE; |
96 | dst += SALSA20_BLOCK_SIZE; | 94 | dst += SALSA20_BLOCK_SIZE; |
95 | src += SALSA20_BLOCK_SIZE; | ||
97 | } | 96 | } |
98 | if (bytes) { | 97 | if (bytes) { |
99 | salsa20_block(state, stream); | 98 | salsa20_block(state, stream); |
100 | crypto_xor(dst, (const u8 *)stream, bytes); | 99 | crypto_xor_cpy(dst, src, (const u8 *)stream, bytes); |
101 | } | 100 | } |
102 | } | 101 | } |
103 | 102 | ||
@@ -161,7 +160,7 @@ static int salsa20_crypt(struct skcipher_request *req) | |||
161 | 160 | ||
162 | err = skcipher_walk_virt(&walk, req, false); | 161 | err = skcipher_walk_virt(&walk, req, false); |
163 | 162 | ||
164 | salsa20_init(state, ctx, walk.iv); | 163 | salsa20_init(state, ctx, req->iv); |
165 | 164 | ||
166 | while (walk.nbytes > 0) { | 165 | while (walk.nbytes > 0) { |
167 | unsigned int nbytes = walk.nbytes; | 166 | unsigned int nbytes = walk.nbytes; |
@@ -204,7 +203,7 @@ static void __exit salsa20_generic_mod_fini(void) | |||
204 | crypto_unregister_skcipher(&alg); | 203 | crypto_unregister_skcipher(&alg); |
205 | } | 204 | } |
206 | 205 | ||
207 | module_init(salsa20_generic_mod_init); | 206 | subsys_initcall(salsa20_generic_mod_init); |
208 | module_exit(salsa20_generic_mod_fini); | 207 | module_exit(salsa20_generic_mod_fini); |
209 | 208 | ||
210 | MODULE_LICENSE("GPL"); | 209 | MODULE_LICENSE("GPL"); |