summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/bio_enc.c
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/evp/bio_enc.c
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/evp/bio_enc.c')
-rw-r--r--src/lib/libcrypto/evp/bio_enc.c58
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
66static int enc_write(BIO *h,char *buf,int num); 65static int enc_write(BIO *h,char *buf,int num);
67static int enc_read(BIO *h,char *buf,int size); 66static 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);
70static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); 69static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2);
71static int enc_new(BIO *h); 70static int enc_new(BIO *h);
72static int enc_free(BIO *data); 71static int enc_free(BIO *data);
73#else
74static int enc_write();
75static int enc_read();
76/*static int enc_puts(); */
77/*static int enc_gets(); */
78static long enc_ctrl();
79static int enc_new();
80static int enc_free();
81#endif
82
83#define ENC_BLOCK_SIZE (1024*4) 72#define ENC_BLOCK_SIZE (1024*4)
84 73
85typedef struct enc_struct 74typedef struct enc_struct
@@ -105,13 +94,12 @@ static BIO_METHOD methods_enc=
105 enc_free, 94 enc_free,
106 }; 95 };
107 96
108BIO_METHOD *BIO_f_cipher() 97BIO_METHOD *BIO_f_cipher(void)
109 { 98 {
110 return(&methods_enc); 99 return(&methods_enc);
111 } 100 }
112 101
113static int enc_new(bi) 102static int enc_new(BIO *bi)
114BIO *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
134static int enc_free(a) 122static int enc_free(BIO *a)
135BIO *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
150static int enc_read(b,out,outl) 137static int enc_read(BIO *b, char *out, int outl)
151BIO *b;
152char *out;
153int 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
233static int enc_write(b,in,inl) 217static int enc_write(BIO *b, char *in, int inl)
234BIO *b;
235char *in;
236int 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
291static long enc_ctrl(b,cmd,num,ptr) 272static long enc_ctrl(BIO *b, int cmd, long num, char *ptr)
292BIO *b;
293int cmd;
294long num;
295char *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
401void BIO_set_cipher(b,c,k,i,e) 383void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k,
402BIO *b; 384 unsigned char *i, int e)
403EVP_CIPHER *c;
404unsigned char *k;
405unsigned char *i;
406int 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