diff options
Diffstat (limited to 'src/lib/libcrypto/evp/e_rc5.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_rc5.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/lib/libcrypto/evp/e_rc5.c b/src/lib/libcrypto/evp/e_rc5.c index 19a10c6402..efbd03735e 100644 --- a/src/lib/libcrypto/evp/e_rc5.c +++ b/src/lib/libcrypto/evp/e_rc5.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 |
@@ -67,27 +67,26 @@ | |||
67 | #include <openssl/rc5.h> | 67 | #include <openssl/rc5.h> |
68 | 68 | ||
69 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 69 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
70 | const unsigned char *iv,int enc); | 70 | const unsigned char *iv, int enc); |
71 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); | 71 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); |
72 | 72 | ||
73 | typedef struct | 73 | typedef struct { |
74 | { | ||
75 | int rounds; /* number of rounds */ | 74 | int rounds; /* number of rounds */ |
76 | RC5_32_KEY ks; /* key schedule */ | 75 | RC5_32_KEY ks; /* key schedule */ |
77 | } EVP_RC5_KEY; | 76 | } EVP_RC5_KEY; |
78 | 77 | ||
79 | #define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx) | 78 | #define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx) |
80 | 79 | ||
81 | IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5, | 80 | IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5, |
82 | 8, RC5_32_KEY_LENGTH, 8, 64, | 81 | 8, RC5_32_KEY_LENGTH, 8, 64, |
83 | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | 82 | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, |
84 | r_32_12_16_init_key, NULL, | 83 | r_32_12_16_init_key, NULL, |
85 | NULL, NULL, rc5_ctrl) | 84 | NULL, NULL, rc5_ctrl) |
86 | 85 | ||
87 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | 86 | static int |
88 | { | 87 | rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) |
89 | switch(type) | 88 | { |
90 | { | 89 | switch (type) { |
91 | case EVP_CTRL_INIT: | 90 | case EVP_CTRL_INIT: |
92 | data(c)->rounds = RC5_12_ROUNDS; | 91 | data(c)->rounds = RC5_12_ROUNDS; |
93 | return 1; | 92 | return 1; |
@@ -95,10 +94,9 @@ static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | |||
95 | case EVP_CTRL_GET_RC5_ROUNDS: | 94 | case EVP_CTRL_GET_RC5_ROUNDS: |
96 | *(int *)ptr = data(c)->rounds; | 95 | *(int *)ptr = data(c)->rounds; |
97 | return 1; | 96 | return 1; |
98 | 97 | ||
99 | case EVP_CTRL_SET_RC5_ROUNDS: | 98 | case EVP_CTRL_SET_RC5_ROUNDS: |
100 | switch(arg) | 99 | switch (arg) { |
101 | { | ||
102 | case RC5_8_ROUNDS: | 100 | case RC5_8_ROUNDS: |
103 | case RC5_12_ROUNDS: | 101 | case RC5_12_ROUNDS: |
104 | case RC5_16_ROUNDS: | 102 | case RC5_16_ROUNDS: |
@@ -106,21 +104,23 @@ static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | |||
106 | return 1; | 104 | return 1; |
107 | 105 | ||
108 | default: | 106 | default: |
109 | EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS); | 107 | EVPerr(EVP_F_RC5_CTRL, |
108 | EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS); | ||
110 | return 0; | 109 | return 0; |
111 | } | 110 | } |
112 | 111 | ||
113 | default: | 112 | default: |
114 | return -1; | 113 | return -1; |
115 | } | ||
116 | } | 114 | } |
115 | } | ||
117 | 116 | ||
118 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 117 | static int |
119 | const unsigned char *iv, int enc) | 118 | r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
120 | { | 119 | const unsigned char *iv, int enc) |
121 | RC5_32_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), | 120 | { |
122 | key,data(ctx)->rounds); | 121 | RC5_32_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key, |
122 | data(ctx)->rounds); | ||
123 | return 1; | 123 | return 1; |
124 | } | 124 | } |
125 | 125 | ||
126 | #endif | 126 | #endif |