Fix Bleichenbacher PKCS #1 1.5 countermeasure.
[oweals/openssl.git] / ssl / ssl_lib.c
index 24f314e5b93f3302cd1f053a8651df62748ec523..1fe85b6cb7560ac209381f11641bb55b9ac73ecf 100644 (file)
@@ -191,10 +191,6 @@ SSL *SSL_new(SSL_CTX *ctx)
        if (s == NULL) goto err;
        memset(s,0,sizeof(SSL));
 
-#ifndef        NO_KRB5
-       s->kssl_ctx = kssl_ctx_new();
-#endif /* NO_KRB5 */
-
        if (ctx->cert != NULL)
                {
                /* Earlier library versions used to copy the pointer to
@@ -580,13 +576,6 @@ int SSL_get_read_ahead(SSL *s)
 
 int SSL_pending(SSL *s)
        {
-       /* SSL_pending cannot work properly if read-ahead is enabled
-        * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)),
-        * and it is impossible to fix since SSL_pending cannot report
-        * errors that may be observed while scanning the new data.
-        * (Note that SSL_pending() is often used as a boolean value,
-        * so we'd better not return -1.)
-        */
        return(s->method->ssl_pending(s));
        }
 
@@ -719,7 +708,7 @@ long SSL_get_default_timeout(SSL *s)
        return(s->method->get_timeout());
        }
 
-int SSL_read(SSL *s,char *buf,int num)
+int SSL_read(SSL *s,void *buf,int num)
        {
        if (s->handshake_func == 0)
                {
@@ -735,8 +724,14 @@ int SSL_read(SSL *s,char *buf,int num)
        return(s->method->ssl_read(s,buf,num));
        }
 
-int SSL_peek(SSL *s,char *buf,int num)
+int SSL_peek(SSL *s,void *buf,int num)
        {
+       if (s->handshake_func == 0)
+               {
+               SSLerr(SSL_F_SSL_READ, SSL_R_UNINITIALIZED);
+               return -1;
+               }
+
        if (s->shutdown & SSL_RECEIVED_SHUTDOWN)
                {
                return(0);
@@ -744,7 +739,7 @@ int SSL_peek(SSL *s,char *buf,int num)
        return(s->method->ssl_peek(s,buf,num));
        }
 
-int SSL_write(SSL *s,const char *buf,int num)
+int SSL_write(SSL *s,const void *buf,int num)
        {
        if (s->handshake_func == 0)
                {
@@ -1101,13 +1096,6 @@ int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b)
        return(memcmp(a->session_id,b->session_id,a->session_id_length));
        }
 
-/* These wrapper functions should remain rather than redeclaring
- * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each
- * variable. The reason is that the functions aren't static, they're exposed via
- * ssl.h. */
-static IMPLEMENT_LHASH_HASH_FN(SSL_SESSION_hash, SSL_SESSION *)
-static IMPLEMENT_LHASH_COMP_FN(SSL_SESSION_cmp, SSL_SESSION *)
-
 SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
        {
        SSL_CTX *ret=NULL;
@@ -1171,8 +1159,7 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
        ret->default_passwd_callback_userdata=NULL;
        ret->client_cert_cb=NULL;
 
-       ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash),
-                       LHASH_COMP_FN(SSL_SESSION_cmp));
+       ret->sessions=lh_new(SSL_SESSION_hash,SSL_SESSION_cmp);
        if (ret->sessions == NULL) goto err;
        ret->cert_store=X509_STORE_new();
        if (ret->cert_store == NULL) goto err;
@@ -1219,10 +1206,8 @@ err2:
        return(NULL);
        }
 
-#if 0
 static void SSL_COMP_free(SSL_COMP *comp)
     { OPENSSL_free(comp); }
-#endif
 
 void SSL_CTX_free(SSL_CTX *a)
        {
@@ -1261,12 +1246,8 @@ void SSL_CTX_free(SSL_CTX *a)
                sk_X509_NAME_pop_free(a->client_CA,X509_NAME_free);
        if (a->extra_certs != NULL)
                sk_X509_pop_free(a->extra_certs,X509_free);
-#if 0 /* This should never be done, since it removes a global database */
        if (a->comp_methods != NULL)
                sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free);
-#else
-       a->comp_methods = NULL;
-#endif
        OPENSSL_free(a);
        }
 
@@ -1397,11 +1378,6 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher)
        mask|=SSL_aNULL;
        emask|=SSL_aNULL;
 
-#ifndef NO_KRB5
-       mask|=SSL_kKRB5|SSL_aKRB5;
-       emask|=SSL_kKRB5|SSL_aKRB5;
-#endif
-
        c->mask=mask;
        c->export_mask=emask;
        c->valid=1;
@@ -1434,11 +1410,6 @@ X509 *ssl_get_server_send_cert(SSL *s)
                else
                        i=SSL_PKEY_RSA_ENC;
                }
-       else if (kalg & SSL_aKRB5)
-               {
-               /* VRS something else here? */
-               return(NULL);
-               }
        else /* if (kalg & SSL_aNULL) */
                {
                SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,SSL_R_INTERNAL_ERROR);
@@ -1578,8 +1549,6 @@ int SSL_get_error(SSL *s,int i)
                        reason=BIO_get_retry_reason(bio);
                        if (reason == BIO_RR_CONNECT)
                                return(SSL_ERROR_WANT_CONNECT);
-                       else if (reason == BIO_RR_ACCEPT)
-                               return(SSL_ERROR_WANT_ACCEPT);
                        else
                                return(SSL_ERROR_SYSCALL); /* unknown */
                        }
@@ -1598,8 +1567,6 @@ int SSL_get_error(SSL *s,int i)
                        reason=BIO_get_retry_reason(bio);
                        if (reason == BIO_RR_CONNECT)
                                return(SSL_ERROR_WANT_CONNECT);
-                       else if (reason == BIO_RR_ACCEPT)
-                               return(SSL_ERROR_WANT_ACCEPT);
                        else
                                return(SSL_ERROR_SYSCALL);
                        }