diff options
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/algapi.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 404e9558e879..ebe4ded0c55d 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h | |||
| @@ -191,9 +191,25 @@ static inline unsigned int crypto_queue_len(struct crypto_queue *queue) | |||
| 191 | return queue->qlen; | 191 | return queue->qlen; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | /* These functions require the input/output to be aligned as u32. */ | ||
| 195 | void crypto_inc(u8 *a, unsigned int size); | 194 | void crypto_inc(u8 *a, unsigned int size); |
| 196 | void crypto_xor(u8 *dst, const u8 *src, unsigned int size); | 195 | void __crypto_xor(u8 *dst, const u8 *src, unsigned int size); |
| 196 | |||
| 197 | static inline void crypto_xor(u8 *dst, const u8 *src, unsigned int size) | ||
| 198 | { | ||
| 199 | if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && | ||
| 200 | __builtin_constant_p(size) && | ||
| 201 | (size % sizeof(unsigned long)) == 0) { | ||
| 202 | unsigned long *d = (unsigned long *)dst; | ||
| 203 | unsigned long *s = (unsigned long *)src; | ||
| 204 | |||
| 205 | while (size > 0) { | ||
| 206 | *d++ ^= *s++; | ||
| 207 | size -= sizeof(unsigned long); | ||
| 208 | } | ||
| 209 | } else { | ||
| 210 | __crypto_xor(dst, src, size); | ||
| 211 | } | ||
| 212 | } | ||
| 197 | 213 | ||
| 198 | int blkcipher_walk_done(struct blkcipher_desc *desc, | 214 | int blkcipher_walk_done(struct blkcipher_desc *desc, |
| 199 | struct blkcipher_walk *walk, int err); | 215 | struct blkcipher_walk *walk, int err); |
