diff options
author | beck <> | 2000-03-19 11:13:58 +0000 |
---|---|---|
committer | beck <> | 2000-03-19 11:13:58 +0000 |
commit | 796d609550df3a33fc11468741c5d2f6d3df4c11 (patch) | |
tree | 6c6d539061caa20372dad0ac4ddb1dfae2fbe7fe /src/lib/libcrypto/bio/bio_lib.c | |
parent | 5be3114c1fd7e0dfea1e38d3abb4cbba75244419 (diff) | |
download | openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.gz openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.bz2 openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.zip |
OpenSSL 0.9.5 merge
*warning* this bumps shared lib minors for libssl and libcrypto from 2.1 to 2.2
if you are using the ssl26 packages for ssh and other things to work you will
need to get new ones (see ~beck/libsslsnap/<arch>) on cvs or ~beck/src-patent.tar.gz on cvs
Diffstat (limited to 'src/lib/libcrypto/bio/bio_lib.c')
-rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index b72688ea90..cf8e6150fd 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
@@ -63,7 +63,7 @@ | |||
63 | #include <openssl/bio.h> | 63 | #include <openssl/bio.h> |
64 | #include <openssl/stack.h> | 64 | #include <openssl/stack.h> |
65 | 65 | ||
66 | static STACK *bio_meth=NULL; | 66 | static STACK_OF(CRYPTO_EX_DATA_FUNCS) *bio_meth=NULL; |
67 | static int bio_meth_num=0; | 67 | static int bio_meth_num=0; |
68 | 68 | ||
69 | BIO *BIO_new(BIO_METHOD *method) | 69 | BIO *BIO_new(BIO_METHOD *method) |
@@ -100,7 +100,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method) | |||
100 | bio->references=1; | 100 | bio->references=1; |
101 | bio->num_read=0L; | 101 | bio->num_read=0L; |
102 | bio->num_write=0L; | 102 | bio->num_write=0L; |
103 | CRYPTO_new_ex_data(bio_meth,(char *)bio,&bio->ex_data); | 103 | CRYPTO_new_ex_data(bio_meth,bio,&bio->ex_data); |
104 | if (method->create != NULL) | 104 | if (method->create != NULL) |
105 | if (!method->create(bio)) | 105 | if (!method->create(bio)) |
106 | return(0); | 106 | return(0); |
@@ -129,7 +129,7 @@ int BIO_free(BIO *a) | |||
129 | ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) | 129 | ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) |
130 | return(i); | 130 | return(i); |
131 | 131 | ||
132 | CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); | 132 | CRYPTO_free_ex_data(bio_meth,a,&a->ex_data); |
133 | 133 | ||
134 | if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); | 134 | if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); |
135 | ret=a->method->destroy(a); | 135 | ret=a->method->destroy(a); |
@@ -317,16 +317,43 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) | |||
317 | return(ret); | 317 | return(ret); |
318 | } | 318 | } |
319 | 319 | ||
320 | long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)()) | ||
321 | { | ||
322 | long ret; | ||
323 | long (*cb)(); | ||
324 | |||
325 | if (b == NULL) return(0); | ||
326 | |||
327 | if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) | ||
328 | { | ||
329 | BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD); | ||
330 | return(-2); | ||
331 | } | ||
332 | |||
333 | cb=b->callback; | ||
334 | |||
335 | if ((cb != NULL) && | ||
336 | ((ret=cb(b,BIO_CB_CTRL,(void *)&fp,cmd,0,1L)) <= 0)) | ||
337 | return(ret); | ||
338 | |||
339 | ret=b->method->callback_ctrl(b,cmd,fp); | ||
340 | |||
341 | if (cb != NULL) | ||
342 | ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,(void *)&fp,cmd, | ||
343 | 0,ret); | ||
344 | return(ret); | ||
345 | } | ||
346 | |||
320 | /* It is unfortunate to duplicate in functions what the BIO_(w)pending macros | 347 | /* It is unfortunate to duplicate in functions what the BIO_(w)pending macros |
321 | * do; but those macros have inappropriate return type, and for interfacing | 348 | * do; but those macros have inappropriate return type, and for interfacing |
322 | * from other programming languages, C macros aren't much of a help anyway. */ | 349 | * from other programming languages, C macros aren't much of a help anyway. */ |
323 | size_t BIO_ctrl_pending(BIO *bio) | 350 | size_t BIO_ctrl_pending(BIO *bio) |
324 | { | 351 | { |
325 | return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); | 352 | return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); |
326 | } | 353 | } |
327 | 354 | ||
328 | size_t BIO_ctrl_wpending(BIO *bio) | 355 | size_t BIO_ctrl_wpending(BIO *bio) |
329 | { | 356 | { |
330 | return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); | 357 | return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); |
331 | } | 358 | } |
332 | 359 | ||
@@ -476,21 +503,32 @@ void BIO_copy_next_retry(BIO *b) | |||
476 | b->retry_reason=b->next_bio->retry_reason; | 503 | b->retry_reason=b->next_bio->retry_reason; |
477 | } | 504 | } |
478 | 505 | ||
479 | int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | 506 | int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
480 | int (*dup_func)(), void (*free_func)()) | 507 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
481 | { | 508 | { |
482 | bio_meth_num++; | 509 | bio_meth_num++; |
483 | return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, | 510 | return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, |
484 | argl,argp,new_func,dup_func,free_func)); | 511 | argl,argp,new_func,dup_func,free_func)); |
485 | } | 512 | } |
486 | 513 | ||
487 | int BIO_set_ex_data(BIO *bio, int idx, char *data) | 514 | int BIO_set_ex_data(BIO *bio, int idx, void *data) |
488 | { | 515 | { |
489 | return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); | 516 | return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); |
490 | } | 517 | } |
491 | 518 | ||
492 | char *BIO_get_ex_data(BIO *bio, int idx) | 519 | void *BIO_get_ex_data(BIO *bio, int idx) |
493 | { | 520 | { |
494 | return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); | 521 | return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); |
495 | } | 522 | } |
496 | 523 | ||
524 | unsigned long BIO_number_read(BIO *bio) | ||
525 | { | ||
526 | if(bio) return bio->num_read; | ||
527 | return 0; | ||
528 | } | ||
529 | |||
530 | unsigned long BIO_number_written(BIO *bio) | ||
531 | { | ||
532 | if(bio) return bio->num_write; | ||
533 | return 0; | ||
534 | } | ||