diff options
| author | jsing <> | 2014-05-08 15:13:06 +0000 |
|---|---|---|
| committer | jsing <> | 2014-05-08 15:13:06 +0000 |
| commit | afa026a20fd107fc700f84f9b2db8b5320e934f1 (patch) | |
| tree | ef972fdbbb4716d3000038e30dffd3367e980018 /src/lib/libcrypto/evp/e_rc4.c | |
| parent | 5420bf0ea074216c637a5b6f7a6c9143a629f1ab (diff) | |
| download | openbsd-afa026a20fd107fc700f84f9b2db8b5320e934f1.tar.gz openbsd-afa026a20fd107fc700f84f9b2db8b5320e934f1.tar.bz2 openbsd-afa026a20fd107fc700f84f9b2db8b5320e934f1.zip | |
KNF.
Diffstat (limited to 'src/lib/libcrypto/evp/e_rc4.c')
| -rw-r--r-- | src/lib/libcrypto/evp/e_rc4.c | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c index b4f6bda82d..f66885f70d 100644 --- a/src/lib/libcrypto/evp/e_rc4.c +++ b/src/lib/libcrypto/evp/e_rc4.c | |||
| @@ -5,21 +5,21 @@ | |||
| 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 |
| @@ -69,21 +69,20 @@ | |||
| 69 | /* FIXME: surely this is available elsewhere? */ | 69 | /* FIXME: surely this is available elsewhere? */ |
| 70 | #define EVP_RC4_KEY_SIZE 16 | 70 | #define EVP_RC4_KEY_SIZE 16 |
| 71 | 71 | ||
| 72 | typedef struct | 72 | typedef struct { |
| 73 | { | ||
| 74 | RC4_KEY ks; /* working key */ | 73 | RC4_KEY ks; /* working key */ |
| 75 | } EVP_RC4_KEY; | 74 | } EVP_RC4_KEY; |
| 76 | 75 | ||
| 77 | #define data(ctx) ((EVP_RC4_KEY *)(ctx)->cipher_data) | 76 | #define data(ctx) ((EVP_RC4_KEY *)(ctx)->cipher_data) |
| 78 | 77 | ||
| 79 | static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 78 | static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 80 | const unsigned char *iv,int enc); | 79 | const unsigned char *iv, int enc); |
| 81 | static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 80 | static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 82 | const unsigned char *in, size_t inl); | 81 | const unsigned char *in, size_t inl); |
| 83 | static const EVP_CIPHER r4_cipher= | 82 | |
| 84 | { | 83 | static const EVP_CIPHER r4_cipher = { |
| 85 | NID_rc4, | 84 | NID_rc4, |
| 86 | 1,EVP_RC4_KEY_SIZE,0, | 85 | 1, EVP_RC4_KEY_SIZE, 0, |
| 87 | EVP_CIPH_VARIABLE_LENGTH, | 86 | EVP_CIPH_VARIABLE_LENGTH, |
| 88 | rc4_init_key, | 87 | rc4_init_key, |
| 89 | rc4_cipher, | 88 | rc4_cipher, |
| @@ -93,45 +92,47 @@ static const EVP_CIPHER r4_cipher= | |||
| 93 | NULL, | 92 | NULL, |
| 94 | NULL, | 93 | NULL, |
| 95 | NULL | 94 | NULL |
| 96 | }; | 95 | }; |
| 97 | 96 | ||
| 98 | static const EVP_CIPHER r4_40_cipher= | 97 | static const EVP_CIPHER r4_40_cipher = { |
| 99 | { | ||
| 100 | NID_rc4_40, | 98 | NID_rc4_40, |
| 101 | 1,5 /* 40 bit */,0, | 99 | 1, 5 /* 40 bit */, 0, |
| 102 | EVP_CIPH_VARIABLE_LENGTH, | 100 | EVP_CIPH_VARIABLE_LENGTH, |
| 103 | rc4_init_key, | 101 | rc4_init_key, |
| 104 | rc4_cipher, | 102 | rc4_cipher, |
| 105 | NULL, | 103 | NULL, |
| 106 | sizeof(EVP_RC4_KEY), | 104 | sizeof(EVP_RC4_KEY), |
| 107 | NULL, | 105 | NULL, |
| 108 | NULL, | 106 | NULL, |
| 109 | NULL, | 107 | NULL, |
| 110 | NULL | 108 | NULL |
| 111 | }; | 109 | }; |
| 112 | 110 | ||
| 113 | const EVP_CIPHER *EVP_rc4(void) | 111 | const EVP_CIPHER * |
| 114 | { | 112 | EVP_rc4(void) |
| 115 | return(&r4_cipher); | 113 | { |
| 116 | } | 114 | return (&r4_cipher); |
| 115 | } | ||
| 117 | 116 | ||
| 118 | const EVP_CIPHER *EVP_rc4_40(void) | 117 | const EVP_CIPHER * |
| 119 | { | 118 | EVP_rc4_40(void) |
| 120 | return(&r4_40_cipher); | 119 | { |
| 121 | } | 120 | return (&r4_40_cipher); |
| 121 | } | ||
| 122 | 122 | ||
| 123 | static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 123 | static int |
| 124 | const unsigned char *iv, int enc) | 124 | rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 125 | { | 125 | const unsigned char *iv, int enc) |
| 126 | RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), | 126 | { |
| 127 | key); | 127 | RC4_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); |
| 128 | return 1; | 128 | return 1; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 131 | static int |
| 132 | const unsigned char *in, size_t inl) | 132 | rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 133 | { | 133 | const unsigned char *in, size_t inl) |
| 134 | RC4(&data(ctx)->ks,inl,in,out); | 134 | { |
| 135 | RC4(&data(ctx)->ks, inl, in, out); | ||
| 135 | return 1; | 136 | return 1; |
| 136 | } | 137 | } |
| 137 | #endif | 138 | #endif |
