aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/algapi.c47
-rw-r--r--include/crypto/algapi.h4
2 files changed, 51 insertions, 0 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 8383282de1dd..08eca6da1d53 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -605,6 +605,53 @@ int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm)
605} 605}
606EXPORT_SYMBOL_GPL(crypto_tfm_in_queue); 606EXPORT_SYMBOL_GPL(crypto_tfm_in_queue);
607 607
608static inline void crypto_inc_byte(u8 *a, unsigned int size)
609{
610 u8 *b = (a + size);
611 u8 c;
612
613 for (; size; size--) {
614 c = *--b + 1;
615 *b = c;
616 if (c)
617 break;
618 }
619}
620
621void crypto_inc(u8 *a, unsigned int size)
622{
623 __be32 *b = (__be32 *)(a + size);
624 u32 c;
625
626 for (; size >= 4; size -= 4) {
627 c = be32_to_cpu(*--b) + 1;
628 *b = cpu_to_be32(c);
629 if (c)
630 return;
631 }
632
633 crypto_inc_byte(a, size);
634}
635EXPORT_SYMBOL_GPL(crypto_inc);
636
637static inline void crypto_xor_byte(u8 *a, const u8 *b, unsigned int size)
638{
639 for (; size; size--)
640 *a++ ^= *b++;
641}
642
643void crypto_xor(u8 *dst, const u8 *src, unsigned int size)
644{
645 u32 *a = (u32 *)dst;
646 u32 *b = (u32 *)src;
647
648 for (; size >= 4; size -= 4)
649 *a++ ^= *b++;
650
651 crypto_xor_byte((u8 *)a, (u8 *)b, size);
652}
653EXPORT_SYMBOL_GPL(crypto_xor);
654
608static int __init crypto_algapi_init(void) 655static int __init crypto_algapi_init(void)
609{ 656{
610 crypto_init_proc(); 657 crypto_init_proc();
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 88619f902c10..2cdb227fc39d 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -124,6 +124,10 @@ int crypto_enqueue_request(struct crypto_queue *queue,
124struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue); 124struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue);
125int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm); 125int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm);
126 126
127/* These functions require the input/output to be aligned as u32. */
128void crypto_inc(u8 *a, unsigned int size);
129void crypto_xor(u8 *dst, const u8 *src, unsigned int size);
130
127int blkcipher_walk_done(struct blkcipher_desc *desc, 131int blkcipher_walk_done(struct blkcipher_desc *desc,
128 struct blkcipher_walk *walk, int err); 132 struct blkcipher_walk *walk, int err);
129int blkcipher_walk_virt(struct blkcipher_desc *desc, 133int blkcipher_walk_virt(struct blkcipher_desc *desc,