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/s23_lib.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 '')
| -rw-r--r-- | src/lib/libssl/s23_lib.c | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/src/lib/libssl/s23_lib.c b/src/lib/libssl/s23_lib.c index e16f641101..b70002a647 100644 --- a/src/lib/libssl/s23_lib.c +++ b/src/lib/libssl/s23_lib.c | |||
| @@ -57,28 +57,18 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "objects.h" | 60 | #include <openssl/objects.h> |
| 61 | #include "ssl_locl.h" | 61 | #include "ssl_locl.h" |
| 62 | 62 | ||
| 63 | #ifndef NOPROTO | ||
| 64 | static int ssl23_num_ciphers(void ); | 63 | static int ssl23_num_ciphers(void ); |
| 65 | static SSL_CIPHER *ssl23_get_cipher(unsigned int u); | 64 | static SSL_CIPHER *ssl23_get_cipher(unsigned int u); |
| 66 | static int ssl23_read(SSL *s, char *buf, int len); | 65 | static int ssl23_read(SSL *s, void *buf, int len); |
| 67 | static int ssl23_write(SSL *s, char *buf, int len); | 66 | static int ssl23_peek(SSL *s, void *buf, int len); |
| 67 | static int ssl23_write(SSL *s, const void *buf, int len); | ||
| 68 | static long ssl23_default_timeout(void ); | 68 | static long ssl23_default_timeout(void ); |
| 69 | static int ssl23_put_cipher_by_char(SSL_CIPHER *c, unsigned char *p); | 69 | static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); |
| 70 | static SSL_CIPHER *ssl23_get_cipher_by_char(unsigned char *p); | 70 | static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p); |
| 71 | #else | 71 | const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT; |
| 72 | static int ssl23_num_ciphers(); | ||
| 73 | static SSL_CIPHER *ssl23_get_cipher(); | ||
| 74 | static int ssl23_read(); | ||
| 75 | static int ssl23_write(); | ||
| 76 | static long ssl23_default_timeout(); | ||
| 77 | static int ssl23_put_cipher_by_char(); | ||
| 78 | static SSL_CIPHER *ssl23_get_cipher_by_char(); | ||
| 79 | #endif | ||
| 80 | |||
| 81 | char *SSL23_version_str="SSLv2/3 compatablity part of SSLeay 0.7.0 30-Jan-1997"; | ||
| 82 | 72 | ||
| 83 | static SSL_METHOD SSLv23_data= { | 73 | static SSL_METHOD SSLv23_data= { |
| 84 | TLS1_VERSION, | 74 | TLS1_VERSION, |
| @@ -88,10 +78,11 @@ static SSL_METHOD SSLv23_data= { | |||
| 88 | ssl_undefined_function, | 78 | ssl_undefined_function, |
| 89 | ssl_undefined_function, | 79 | ssl_undefined_function, |
| 90 | ssl23_read, | 80 | ssl23_read, |
| 91 | ssl_undefined_function, | 81 | ssl23_peek, |
| 92 | ssl23_write, | 82 | ssl23_write, |
| 93 | ssl_undefined_function, | 83 | ssl_undefined_function, |
| 94 | ssl_undefined_function, | 84 | ssl_undefined_function, |
| 85 | ssl_ok, | ||
| 95 | ssl3_ctrl, | 86 | ssl3_ctrl, |
| 96 | ssl3_ctx_ctrl, | 87 | ssl3_ctx_ctrl, |
| 97 | ssl23_get_cipher_by_char, | 88 | ssl23_get_cipher_by_char, |
| @@ -102,38 +93,47 @@ static SSL_METHOD SSLv23_data= { | |||
| 102 | ssl_bad_method, | 93 | ssl_bad_method, |
| 103 | ssl23_default_timeout, | 94 | ssl23_default_timeout, |
| 104 | &ssl3_undef_enc_method, | 95 | &ssl3_undef_enc_method, |
| 96 | ssl_undefined_function, | ||
| 97 | ssl3_callback_ctrl, | ||
| 98 | ssl3_ctx_callback_ctrl, | ||
| 105 | }; | 99 | }; |
| 106 | 100 | ||
| 107 | static long ssl23_default_timeout() | 101 | static long ssl23_default_timeout(void) |
| 108 | { | 102 | { |
| 109 | return(300); | 103 | return(300); |
| 110 | } | 104 | } |
| 111 | 105 | ||
| 112 | SSL_METHOD *sslv23_base_method() | 106 | SSL_METHOD *sslv23_base_method(void) |
| 113 | { | 107 | { |
| 114 | return(&SSLv23_data); | 108 | return(&SSLv23_data); |
| 115 | } | 109 | } |
| 116 | 110 | ||
| 117 | static int ssl23_num_ciphers() | 111 | static int ssl23_num_ciphers(void) |
| 118 | { | 112 | { |
| 119 | return(ssl3_num_ciphers()+ssl2_num_ciphers()); | 113 | return(ssl3_num_ciphers() |
| 114 | #ifndef OPENSSL_NO_SSL2 | ||
| 115 | + ssl2_num_ciphers() | ||
| 116 | #endif | ||
| 117 | ); | ||
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | static SSL_CIPHER *ssl23_get_cipher(u) | 120 | static SSL_CIPHER *ssl23_get_cipher(unsigned int u) |
| 123 | unsigned int u; | ||
| 124 | { | 121 | { |
| 125 | unsigned int uu=ssl3_num_ciphers(); | 122 | unsigned int uu=ssl3_num_ciphers(); |
| 126 | 123 | ||
| 127 | if (u < uu) | 124 | if (u < uu) |
| 128 | return(ssl3_get_cipher(u)); | 125 | return(ssl3_get_cipher(u)); |
| 129 | else | 126 | else |
| 127 | #ifndef OPENSSL_NO_SSL2 | ||
| 130 | return(ssl2_get_cipher(u-uu)); | 128 | return(ssl2_get_cipher(u-uu)); |
| 129 | #else | ||
| 130 | return(NULL); | ||
| 131 | #endif | ||
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | /* This function needs to check if the ciphers required are actually | 134 | /* This function needs to check if the ciphers required are actually |
| 134 | * available */ | 135 | * available */ |
| 135 | static SSL_CIPHER *ssl23_get_cipher_by_char(p) | 136 | static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p) |
| 136 | unsigned char *p; | ||
| 137 | { | 137 | { |
| 138 | SSL_CIPHER c,*cp; | 138 | SSL_CIPHER c,*cp; |
| 139 | unsigned long id; | 139 | unsigned long id; |
| @@ -144,14 +144,14 @@ unsigned char *p; | |||
| 144 | ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; | 144 | ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; |
| 145 | c.id=id; | 145 | c.id=id; |
| 146 | cp=ssl3_get_cipher_by_char(p); | 146 | cp=ssl3_get_cipher_by_char(p); |
| 147 | #ifndef OPENSSL_NO_SSL2 | ||
| 147 | if (cp == NULL) | 148 | if (cp == NULL) |
| 148 | cp=ssl2_get_cipher_by_char(p); | 149 | cp=ssl2_get_cipher_by_char(p); |
| 150 | #endif | ||
| 149 | return(cp); | 151 | return(cp); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | static int ssl23_put_cipher_by_char(c,p) | 154 | static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p) |
| 153 | SSL_CIPHER *c; | ||
| 154 | unsigned char *p; | ||
| 155 | { | 155 | { |
| 156 | long l; | 156 | long l; |
| 157 | 157 | ||
| @@ -166,20 +166,10 @@ unsigned char *p; | |||
| 166 | return(3); | 166 | return(3); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | static int ssl23_read(s,buf,len) | 169 | static int ssl23_read(SSL *s, void *buf, int len) |
| 170 | SSL *s; | ||
| 171 | char *buf; | ||
| 172 | int len; | ||
| 173 | { | 170 | { |
| 174 | int n; | 171 | int n; |
| 175 | 172 | ||
| 176 | #if 0 | ||
| 177 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | ||
| 178 | { | ||
| 179 | s->rwstate=SSL_NOTHING; | ||
| 180 | return(0); | ||
| 181 | } | ||
| 182 | #endif | ||
| 183 | clear_sys_error(); | 173 | clear_sys_error(); |
| 184 | if (SSL_in_init(s) && (!s->in_handshake)) | 174 | if (SSL_in_init(s) && (!s->in_handshake)) |
| 185 | { | 175 | { |
| @@ -199,20 +189,33 @@ int len; | |||
| 199 | } | 189 | } |
| 200 | } | 190 | } |
| 201 | 191 | ||
| 202 | static int ssl23_write(s,buf,len) | 192 | static int ssl23_peek(SSL *s, void *buf, int len) |
| 203 | SSL *s; | ||
| 204 | char *buf; | ||
| 205 | int len; | ||
| 206 | { | 193 | { |
| 207 | int n; | 194 | int n; |
| 208 | 195 | ||
| 209 | #if 0 | 196 | clear_sys_error(); |
| 210 | if (s->shutdown & SSL_SENT_SHUTDOWN) | 197 | if (SSL_in_init(s) && (!s->in_handshake)) |
| 211 | { | 198 | { |
| 212 | s->rwstate=SSL_NOTHING; | 199 | n=s->handshake_func(s); |
| 213 | return(0); | 200 | if (n < 0) return(n); |
| 201 | if (n == 0) | ||
| 202 | { | ||
| 203 | SSLerr(SSL_F_SSL23_PEEK,SSL_R_SSL_HANDSHAKE_FAILURE); | ||
| 204 | return(-1); | ||
| 205 | } | ||
| 206 | return(SSL_peek(s,buf,len)); | ||
| 214 | } | 207 | } |
| 215 | #endif | 208 | else |
| 209 | { | ||
| 210 | ssl_undefined_function(s); | ||
| 211 | return(-1); | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | static int ssl23_write(SSL *s, const void *buf, int len) | ||
| 216 | { | ||
| 217 | int n; | ||
| 218 | |||
| 216 | clear_sys_error(); | 219 | clear_sys_error(); |
| 217 | if (SSL_in_init(s) && (!s->in_handshake)) | 220 | if (SSL_in_init(s) && (!s->in_handshake)) |
| 218 | { | 221 | { |
