diff options
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
-rw-r--r-- | src/lib/libcrypto/evp/evp_lib.c | 125 |
1 files changed, 118 insertions, 7 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c index a63ba19317..edb28ef38e 100644 --- a/src/lib/libcrypto/evp/evp_lib.c +++ b/src/lib/libcrypto/evp/evp_lib.c | |||
@@ -68,7 +68,7 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | |||
68 | if (c->cipher->set_asn1_parameters != NULL) | 68 | if (c->cipher->set_asn1_parameters != NULL) |
69 | ret=c->cipher->set_asn1_parameters(c,type); | 69 | ret=c->cipher->set_asn1_parameters(c,type); |
70 | else | 70 | else |
71 | return -1; | 71 | ret=-1; |
72 | return(ret); | 72 | return(ret); |
73 | } | 73 | } |
74 | 74 | ||
@@ -79,20 +79,21 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | |||
79 | if (c->cipher->get_asn1_parameters != NULL) | 79 | if (c->cipher->get_asn1_parameters != NULL) |
80 | ret=c->cipher->get_asn1_parameters(c,type); | 80 | ret=c->cipher->get_asn1_parameters(c,type); |
81 | else | 81 | else |
82 | return -1; | 82 | ret=-1; |
83 | return(ret); | 83 | return(ret); |
84 | } | 84 | } |
85 | 85 | ||
86 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | 86 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) |
87 | { | 87 | { |
88 | int i=0,l; | 88 | int i=0; |
89 | unsigned int l; | ||
89 | 90 | ||
90 | if (type != NULL) | 91 | if (type != NULL) |
91 | { | 92 | { |
92 | l=EVP_CIPHER_CTX_iv_length(c); | 93 | l=EVP_CIPHER_CTX_iv_length(c); |
93 | OPENSSL_assert(l <= sizeof c->iv); | 94 | OPENSSL_assert(l <= sizeof(c->iv)); |
94 | i=ASN1_TYPE_get_octetstring(type,c->oiv,l); | 95 | i=ASN1_TYPE_get_octetstring(type,c->oiv,l); |
95 | if (i != l) | 96 | if (i != (int)l) |
96 | return(-1); | 97 | return(-1); |
97 | else if (i > 0) | 98 | else if (i > 0) |
98 | memcpy(c->iv,c->oiv,l); | 99 | memcpy(c->iv,c->oiv,l); |
@@ -102,12 +103,13 @@ int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | |||
102 | 103 | ||
103 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | 104 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) |
104 | { | 105 | { |
105 | int i=0,j; | 106 | int i=0; |
107 | unsigned int j; | ||
106 | 108 | ||
107 | if (type != NULL) | 109 | if (type != NULL) |
108 | { | 110 | { |
109 | j=EVP_CIPHER_CTX_iv_length(c); | 111 | j=EVP_CIPHER_CTX_iv_length(c); |
110 | OPENSSL_assert(j <= sizeof c->iv); | 112 | OPENSSL_assert(j <= sizeof(c->iv)); |
111 | i=ASN1_TYPE_set_octetstring(type,c->oiv,j); | 113 | i=ASN1_TYPE_set_octetstring(type,c->oiv,j); |
112 | } | 114 | } |
113 | return(i); | 115 | return(i); |
@@ -166,3 +168,112 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx) | |||
166 | } | 168 | } |
167 | } | 169 | } |
168 | 170 | ||
171 | int EVP_CIPHER_block_size(const EVP_CIPHER *e) | ||
172 | { | ||
173 | return e->block_size; | ||
174 | } | ||
175 | |||
176 | int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) | ||
177 | { | ||
178 | return ctx->cipher->block_size; | ||
179 | } | ||
180 | |||
181 | int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) | ||
182 | { | ||
183 | return ctx->cipher->do_cipher(ctx,out,in,inl); | ||
184 | } | ||
185 | |||
186 | const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) | ||
187 | { | ||
188 | return ctx->cipher; | ||
189 | } | ||
190 | |||
191 | unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher) | ||
192 | { | ||
193 | return cipher->flags; | ||
194 | } | ||
195 | |||
196 | unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx) | ||
197 | { | ||
198 | return ctx->cipher->flags; | ||
199 | } | ||
200 | |||
201 | void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) | ||
202 | { | ||
203 | return ctx->app_data; | ||
204 | } | ||
205 | |||
206 | void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data) | ||
207 | { | ||
208 | ctx->app_data = data; | ||
209 | } | ||
210 | |||
211 | int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) | ||
212 | { | ||
213 | return cipher->iv_len; | ||
214 | } | ||
215 | |||
216 | int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx) | ||
217 | { | ||
218 | return ctx->cipher->iv_len; | ||
219 | } | ||
220 | |||
221 | int EVP_CIPHER_key_length(const EVP_CIPHER *cipher) | ||
222 | { | ||
223 | return cipher->key_len; | ||
224 | } | ||
225 | |||
226 | int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx) | ||
227 | { | ||
228 | return ctx->key_len; | ||
229 | } | ||
230 | |||
231 | int EVP_CIPHER_nid(const EVP_CIPHER *cipher) | ||
232 | { | ||
233 | return cipher->nid; | ||
234 | } | ||
235 | |||
236 | int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) | ||
237 | { | ||
238 | return ctx->cipher->nid; | ||
239 | } | ||
240 | |||
241 | int EVP_MD_block_size(const EVP_MD *md) | ||
242 | { | ||
243 | return md->block_size; | ||
244 | } | ||
245 | |||
246 | int EVP_MD_type(const EVP_MD *md) | ||
247 | { | ||
248 | return md->type; | ||
249 | } | ||
250 | |||
251 | int EVP_MD_pkey_type(const EVP_MD *md) | ||
252 | { | ||
253 | return md->pkey_type; | ||
254 | } | ||
255 | |||
256 | int EVP_MD_size(const EVP_MD *md) | ||
257 | { | ||
258 | return md->md_size; | ||
259 | } | ||
260 | |||
261 | const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx) | ||
262 | { | ||
263 | return ctx->digest; | ||
264 | } | ||
265 | |||
266 | void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags) | ||
267 | { | ||
268 | ctx->flags |= flags; | ||
269 | } | ||
270 | |||
271 | void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags) | ||
272 | { | ||
273 | ctx->flags &= ~flags; | ||
274 | } | ||
275 | |||
276 | int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags) | ||
277 | { | ||
278 | return (ctx->flags & flags); | ||
279 | } | ||