aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/des_generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/des_generic.c')
-rw-r--r--crypto/des_generic.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/crypto/des_generic.c b/crypto/des_generic.c
index 59966d14b8e0..355ecb71cb0d 100644
--- a/crypto/des_generic.c
+++ b/crypto/des_generic.c
@@ -20,13 +20,7 @@
20#include <linux/crypto.h> 20#include <linux/crypto.h>
21#include <linux/types.h> 21#include <linux/types.h>
22 22
23#define DES_KEY_SIZE 8 23#include <crypto/des.h>
24#define DES_EXPKEY_WORDS 32
25#define DES_BLOCK_SIZE 8
26
27#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)
28#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)
29#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE
30 24
31#define ROL(x, r) ((x) = rol32((x), (r))) 25#define ROL(x, r) ((x) = rol32((x), (r)))
32#define ROR(x, r) ((x) = ror32((x), (r))) 26#define ROR(x, r) ((x) = ror32((x), (r)))
@@ -634,7 +628,7 @@ static const u32 S8[64] = {
634 * Choice 1 has operated on the key. 628 * Choice 1 has operated on the key.
635 * 629 *
636 */ 630 */
637static unsigned long ekey(u32 *pe, const u8 *k) 631unsigned long des_ekey(u32 *pe, const u8 *k)
638{ 632{
639 /* K&R: long is at least 32 bits */ 633 /* K&R: long is at least 32 bits */
640 unsigned long a, b, c, d, w; 634 unsigned long a, b, c, d, w;
@@ -709,6 +703,7 @@ static unsigned long ekey(u32 *pe, const u8 *k)
709 /* Zero if weak key */ 703 /* Zero if weak key */
710 return w; 704 return w;
711} 705}
706EXPORT_SYMBOL_GPL(des_ekey);
712 707
713/* 708/*
714 * Decryption key expansion 709 * Decryption key expansion
@@ -792,7 +787,7 @@ static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
792 int ret; 787 int ret;
793 788
794 /* Expand to tmp */ 789 /* Expand to tmp */
795 ret = ekey(tmp, key); 790 ret = des_ekey(tmp, key);
796 791
797 if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) { 792 if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
798 *flags |= CRYPTO_TFM_RES_WEAK_KEY; 793 *flags |= CRYPTO_TFM_RES_WEAK_KEY;
@@ -879,9 +874,9 @@ static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key,
879 return -EINVAL; 874 return -EINVAL;
880 } 875 }
881 876
882 ekey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE; 877 des_ekey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE;
883 dkey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE; 878 dkey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE;
884 ekey(expkey, key); 879 des_ekey(expkey, key);
885 880
886 return 0; 881 return 0;
887} 882}