summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s23_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/s23_lib.c')
-rw-r--r--src/lib/libssl/s23_lib.c101
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
64static int ssl23_num_ciphers(void ); 63static int ssl23_num_ciphers(void );
65static SSL_CIPHER *ssl23_get_cipher(unsigned int u); 64static SSL_CIPHER *ssl23_get_cipher(unsigned int u);
66static int ssl23_read(SSL *s, char *buf, int len); 65static int ssl23_read(SSL *s, void *buf, int len);
67static int ssl23_write(SSL *s, char *buf, int len); 66static int ssl23_peek(SSL *s, void *buf, int len);
67static int ssl23_write(SSL *s, const void *buf, int len);
68static long ssl23_default_timeout(void ); 68static long ssl23_default_timeout(void );
69static int ssl23_put_cipher_by_char(SSL_CIPHER *c, unsigned char *p); 69static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
70static SSL_CIPHER *ssl23_get_cipher_by_char(unsigned char *p); 70static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p);
71#else 71const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT;
72static int ssl23_num_ciphers();
73static SSL_CIPHER *ssl23_get_cipher();
74static int ssl23_read();
75static int ssl23_write();
76static long ssl23_default_timeout();
77static int ssl23_put_cipher_by_char();
78static SSL_CIPHER *ssl23_get_cipher_by_char();
79#endif
80
81char *SSL23_version_str="SSLv2/3 compatablity part of SSLeay 0.7.0 30-Jan-1997";
82 72
83static SSL_METHOD SSLv23_data= { 73static 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
107static long ssl23_default_timeout() 101static long ssl23_default_timeout(void)
108 { 102 {
109 return(300); 103 return(300);
110 } 104 }
111 105
112SSL_METHOD *sslv23_base_method() 106SSL_METHOD *sslv23_base_method(void)
113 { 107 {
114 return(&SSLv23_data); 108 return(&SSLv23_data);
115 } 109 }
116 110
117static int ssl23_num_ciphers() 111static 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
122static SSL_CIPHER *ssl23_get_cipher(u) 120static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
123unsigned 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 */
135static SSL_CIPHER *ssl23_get_cipher_by_char(p) 136static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p)
136unsigned 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
152static int ssl23_put_cipher_by_char(c,p) 154static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
153SSL_CIPHER *c;
154unsigned 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
169static int ssl23_read(s,buf,len) 169static int ssl23_read(SSL *s, void *buf, int len)
170SSL *s;
171char *buf;
172int 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
202static int ssl23_write(s,buf,len) 192static int ssl23_peek(SSL *s, void *buf, int len)
203SSL *s;
204char *buf;
205int 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
215static 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 {