aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/des
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2016-01-27 18:43:25 -0500
committerRich Salz <rsalz@openssl.org>2016-01-27 19:05:50 -0500
commit3e9e810f2e047effb1056211794d2d12ec2b04e7 (patch)
tree26c730915e8c56590fa8fc148da2651dab7f7c8c /crypto/des
parent8ed40b83ec19aab146a3df701c83066c8788a7a8 (diff)
downloadopenssl-3e9e810f2e047effb1056211794d2d12ec2b04e7.tar.gz
Remove outdated legacy crypto options
Many options for supporting optimizations for legacy crypto on legacy platforms have been removed. This simplifies the source code and does not really penalize anyone. DES_PTR (always on) DES_RISC1, DES_RISC2 (always off) DES_INT (always 'unsigned int') DES_UNROLL (always on) BF_PTR (always on) BF_PTR2 (removed) MD2_CHAR, MD2_LONG (always 'unsigned char') IDEA_SHORT, IDEA_LONG (always 'unsigned int') RC2_SHORT, RC2_LONG (always 'unsigned int') RC4_LONG (only int and char (for assembler) are supported) RC4_CHUNK (always long), RC_CHUNK_LL (removed) RC4_INDEX (always on) And also make D_ENCRYPT macro more clear (@appro) This is done in consultation with Andy. Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'crypto/des')
-rw-r--r--crypto/des/des_enc.c40
-rw-r--r--crypto/des/des_locl.h171
-rw-r--r--crypto/des/ecb_enc.c25
-rw-r--r--crypto/des/fcrypt_b.c21
4 files changed, 15 insertions, 242 deletions
diff --git a/crypto/des/des_enc.c b/crypto/des/des_enc.c
index 613735190f..1f827f216e 100644
--- a/crypto/des/des_enc.c
+++ b/crypto/des/des_enc.c
@@ -62,12 +62,6 @@
void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
{
register DES_LONG l, r, t, u;
-#ifdef DES_PTR
- register const unsigned char *des_SP = (const unsigned char *)DES_SPtrans;
-#endif
-#ifndef DES_UNROLL
- register int i;
-#endif
register DES_LONG *s;
r = data[0];
@@ -92,7 +86,6 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
* loop
*/
if (enc) {
-#ifdef DES_UNROLL
D_ENCRYPT(l, r, 0); /* 1 */
D_ENCRYPT(r, l, 2); /* 2 */
D_ENCRYPT(l, r, 4); /* 3 */
@@ -109,14 +102,7 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(r, l, 26); /* 14 */
D_ENCRYPT(l, r, 28); /* 15 */
D_ENCRYPT(r, l, 30); /* 16 */
-#else
- for (i = 0; i < 32; i += 4) {
- D_ENCRYPT(l, r, i + 0); /* 1 */
- D_ENCRYPT(r, l, i + 2); /* 2 */
- }
-#endif
} else {
-#ifdef DES_UNROLL
D_ENCRYPT(l, r, 30); /* 16 */
D_ENCRYPT(r, l, 28); /* 15 */
D_ENCRYPT(l, r, 26); /* 14 */
@@ -133,12 +119,6 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(r, l, 4); /* 3 */
D_ENCRYPT(l, r, 2); /* 2 */
D_ENCRYPT(r, l, 0); /* 1 */
-#else
- for (i = 30; i > 0; i -= 4) {
- D_ENCRYPT(l, r, i - 0); /* 16 */
- D_ENCRYPT(r, l, i - 2); /* 15 */
- }
-#endif
}
/* rotate and clear the top bits on machines with 8byte longs */
@@ -154,12 +134,6 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
{
register DES_LONG l, r, t, u;
-#ifdef DES_PTR
- register const unsigned char *des_SP = (const unsigned char *)DES_SPtrans;
-#endif
-#ifndef DES_UNROLL
- register int i;
-#endif
register DES_LONG *s;
r = data[0];
@@ -182,7 +156,6 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
* loop
*/
if (enc) {
-#ifdef DES_UNROLL
D_ENCRYPT(l, r, 0); /* 1 */
D_ENCRYPT(r, l, 2); /* 2 */
D_ENCRYPT(l, r, 4); /* 3 */
@@ -199,14 +172,7 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(r, l, 26); /* 14 */
D_ENCRYPT(l, r, 28); /* 15 */
D_ENCRYPT(r, l, 30); /* 16 */
-#else
- for (i = 0; i < 32; i += 4) {
- D_ENCRYPT(l, r, i + 0); /* 1 */
- D_ENCRYPT(r, l, i + 2); /* 2 */
- }
-#endif
} else {
-#ifdef DES_UNROLL
D_ENCRYPT(l, r, 30); /* 16 */
D_ENCRYPT(r, l, 28); /* 15 */
D_ENCRYPT(l, r, 26); /* 14 */
@@ -223,12 +189,6 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(r, l, 4); /* 3 */
D_ENCRYPT(l, r, 2); /* 2 */
D_ENCRYPT(r, l, 0); /* 1 */
-#else
- for (i = 30; i > 0; i -= 4) {
- D_ENCRYPT(l, r, i - 0); /* 16 */
- D_ENCRYPT(r, l, i - 2); /* 15 */
- }
-#endif
}
/* rotate and clear the top bits on machines with 8byte longs */
data[0] = ROTATE(l, 3) & 0xffffffffL;
diff --git a/crypto/des/des_locl.h b/crypto/des/des_locl.h
index 651eb3a61c..7ed783cb37 100644
--- a/crypto/des/des_locl.h
+++ b/crypto/des/des_locl.h
@@ -60,8 +60,6 @@
# include <openssl/e_os2.h>
-# include "internal/des_conf.h"
-
# if defined(OPENSSL_SYS_WIN32)
# ifndef OPENSSL_SYS_MSDOS
# define OPENSSL_SYS_MSDOS
@@ -205,171 +203,23 @@
# endif
/*
- * The changes to this macro may help or hinder, depending on the compiler
- * and the architecture. gcc2 always seems to do well :-). Inspired by Dana
- * How <how@isl.stanford.edu> DO NOT use the alternative version on machines
- * with 8 byte longs. It does not seem to work on the Alpha, even when
- * DES_LONG is 4 bytes, probably an issue of accessing non-word aligned
- * objects :-(
- */
-# ifdef DES_PTR
-
-/*
* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there is no reason
* to not xor all the sub items together. This potentially saves a register
* since things can be xored directly into L
*/
-# if defined(DES_RISC1) || defined(DES_RISC2)
-# ifdef DES_RISC1
-# define D_ENCRYPT(LL,R,S) { \
- unsigned int u1,u2,u3; \
- LOAD_DATA(R,S,u,t,E0,E1,u1); \
- u2=(int)u>>8L; \
- u1=(int)u&0xfc; \
- u2&=0xfc; \
- t=ROTATE(t,4); \
- u>>=16L; \
- LL^= *(const DES_LONG *)(des_SP +u1); \
- LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
- u3=(int)(u>>8L); \
- u1=(int)u&0xfc; \
- u3&=0xfc; \
- LL^= *(const DES_LONG *)(des_SP+0x400+u1); \
- LL^= *(const DES_LONG *)(des_SP+0x600+u3); \
- u2=(int)t>>8L; \
- u1=(int)t&0xfc; \
- u2&=0xfc; \
- t>>=16L; \
- LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
- LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
- u3=(int)t>>8L; \
- u1=(int)t&0xfc; \
- u3&=0xfc; \
- LL^= *(const DES_LONG *)(des_SP+0x500+u1); \
- LL^= *(const DES_LONG *)(des_SP+0x700+u3); }
-# endif
-# ifdef DES_RISC2
-# define D_ENCRYPT(LL,R,S) { \
- unsigned int u1,u2,s1,s2; \
- LOAD_DATA(R,S,u,t,E0,E1,u1); \
- u2=(int)u>>8L; \
- u1=(int)u&0xfc; \
- u2&=0xfc; \
- t=ROTATE(t,4); \
- LL^= *(const DES_LONG *)(des_SP +u1); \
- LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
- s1=(int)(u>>16L); \
- s2=(int)(u>>24L); \
- s1&=0xfc; \
- s2&=0xfc; \
- LL^= *(const DES_LONG *)(des_SP+0x400+s1); \
- LL^= *(const DES_LONG *)(des_SP+0x600+s2); \
- u2=(int)t>>8L; \
- u1=(int)t&0xfc; \
- u2&=0xfc; \
- LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
- LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
- s1=(int)(t>>16L); \
- s2=(int)(t>>24L); \
- s1&=0xfc; \
- s2&=0xfc; \
- LL^= *(const DES_LONG *)(des_SP+0x500+s1); \
- LL^= *(const DES_LONG *)(des_SP+0x700+s2); }
-# endif
-# else
-# define D_ENCRYPT(LL,R,S) { \
+# define D_ENCRYPT(LL,R,S) { \
LOAD_DATA_tmp(R,S,u,t,E0,E1); \
t=ROTATE(t,4); \
LL^= \
- *(const DES_LONG *)(des_SP +((u )&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \
- *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); }
-# endif
-
-# else /* original version */
-
-# if defined(DES_RISC1) || defined(DES_RISC2)
-# ifdef DES_RISC1
-# define D_ENCRYPT(LL,R,S) {\
- unsigned int u1,u2,u3; \
- LOAD_DATA(R,S,u,t,E0,E1,u1); \
- u>>=2L; \
- t=ROTATE(t,6); \
- u2=(int)u>>8L; \
- u1=(int)u&0x3f; \
- u2&=0x3f; \
- u>>=16L; \
- LL^=DES_SPtrans[0][u1]; \
- LL^=DES_SPtrans[2][u2]; \
- u3=(int)u>>8L; \
- u1=(int)u&0x3f; \
- u3&=0x3f; \
- LL^=DES_SPtrans[4][u1]; \
- LL^=DES_SPtrans[6][u3]; \
- u2=(int)t>>8L; \
- u1=(int)t&0x3f; \
- u2&=0x3f; \
- t>>=16L; \
- LL^=DES_SPtrans[1][u1]; \
- LL^=DES_SPtrans[3][u2]; \
- u3=(int)t>>8L; \
- u1=(int)t&0x3f; \
- u3&=0x3f; \
- LL^=DES_SPtrans[5][u1]; \
- LL^=DES_SPtrans[7][u3]; }
-# endif
-# ifdef DES_RISC2
-# define D_ENCRYPT(LL,R,S) {\
- unsigned int u1,u2,s1,s2; \
- LOAD_DATA(R,S,u,t,E0,E1,u1); \
- u>>=2L; \
- t=ROTATE(t,6); \
- u2=(int)u>>8L; \
- u1=(int)u&0x3f; \
- u2&=0x3f; \
- LL^=DES_SPtrans[0][u1]; \
- LL^=DES_SPtrans[2][u2]; \
- s1=(int)u>>16L; \
- s2=(int)u>>24L; \
- s1&=0x3f; \
- s2&=0x3f; \
- LL^=DES_SPtrans[4][s1]; \
- LL^=DES_SPtrans[6][s2]; \
- u2=(int)t>>8L; \
- u1=(int)t&0x3f; \
- u2&=0x3f; \
- LL^=DES_SPtrans[1][u1]; \
- LL^=DES_SPtrans[3][u2]; \
- s1=(int)t>>16; \
- s2=(int)t>>24L; \
- s1&=0x3f; \
- s2&=0x3f; \
- LL^=DES_SPtrans[5][s1]; \
- LL^=DES_SPtrans[7][s2]; }
-# endif
-
-# else
-
-# define D_ENCRYPT(LL,R,S) {\
- LOAD_DATA_tmp(R,S,u,t,E0,E1); \
- t=ROTATE(t,4); \
- LL^=\
- DES_SPtrans[0][(u>> 2L)&0x3f]^ \
- DES_SPtrans[2][(u>>10L)&0x3f]^ \
- DES_SPtrans[4][(u>>18L)&0x3f]^ \
- DES_SPtrans[6][(u>>26L)&0x3f]^ \
- DES_SPtrans[1][(t>> 2L)&0x3f]^ \
- DES_SPtrans[3][(t>>10L)&0x3f]^ \
- DES_SPtrans[5][(t>>18L)&0x3f]^ \
- DES_SPtrans[7][(t>>26L)&0x3f]; }
-# endif
-# endif
+ DES_SPtrans[0][(u>> 2L)&0x3f]^ \
+ DES_SPtrans[2][(u>>10L)&0x3f]^ \
+ DES_SPtrans[4][(u>>18L)&0x3f]^ \
+ DES_SPtrans[6][(u>>26L)&0x3f]^ \
+ DES_SPtrans[1][(t>> 2L)&0x3f]^ \
+ DES_SPtrans[3][(t>>10L)&0x3f]^ \
+ DES_SPtrans[5][(t>>18L)&0x3f]^ \
+ DES_SPtrans[7][(t>>26L)&0x3f]; }
/*-
* IP and FP
@@ -438,7 +288,4 @@ extern const DES_LONG DES_SPtrans[8][64];
void fcrypt_body(DES_LONG *out, DES_key_schedule *ks,
DES_LONG Eswap0, DES_LONG Eswap1);
-# ifdef OPENSSL_SMALL_FOOTPRINT
-# undef DES_UNROLL
-# endif
#endif
diff --git a/crypto/des/ecb_enc.c b/crypto/des/ecb_enc.c
index 56a6a0b4da..109ffd430f 100644
--- a/crypto/des/ecb_enc.c
+++ b/crypto/des/ecb_enc.c
@@ -66,34 +66,13 @@ const char *DES_options(void)
static char buf[32];
if (init) {
- const char *ptr, *unroll, *risc, *size;
+ const char *size;
-#ifdef DES_PTR
- ptr = "ptr";
-#else
- ptr = "idx";
-#endif
-#if defined(DES_RISC1) || defined(DES_RISC2)
-# ifdef DES_RISC1
- risc = "risc1";
-# endif
-# ifdef DES_RISC2
- risc = "risc2";
-# endif
-#else
- risc = "cisc";
-#endif
-#ifdef DES_UNROLL
- unroll = "16";
-#else
- unroll = "2";
-#endif
if (sizeof(DES_LONG) != sizeof(long))
size = "int";
else
size = "long";
- BIO_snprintf(buf, sizeof buf, "des(%s,%s,%s,%s)", ptr, risc, unroll,
- size);
+ BIO_snprintf(buf, sizeof buf, "des(%s)", size);
init = 0;
}
return (buf);
diff --git a/crypto/des/fcrypt_b.c b/crypto/des/fcrypt_b.c
index 8fb9350c87..6e02ac7c3c 100644
--- a/crypto/des/fcrypt_b.c
+++ b/crypto/des/fcrypt_b.c
@@ -80,9 +80,6 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
DES_LONG Eswap1)
{
register DES_LONG l, r, t, u;
-#ifdef DES_PTR
- register const unsigned char *des_SP = (const unsigned char *)DES_SPtrans;
-#endif
register DES_LONG *s;
register int j;
register DES_LONG E0, E1;
@@ -95,14 +92,6 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
E1 = Eswap1;
for (j = 0; j < 25; j++) {
-#ifndef DES_UNROLL
- register int i;
-
- for (i = 0; i < 32; i += 4) {
- D_ENCRYPT(l, r, i + 0); /* 1 */
- D_ENCRYPT(r, l, i + 2); /* 2 */
- }
-#else
D_ENCRYPT(l, r, 0); /* 1 */
D_ENCRYPT(r, l, 2); /* 2 */
D_ENCRYPT(l, r, 4); /* 3 */
@@ -119,8 +108,6 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
D_ENCRYPT(r, l, 26); /* 14 */
D_ENCRYPT(l, r, 28); /* 15 */
D_ENCRYPT(r, l, 30); /* 16 */
-#endif
-
t = l;
l = r;
r = t;
@@ -128,11 +115,11 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
l = ROTATE(l, 3) & 0xffffffffL;
r = ROTATE(r, 3) & 0xffffffffL;
- PERM_OP(l, r, t, 1, 0x55555555L);
- PERM_OP(r, l, t, 8, 0x00ff00ffL);
- PERM_OP(l, r, t, 2, 0x33333333L);
+ PERM_OP(l, r, t, 1, 0x55555555L);
+ PERM_OP(r, l, t, 8, 0x00ff00ffL);
+ PERM_OP(l, r, t, 2, 0x33333333L);
PERM_OP(r, l, t, 16, 0x0000ffffL);
- PERM_OP(l, r, t, 4, 0x0f0f0f0fL);
+ PERM_OP(l, r, t, 4, 0x0f0f0f0fL);
out[0] = r;
out[1] = l;