提交 9f03d0fc 编写于 作者: A Andy Polyakov

Optimize #undef DES_UNROLL for size.

上级 2140659b
...@@ -108,12 +108,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) ...@@ -108,12 +108,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(l,r,28); /* 15 */
D_ENCRYPT(r,l,30); /* 16 */ D_ENCRYPT(r,l,30); /* 16 */
#else #else
for (i=0; i<32; i+=8) for (i=0; i<32; i+=4)
{ {
D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(l,r,i+0); /* 1 */
D_ENCRYPT(r,l,i+2); /* 2 */ D_ENCRYPT(r,l,i+2); /* 2 */
D_ENCRYPT(l,r,i+4); /* 3 */
D_ENCRYPT(r,l,i+6); /* 4 */
} }
#endif #endif
} }
...@@ -137,12 +135,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) ...@@ -137,12 +135,10 @@ void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(l,r, 2); /* 2 */ D_ENCRYPT(l,r, 2); /* 2 */
D_ENCRYPT(r,l, 0); /* 1 */ D_ENCRYPT(r,l, 0); /* 1 */
#else #else
for (i=30; i>0; i-=8) for (i=30; i>0; i-=4)
{ {
D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(l,r,i-0); /* 16 */
D_ENCRYPT(r,l,i-2); /* 15 */ D_ENCRYPT(r,l,i-2); /* 15 */
D_ENCRYPT(l,r,i-4); /* 14 */
D_ENCRYPT(r,l,i-6); /* 13 */
} }
#endif #endif
} }
...@@ -204,12 +200,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) ...@@ -204,12 +200,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(l,r,28); /* 15 */ D_ENCRYPT(l,r,28); /* 15 */
D_ENCRYPT(r,l,30); /* 16 */ D_ENCRYPT(r,l,30); /* 16 */
#else #else
for (i=0; i<32; i+=8) for (i=0; i<32; i+=4)
{ {
D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(l,r,i+0); /* 1 */
D_ENCRYPT(r,l,i+2); /* 2 */ D_ENCRYPT(r,l,i+2); /* 2 */
D_ENCRYPT(l,r,i+4); /* 3 */
D_ENCRYPT(r,l,i+6); /* 4 */
} }
#endif #endif
} }
...@@ -233,12 +227,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) ...@@ -233,12 +227,10 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
D_ENCRYPT(l,r, 2); /* 2 */ D_ENCRYPT(l,r, 2); /* 2 */
D_ENCRYPT(r,l, 0); /* 1 */ D_ENCRYPT(r,l, 0); /* 1 */
#else #else
for (i=30; i>0; i-=8) for (i=30; i>0; i-=4)
{ {
D_ENCRYPT(l,r,i-0); /* 16 */ D_ENCRYPT(l,r,i-0); /* 16 */
D_ENCRYPT(r,l,i-2); /* 15 */ D_ENCRYPT(r,l,i-2); /* 15 */
D_ENCRYPT(l,r,i-4); /* 14 */
D_ENCRYPT(r,l,i-6); /* 13 */
} }
#endif #endif
} }
......
...@@ -91,7 +91,7 @@ const char *DES_options(void) ...@@ -91,7 +91,7 @@ const char *DES_options(void)
#ifdef DES_UNROLL #ifdef DES_UNROLL
unroll="16"; unroll="16";
#else #else
unroll="4"; unroll="2";
#endif #endif
if (sizeof(DES_LONG) != sizeof(long)) if (sizeof(DES_LONG) != sizeof(long))
size="int"; size="int";
......
...@@ -100,12 +100,10 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, ...@@ -100,12 +100,10 @@ void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
#ifndef DES_UNROLL #ifndef DES_UNROLL
register int i; register int i;
for (i=0; i<32; i+=8) for (i=0; i<32; i+=4)
{ {
D_ENCRYPT(l,r,i+0); /* 1 */ D_ENCRYPT(l,r,i+0); /* 1 */
D_ENCRYPT(r,l,i+2); /* 2 */ D_ENCRYPT(r,l,i+2); /* 2 */
D_ENCRYPT(l,r,i+4); /* 1 */
D_ENCRYPT(r,l,i+6); /* 2 */
} }
#else #else
D_ENCRYPT(l,r, 0); /* 1 */ D_ENCRYPT(l,r, 0); /* 1 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册