OLD | NEW |
1 /* crypto/cast/c_skey.c */ | 1 /* crypto/cast/c_skey.c */ |
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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
56 * [including the GNU Public Licence.] | 56 * [including the GNU Public Licence.] |
57 */ | 57 */ |
58 | 58 |
59 #include <openssl/cast.h> | 59 #include <openssl/cast.h> |
60 #include <openssl/crypto.h> | |
61 #ifdef OPENSSL_FIPS | |
62 #include <openssl/fips.h> | |
63 #endif | |
64 | |
65 #include "cast_lcl.h" | 60 #include "cast_lcl.h" |
66 #include "cast_s.h" | 61 #include "cast_s.h" |
67 | 62 |
68 #define CAST_exp(l,A,a,n) \ | 63 #define CAST_exp(l,A,a,n) \ |
69 A[n/4]=l; \ | 64 A[n/4]=l; \ |
70 a[n+3]=(l )&0xff; \ | 65 a[n+3]=(l )&0xff; \ |
71 a[n+2]=(l>> 8)&0xff; \ | 66 a[n+2]=(l>> 8)&0xff; \ |
72 a[n+1]=(l>>16)&0xff; \ | 67 a[n+1]=(l>>16)&0xff; \ |
73 a[n+0]=(l>>24)&0xff; | 68 a[n+0]=(l>>24)&0xff; |
74 | 69 |
75 #define S4 CAST_S_table4 | 70 #define S4 CAST_S_table4 |
76 #define S5 CAST_S_table5 | 71 #define S5 CAST_S_table5 |
77 #define S6 CAST_S_table6 | 72 #define S6 CAST_S_table6 |
78 #define S7 CAST_S_table7 | 73 #define S7 CAST_S_table7 |
79 | 74 |
80 FIPS_NON_FIPS_VCIPHER_Init(CAST) | 75 void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data) |
81 { | 76 { |
82 CAST_LONG x[16]; | 77 CAST_LONG x[16]; |
83 CAST_LONG z[16]; | 78 CAST_LONG z[16]; |
84 CAST_LONG k[32]; | 79 CAST_LONG k[32]; |
85 CAST_LONG X[4],Z[4]; | 80 CAST_LONG X[4],Z[4]; |
86 CAST_LONG l,*K; | 81 CAST_LONG l,*K; |
87 int i; | 82 int i; |
88 | 83 |
89 for (i=0; i<16; i++) x[i]=0; | 84 for (i=0; i<16; i++) x[i]=0; |
90 if (len > 16) len=16; | 85 if (len > 16) len=16; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 K+=16; | 157 K+=16; |
163 } | 158 } |
164 | 159 |
165 for (i=0; i<16; i++) | 160 for (i=0; i<16; i++) |
166 { | 161 { |
167 key->data[i*2]=k[i]; | 162 key->data[i*2]=k[i]; |
168 key->data[i*2+1]=((k[i+16])+16)&0x1f; | 163 key->data[i*2+1]=((k[i+16])+16)&0x1f; |
169 } | 164 } |
170 } | 165 } |
171 | 166 |
OLD | NEW |