diff options
Diffstat (limited to 'src/lib/libcrypto/rc4/rc4_skey.c')
| -rw-r--r-- | src/lib/libcrypto/rc4/rc4_skey.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/src/lib/libcrypto/rc4/rc4_skey.c b/src/lib/libcrypto/rc4/rc4_skey.c index 7ef4da3f15..861941fb4d 100644 --- a/src/lib/libcrypto/rc4/rc4_skey.c +++ b/src/lib/libcrypto/rc4/rc4_skey.c | |||
| @@ -1,25 +1,25 @@ | |||
| 1 | /* $OpenBSD: rc4_skey.c,v 1.13 2014/10/28 07:35:59 jsg Exp $ */ | 1 | /* $OpenBSD: rc4_skey.c,v 1.14 2015/10/20 15:50:13 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
| 13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
| 19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
| 20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
| 21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -60,8 +60,9 @@ | |||
| 60 | #include "rc4_locl.h" | 60 | #include "rc4_locl.h" |
| 61 | #include <openssl/opensslv.h> | 61 | #include <openssl/opensslv.h> |
| 62 | 62 | ||
| 63 | const char *RC4_options(void) | 63 | const char * |
| 64 | { | 64 | RC4_options(void) |
| 65 | { | ||
| 65 | #ifdef RC4_INDEX | 66 | #ifdef RC4_INDEX |
| 66 | if (sizeof(RC4_INT) == 1) | 67 | if (sizeof(RC4_INT) == 1) |
| 67 | return("rc4(idx,char)"); | 68 | return("rc4(idx,char)"); |
| @@ -73,7 +74,7 @@ const char *RC4_options(void) | |||
| 73 | else | 74 | else |
| 74 | return("rc4(ptr,int)"); | 75 | return("rc4(ptr,int)"); |
| 75 | #endif | 76 | #endif |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | /* RC4 as implemented from a posting from | 79 | /* RC4 as implemented from a posting from |
| 79 | * Newsgroups: sci.crypt | 80 | * Newsgroups: sci.crypt |
| @@ -83,17 +84,18 @@ const char *RC4_options(void) | |||
| 83 | * Date: Wed, 14 Sep 1994 06:35:31 GMT | 84 | * Date: Wed, 14 Sep 1994 06:35:31 GMT |
| 84 | */ | 85 | */ |
| 85 | 86 | ||
| 86 | void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) | 87 | void |
| 87 | { | 88 | RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) |
| 88 | RC4_INT tmp; | 89 | { |
| 89 | int id1,id2; | 90 | RC4_INT tmp; |
| 90 | RC4_INT *d; | 91 | int id1, id2; |
| 91 | unsigned int i; | 92 | RC4_INT *d; |
| 92 | 93 | unsigned int i; | |
| 93 | d= &(key->data[0]); | 94 | |
| 94 | key->x = 0; | 95 | d = &(key->data[0]); |
| 95 | key->y = 0; | 96 | key->x = 0; |
| 96 | id1=id2=0; | 97 | key->y = 0; |
| 98 | id1 = id2 = 0; | ||
| 97 | 99 | ||
| 98 | #define SK_LOOP(d,n) { \ | 100 | #define SK_LOOP(d,n) { \ |
| 99 | tmp=d[(n)]; \ | 101 | tmp=d[(n)]; \ |
| @@ -102,13 +104,12 @@ void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) | |||
| 102 | d[(n)]=d[id2]; \ | 104 | d[(n)]=d[id2]; \ |
| 103 | d[id2]=tmp; } | 105 | d[id2]=tmp; } |
| 104 | 106 | ||
| 105 | for (i=0; i < 256; i++) d[i]=i; | 107 | for (i = 0; i < 256; i++) |
| 106 | for (i=0; i < 256; i+=4) | 108 | d[i] = i; |
| 107 | { | 109 | for (i = 0; i < 256; i += 4) { |
| 108 | SK_LOOP(d,i+0); | 110 | SK_LOOP(d, i + 0); |
| 109 | SK_LOOP(d,i+1); | 111 | SK_LOOP(d, i + 1); |
| 110 | SK_LOOP(d,i+2); | 112 | SK_LOOP(d, i + 2); |
| 111 | SK_LOOP(d,i+3); | 113 | SK_LOOP(d, i + 3); |
| 112 | } | ||
| 113 | } | 114 | } |
| 114 | 115 | } | |
