Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2015-02-21 00:49:37 +0300
committerAdam Langley <agl@google.com>2015-02-21 02:44:33 +0300
commit3f309aef45e24dfdfc800b1cb0b6d9734ba9aff2 (patch)
tree5d778f2a741b3077bd26c12798095c6d7f03606f /crypto
parent44972944fd85bb38f5e28a2a912295717258c2cf (diff)
Tidy up RC4 a little.
RC4_CHUNK is always defined, RC4_INT is always uint32_t and the "register" keyword is an anachronism. Change-Id: Ia752af30ba6bac0ee6216ce189fcf3888de73c6e Reviewed-on: https://boringssl-review.googlesource.com/3544 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/rc4/rc4.c43
1 files changed, 5 insertions, 38 deletions
diff --git a/crypto/rc4/rc4.c b/crypto/rc4/rc4.c
index 2ebee3b2..2a98fd09 100644
--- a/crypto/rc4/rc4.c
+++ b/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]; \
@@ -328,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];