summaryrefslogtreecommitdiffstats
path: root/src/crypto/rc4
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/rc4')
-rw-r--r--src/crypto/rc4/asm/rc4-x86_64.pl26
-rw-r--r--src/crypto/rc4/rc4.c67
2 files changed, 21 insertions, 72 deletions
diff --git a/src/crypto/rc4/asm/rc4-x86_64.pl b/src/crypto/rc4/asm/rc4-x86_64.pl
index 2c52ac0..db46242 100644
--- a/src/crypto/rc4/asm/rc4-x86_64.pl
+++ b/src/crypto/rc4/asm/rc4-x86_64.pl
@@ -502,32 +502,6 @@ asm_RC4_set_key:
mov %eax,-4($dat)
ret
.size asm_RC4_set_key,.-asm_RC4_set_key
-
-.globl RC4_options
-.type RC4_options,\@abi-omnipotent
-.align 16
-RC4_options:
- lea .Lopts(%rip),%rax
- mov OPENSSL_ia32cap_P(%rip),%rdx
- mov (%rdx),%edx
- bt \$20,%edx
- jc .L8xchar
- bt \$30,%edx
- jnc .Ldone
- add \$25,%rax
- ret
-.L8xchar:
- add \$12,%rax
-.Ldone:
- ret
-.align 64
-.Lopts:
-.asciz "rc4(8x,int)"
-.asciz "rc4(8x,char)"
-.asciz "rc4(16x,int)"
-.asciz "RC4 for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
-.align 64
-.size RC4_options,.-RC4_options
___
# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
diff --git a/src/crypto/rc4/rc4.c b/src/crypto/rc4/rc4.c
index 00b59c8..2a98fd0 100644
--- a/src/crypto/rc4/rc4.c
+++ b/src/crypto/rc4/rc4.c
@@ -67,8 +67,6 @@
#error "Unknown word size"
#endif
-#define RC4_INT uint32_t
-
/* RC4 as implemented from a posting from
* Newsgroups: sci.crypt
@@ -78,44 +76,14 @@
* Date: Wed, 14 Sep 1994 06:35:31 GMT */
void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
- register RC4_INT *d;
- register RC4_INT x, y, tx, ty;
+ uint32_t *d;
+ uint32_t x, y, tx, ty;
size_t i;
x = key->x;
y = key->y;
d = key->data;
-#if defined(RC4_CHUNK)
-/* The original reason for implementing this(*) was the fact that
- * pre-21164a Alpha CPUs don't have byte load/store instructions
- * and e.g. a byte store has to be done with 64-bit load, shift,
- * and, or and finally 64-bit store. Peaking data and operating
- * at natural word size made it possible to reduce amount of
- * instructions as well as to perform early read-ahead without
- * suffering from RAW (read-after-write) hazard. This resulted
- * in ~40%(**) performance improvement on 21064 box with gcc.
- * But it's not only Alpha users who win here:-) Thanks to the
- * early-n-wide read-ahead this implementation also exhibits
- * >40% speed-up on SPARC and 20-30% on 64-bit MIPS (depending
- * on sizeof(RC4_INT)).
- *
- * (*) "this" means code which recognizes the case when input
- * and output pointers appear to be aligned at natural CPU
- * word boundary
- * (**) i.e. according to 'apps/openssl speed rc4' benchmark,
- * crypto/rc4/rc4speed.c exhibits almost 70% speed-up...
- *
- * Cavets.
- *
- * - RC4_CHUNK="unsigned long long" should be a #1 choice for
- * UltraSPARC. Unfortunately gcc generates very slow code
- * (2.5-3 times slower than one generated by Sun's WorkShop
- * C) and therefore gcc (at least 2.95 and earlier) should
- * always be told that RC4_CHUNK="unsigned long".
- *
- * <appro@fy.chalmers.se> */
-
#define RC4_STEP \
(x = (x + 1) & 0xff, tx = d[x], y = (tx + y) & 0xff, ty = d[y], d[y] = tx, \
d[x] = ty, (RC4_CHUNK)d[(tx + ty) & 0xff])
@@ -255,7 +223,6 @@ void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
return;
}
}
-#endif
#define LOOP(in, out) \
x = ((x + 1) & 0xff); \
tx = d[x]; \
@@ -285,34 +252,42 @@ void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
in += 8;
out += 8;
#endif
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
}
}
i = len & 0x07;
if (i) {
for (;;) {
RC4_LOOP(in, out, 0);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
RC4_LOOP(in, out, 1);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
RC4_LOOP(in, out, 2);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
RC4_LOOP(in, out, 3);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
RC4_LOOP(in, out, 4);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
RC4_LOOP(in, out, 5);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
RC4_LOOP(in, out, 6);
- if (--i == 0)
+ if (--i == 0) {
break;
+ }
}
}
key->x = x;
@@ -320,9 +295,9 @@ void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
}
void RC4_set_key(RC4_KEY *rc4key, unsigned len, const uint8_t *key) {
- register RC4_INT tmp;
- register int id1, id2;
- register RC4_INT *d;
+ uint32_t tmp;
+ int id1, id2;
+ uint32_t *d;
unsigned int i;
d = &rc4key->data[0];