diff options
author | markus <> | 2002-09-05 12:51:50 +0000 |
---|---|---|
committer | markus <> | 2002-09-05 12:51:50 +0000 |
commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libssl/bio_ssl.c | |
parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libssl/bio_ssl.c')
-rw-r--r-- | src/lib/libssl/bio_ssl.c | 115 |
1 files changed, 61 insertions, 54 deletions
diff --git a/src/lib/libssl/bio_ssl.c b/src/lib/libssl/bio_ssl.c index 58a6d69b9b..467e149947 100644 --- a/src/lib/libssl/bio_ssl.c +++ b/src/lib/libssl/bio_ssl.c | |||
@@ -60,27 +60,18 @@ | |||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #include "crypto.h" | 63 | #include <openssl/crypto.h> |
64 | #include "bio.h" | 64 | #include <openssl/bio.h> |
65 | #include "err.h" | 65 | #include <openssl/err.h> |
66 | #include "ssl.h" | 66 | #include <openssl/ssl.h> |
67 | 67 | ||
68 | #ifndef NOPROTO | 68 | static int ssl_write(BIO *h, const char *buf, int num); |
69 | static int ssl_write(BIO *h,char *buf,int num); | 69 | static int ssl_read(BIO *h, char *buf, int size); |
70 | static int ssl_read(BIO *h,char *buf,int size); | 70 | static int ssl_puts(BIO *h, const char *str); |
71 | static int ssl_puts(BIO *h,char *str); | 71 | static long ssl_ctrl(BIO *h, int cmd, long arg1, void *arg2); |
72 | static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2); | ||
73 | static int ssl_new(BIO *h); | 72 | static int ssl_new(BIO *h); |
74 | static int ssl_free(BIO *data); | 73 | static int ssl_free(BIO *data); |
75 | #else | 74 | static long ssl_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); |
76 | static int ssl_write(); | ||
77 | static int ssl_read(); | ||
78 | static int ssl_puts(); | ||
79 | static long ssl_ctrl(); | ||
80 | static int ssl_new(); | ||
81 | static int ssl_free(); | ||
82 | #endif | ||
83 | |||
84 | typedef struct bio_ssl_st | 75 | typedef struct bio_ssl_st |
85 | { | 76 | { |
86 | SSL *ssl; /* The ssl handle :-) */ | 77 | SSL *ssl; /* The ssl handle :-) */ |
@@ -102,19 +93,19 @@ static BIO_METHOD methods_sslp= | |||
102 | ssl_ctrl, | 93 | ssl_ctrl, |
103 | ssl_new, | 94 | ssl_new, |
104 | ssl_free, | 95 | ssl_free, |
96 | ssl_callback_ctrl, | ||
105 | }; | 97 | }; |
106 | 98 | ||
107 | BIO_METHOD *BIO_f_ssl() | 99 | BIO_METHOD *BIO_f_ssl(void) |
108 | { | 100 | { |
109 | return(&methods_sslp); | 101 | return(&methods_sslp); |
110 | } | 102 | } |
111 | 103 | ||
112 | static int ssl_new(bi) | 104 | static int ssl_new(BIO *bi) |
113 | BIO *bi; | ||
114 | { | 105 | { |
115 | BIO_SSL *bs; | 106 | BIO_SSL *bs; |
116 | 107 | ||
117 | bs=(BIO_SSL *)Malloc(sizeof(BIO_SSL)); | 108 | bs=(BIO_SSL *)OPENSSL_malloc(sizeof(BIO_SSL)); |
118 | if (bs == NULL) | 109 | if (bs == NULL) |
119 | { | 110 | { |
120 | BIOerr(BIO_F_SSL_NEW,ERR_R_MALLOC_FAILURE); | 111 | BIOerr(BIO_F_SSL_NEW,ERR_R_MALLOC_FAILURE); |
@@ -127,8 +118,7 @@ BIO *bi; | |||
127 | return(1); | 118 | return(1); |
128 | } | 119 | } |
129 | 120 | ||
130 | static int ssl_free(a) | 121 | static int ssl_free(BIO *a) |
131 | BIO *a; | ||
132 | { | 122 | { |
133 | BIO_SSL *bs; | 123 | BIO_SSL *bs; |
134 | 124 | ||
@@ -143,14 +133,11 @@ BIO *a; | |||
143 | a->flags=0; | 133 | a->flags=0; |
144 | } | 134 | } |
145 | if (a->ptr != NULL) | 135 | if (a->ptr != NULL) |
146 | Free(a->ptr); | 136 | OPENSSL_free(a->ptr); |
147 | return(1); | 137 | return(1); |
148 | } | 138 | } |
149 | 139 | ||
150 | static int ssl_read(b,out,outl) | 140 | static int ssl_read(BIO *b, char *out, int outl) |
151 | BIO *b; | ||
152 | char *out; | ||
153 | int outl; | ||
154 | { | 141 | { |
155 | int ret=1; | 142 | int ret=1; |
156 | BIO_SSL *sb; | 143 | BIO_SSL *sb; |
@@ -219,6 +206,10 @@ int outl; | |||
219 | BIO_set_retry_special(b); | 206 | BIO_set_retry_special(b); |
220 | retry_reason=BIO_RR_SSL_X509_LOOKUP; | 207 | retry_reason=BIO_RR_SSL_X509_LOOKUP; |
221 | break; | 208 | break; |
209 | case SSL_ERROR_WANT_ACCEPT: | ||
210 | BIO_set_retry_special(b); | ||
211 | retry_reason=BIO_RR_ACCEPT; | ||
212 | break; | ||
222 | case SSL_ERROR_WANT_CONNECT: | 213 | case SSL_ERROR_WANT_CONNECT: |
223 | BIO_set_retry_special(b); | 214 | BIO_set_retry_special(b); |
224 | retry_reason=BIO_RR_CONNECT; | 215 | retry_reason=BIO_RR_CONNECT; |
@@ -234,10 +225,7 @@ int outl; | |||
234 | return(ret); | 225 | return(ret); |
235 | } | 226 | } |
236 | 227 | ||
237 | static int ssl_write(b,out,outl) | 228 | static int ssl_write(BIO *b, const char *out, int outl) |
238 | BIO *b; | ||
239 | char *out; | ||
240 | int outl; | ||
241 | { | 229 | { |
242 | int ret,r=0; | 230 | int ret,r=0; |
243 | int retry_reason=0; | 231 | int retry_reason=0; |
@@ -305,11 +293,7 @@ int outl; | |||
305 | return(ret); | 293 | return(ret); |
306 | } | 294 | } |
307 | 295 | ||
308 | static long ssl_ctrl(b,cmd,num,ptr) | 296 | static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) |
309 | BIO *b; | ||
310 | int cmd; | ||
311 | long num; | ||
312 | char *ptr; | ||
313 | { | 297 | { |
314 | SSL **sslp,*ssl; | 298 | SSL **sslp,*ssl; |
315 | BIO_SSL *bs; | 299 | BIO_SSL *bs; |
@@ -466,7 +450,14 @@ char *ptr; | |||
466 | ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); | 450 | ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); |
467 | break; | 451 | break; |
468 | case BIO_CTRL_SET_CALLBACK: | 452 | case BIO_CTRL_SET_CALLBACK: |
469 | SSL_set_info_callback(ssl,(void (*)())ptr); | 453 | { |
454 | #if 0 /* FIXME: Should this be used? -- Richard Levitte */ | ||
455 | BIOerr(SSL_F_SSL_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
456 | ret = -1; | ||
457 | #else | ||
458 | ret=0; | ||
459 | #endif | ||
460 | } | ||
470 | break; | 461 | break; |
471 | case BIO_CTRL_GET_CALLBACK: | 462 | case BIO_CTRL_GET_CALLBACK: |
472 | { | 463 | { |
@@ -483,9 +474,31 @@ char *ptr; | |||
483 | return(ret); | 474 | return(ret); |
484 | } | 475 | } |
485 | 476 | ||
486 | static int ssl_puts(bp,str) | 477 | static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) |
487 | BIO *bp; | 478 | { |
488 | char *str; | 479 | SSL *ssl; |
480 | BIO_SSL *bs; | ||
481 | long ret=1; | ||
482 | |||
483 | bs=(BIO_SSL *)b->ptr; | ||
484 | ssl=bs->ssl; | ||
485 | switch (cmd) | ||
486 | { | ||
487 | case BIO_CTRL_SET_CALLBACK: | ||
488 | { | ||
489 | /* FIXME: setting this via a completely different prototype | ||
490 | seems like a crap idea */ | ||
491 | SSL_set_info_callback(ssl,(void (*)(const SSL *,int,int))fp); | ||
492 | } | ||
493 | break; | ||
494 | default: | ||
495 | ret=BIO_callback_ctrl(ssl->rbio,cmd,fp); | ||
496 | break; | ||
497 | } | ||
498 | return(ret); | ||
499 | } | ||
500 | |||
501 | static int ssl_puts(BIO *bp, const char *str) | ||
489 | { | 502 | { |
490 | int n,ret; | 503 | int n,ret; |
491 | 504 | ||
@@ -494,8 +507,7 @@ char *str; | |||
494 | return(ret); | 507 | return(ret); |
495 | } | 508 | } |
496 | 509 | ||
497 | BIO *BIO_new_buffer_ssl_connect(ctx) | 510 | BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) |
498 | SSL_CTX *ctx; | ||
499 | { | 511 | { |
500 | BIO *ret=NULL,*buf=NULL,*ssl=NULL; | 512 | BIO *ret=NULL,*buf=NULL,*ssl=NULL; |
501 | 513 | ||
@@ -512,8 +524,7 @@ err: | |||
512 | return(NULL); | 524 | return(NULL); |
513 | } | 525 | } |
514 | 526 | ||
515 | BIO *BIO_new_ssl_connect(ctx) | 527 | BIO *BIO_new_ssl_connect(SSL_CTX *ctx) |
516 | SSL_CTX *ctx; | ||
517 | { | 528 | { |
518 | BIO *ret=NULL,*con=NULL,*ssl=NULL; | 529 | BIO *ret=NULL,*con=NULL,*ssl=NULL; |
519 | 530 | ||
@@ -530,9 +541,7 @@ err: | |||
530 | return(NULL); | 541 | return(NULL); |
531 | } | 542 | } |
532 | 543 | ||
533 | BIO *BIO_new_ssl(ctx,client) | 544 | BIO *BIO_new_ssl(SSL_CTX *ctx, int client) |
534 | SSL_CTX *ctx; | ||
535 | int client; | ||
536 | { | 545 | { |
537 | BIO *ret; | 546 | BIO *ret; |
538 | SSL *ssl; | 547 | SSL *ssl; |
@@ -553,8 +562,7 @@ int client; | |||
553 | return(ret); | 562 | return(ret); |
554 | } | 563 | } |
555 | 564 | ||
556 | int BIO_ssl_copy_session_id(t,f) | 565 | int BIO_ssl_copy_session_id(BIO *t, BIO *f) |
557 | BIO *t,*f; | ||
558 | { | 566 | { |
559 | t=BIO_find_type(t,BIO_TYPE_SSL); | 567 | t=BIO_find_type(t,BIO_TYPE_SSL); |
560 | f=BIO_find_type(f,BIO_TYPE_SSL); | 568 | f=BIO_find_type(f,BIO_TYPE_SSL); |
@@ -567,8 +575,7 @@ BIO *t,*f; | |||
567 | return(1); | 575 | return(1); |
568 | } | 576 | } |
569 | 577 | ||
570 | void BIO_ssl_shutdown(b) | 578 | void BIO_ssl_shutdown(BIO *b) |
571 | BIO *b; | ||
572 | { | 579 | { |
573 | SSL *s; | 580 | SSL *s; |
574 | 581 | ||