OLD | NEW |
1 /* crypto/evp/e_rc4.c */ | 1 /* crypto/evp/e_rc4.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 */ | 57 */ |
58 | 58 |
59 #include <stdio.h> | 59 #include <stdio.h> |
60 #include "cryptlib.h" | 60 #include "cryptlib.h" |
61 | 61 |
62 #ifndef OPENSSL_NO_RC4 | 62 #ifndef OPENSSL_NO_RC4 |
63 | 63 |
64 #include <openssl/evp.h> | 64 #include <openssl/evp.h> |
65 #include <openssl/objects.h> | 65 #include <openssl/objects.h> |
66 #include <openssl/rc4.h> | 66 #include <openssl/rc4.h> |
67 #include "evp_locl.h" | |
68 | 67 |
69 /* FIXME: surely this is available elsewhere? */ | 68 /* FIXME: surely this is available elsewhere? */ |
70 #define EVP_RC4_KEY_SIZE 16 | 69 #define EVP_RC4_KEY_SIZE 16 |
71 | 70 |
72 typedef struct | 71 typedef struct |
73 { | 72 { |
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, unsigned int inl); | 81 » » const unsigned char *in, size_t inl); |
83 static const EVP_CIPHER r4_cipher= | 82 static const EVP_CIPHER r4_cipher= |
84 { | 83 { |
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, |
90 NULL, | 89 NULL, |
91 sizeof(EVP_RC4_KEY), | 90 sizeof(EVP_RC4_KEY), |
92 NULL, | 91 NULL, |
(...skipping 29 matching lines...) Expand all Loading... |
122 | 121 |
123 static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 122 static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
124 const unsigned char *iv, int enc) | 123 const unsigned char *iv, int enc) |
125 { | 124 { |
126 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), | 125 RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), |
127 key); | 126 key); |
128 return 1; | 127 return 1; |
129 } | 128 } |
130 | 129 |
131 static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 130 static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, |
132 » » const unsigned char *in, unsigned int inl) | 131 » » const unsigned char *in, size_t inl) |
133 { | 132 { |
134 RC4(&data(ctx)->ks,inl,in,out); | 133 RC4(&data(ctx)->ks,inl,in,out); |
135 return 1; | 134 return 1; |
136 } | 135 } |
137 #endif | 136 #endif |
OLD | NEW |