diff options
Diffstat (limited to 'src/lib/libcrypto/evp/bio_enc.c')
-rw-r--r-- | src/lib/libcrypto/evp/bio_enc.c | 58 |
1 files changed, 18 insertions, 40 deletions
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c index 6c30ddfc54..0a7b1ecf07 100644 --- a/src/lib/libcrypto/evp/bio_enc.c +++ b/src/lib/libcrypto/evp/bio_enc.c | |||
@@ -59,10 +59,9 @@ | |||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <errno.h> | 60 | #include <errno.h> |
61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
62 | #include "buffer.h" | 62 | #include <openssl/buffer.h> |
63 | #include "evp.h" | 63 | #include <openssl/evp.h> |
64 | 64 | ||
65 | #ifndef NOPROTO | ||
66 | static int enc_write(BIO *h,char *buf,int num); | 65 | static int enc_write(BIO *h,char *buf,int num); |
67 | static int enc_read(BIO *h,char *buf,int size); | 66 | static int enc_read(BIO *h,char *buf,int size); |
68 | /*static int enc_puts(BIO *h,char *str); */ | 67 | /*static int enc_puts(BIO *h,char *str); */ |
@@ -70,16 +69,6 @@ static int enc_read(BIO *h,char *buf,int size); | |||
70 | static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 69 | static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
71 | static int enc_new(BIO *h); | 70 | static int enc_new(BIO *h); |
72 | static int enc_free(BIO *data); | 71 | static int enc_free(BIO *data); |
73 | #else | ||
74 | static int enc_write(); | ||
75 | static int enc_read(); | ||
76 | /*static int enc_puts(); */ | ||
77 | /*static int enc_gets(); */ | ||
78 | static long enc_ctrl(); | ||
79 | static int enc_new(); | ||
80 | static int enc_free(); | ||
81 | #endif | ||
82 | |||
83 | #define ENC_BLOCK_SIZE (1024*4) | 72 | #define ENC_BLOCK_SIZE (1024*4) |
84 | 73 | ||
85 | typedef struct enc_struct | 74 | typedef struct enc_struct |
@@ -105,13 +94,12 @@ static BIO_METHOD methods_enc= | |||
105 | enc_free, | 94 | enc_free, |
106 | }; | 95 | }; |
107 | 96 | ||
108 | BIO_METHOD *BIO_f_cipher() | 97 | BIO_METHOD *BIO_f_cipher(void) |
109 | { | 98 | { |
110 | return(&methods_enc); | 99 | return(&methods_enc); |
111 | } | 100 | } |
112 | 101 | ||
113 | static int enc_new(bi) | 102 | static int enc_new(BIO *bi) |
114 | BIO *bi; | ||
115 | { | 103 | { |
116 | BIO_ENC_CTX *ctx; | 104 | BIO_ENC_CTX *ctx; |
117 | 105 | ||
@@ -131,8 +119,7 @@ BIO *bi; | |||
131 | return(1); | 119 | return(1); |
132 | } | 120 | } |
133 | 121 | ||
134 | static int enc_free(a) | 122 | static int enc_free(BIO *a) |
135 | BIO *a; | ||
136 | { | 123 | { |
137 | BIO_ENC_CTX *b; | 124 | BIO_ENC_CTX *b; |
138 | 125 | ||
@@ -147,10 +134,7 @@ BIO *a; | |||
147 | return(1); | 134 | return(1); |
148 | } | 135 | } |
149 | 136 | ||
150 | static int enc_read(b,out,outl) | 137 | static int enc_read(BIO *b, char *out, int outl) |
151 | BIO *b; | ||
152 | char *out; | ||
153 | int outl; | ||
154 | { | 138 | { |
155 | int ret=0,i; | 139 | int ret=0,i; |
156 | BIO_ENC_CTX *ctx; | 140 | BIO_ENC_CTX *ctx; |
@@ -230,10 +214,7 @@ int outl; | |||
230 | return((ret == 0)?ctx->cont:ret); | 214 | return((ret == 0)?ctx->cont:ret); |
231 | } | 215 | } |
232 | 216 | ||
233 | static int enc_write(b,in,inl) | 217 | static int enc_write(BIO *b, char *in, int inl) |
234 | BIO *b; | ||
235 | char *in; | ||
236 | int inl; | ||
237 | { | 218 | { |
238 | int ret=0,n,i; | 219 | int ret=0,n,i; |
239 | BIO_ENC_CTX *ctx; | 220 | BIO_ENC_CTX *ctx; |
@@ -288,16 +269,13 @@ int inl; | |||
288 | return(ret); | 269 | return(ret); |
289 | } | 270 | } |
290 | 271 | ||
291 | static long enc_ctrl(b,cmd,num,ptr) | 272 | static long enc_ctrl(BIO *b, int cmd, long num, char *ptr) |
292 | BIO *b; | ||
293 | int cmd; | ||
294 | long num; | ||
295 | char *ptr; | ||
296 | { | 273 | { |
297 | BIO *dbio; | 274 | BIO *dbio; |
298 | BIO_ENC_CTX *ctx,*dctx; | 275 | BIO_ENC_CTX *ctx,*dctx; |
299 | long ret=1; | 276 | long ret=1; |
300 | int i; | 277 | int i; |
278 | EVP_CIPHER_CTX **c_ctx; | ||
301 | 279 | ||
302 | ctx=(BIO_ENC_CTX *)b->ptr; | 280 | ctx=(BIO_ENC_CTX *)b->ptr; |
303 | 281 | ||
@@ -364,7 +342,11 @@ again: | |||
364 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | 342 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); |
365 | BIO_copy_next_retry(b); | 343 | BIO_copy_next_retry(b); |
366 | break; | 344 | break; |
367 | 345 | case BIO_C_GET_CIPHER_CTX: | |
346 | c_ctx=(EVP_CIPHER_CTX **)ptr; | ||
347 | (*c_ctx)= &(ctx->cipher); | ||
348 | b->init=1; | ||
349 | break; | ||
368 | case BIO_CTRL_DUP: | 350 | case BIO_CTRL_DUP: |
369 | dbio=(BIO *)ptr; | 351 | dbio=(BIO *)ptr; |
370 | dctx=(BIO_ENC_CTX *)dbio->ptr; | 352 | dctx=(BIO_ENC_CTX *)dbio->ptr; |
@@ -398,19 +380,15 @@ EVP_CIPHER_ctx *c; | |||
398 | } | 380 | } |
399 | */ | 381 | */ |
400 | 382 | ||
401 | void BIO_set_cipher(b,c,k,i,e) | 383 | void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k, |
402 | BIO *b; | 384 | unsigned char *i, int e) |
403 | EVP_CIPHER *c; | ||
404 | unsigned char *k; | ||
405 | unsigned char *i; | ||
406 | int e; | ||
407 | { | 385 | { |
408 | BIO_ENC_CTX *ctx; | 386 | BIO_ENC_CTX *ctx; |
409 | 387 | ||
410 | if (b == NULL) return; | 388 | if (b == NULL) return; |
411 | 389 | ||
412 | if ((b->callback != NULL) && | 390 | if ((b->callback != NULL) && |
413 | (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0)) | 391 | (b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,0L) <= 0)) |
414 | return; | 392 | return; |
415 | 393 | ||
416 | b->init=1; | 394 | b->init=1; |
@@ -418,6 +396,6 @@ int e; | |||
418 | EVP_CipherInit(&(ctx->cipher),c,k,i,e); | 396 | EVP_CipherInit(&(ctx->cipher),c,k,i,e); |
419 | 397 | ||
420 | if (b->callback != NULL) | 398 | if (b->callback != NULL) |
421 | b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L); | 399 | b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L); |
422 | } | 400 | } |
423 | 401 | ||