Fix compilation with no-nextprotoneg.
[openssl.git] / ssl / s2_lib.c
index 30ca860..b37792f 100644 (file)
@@ -121,7 +121,7 @@ const char ssl2_version_str[]="SSLv2" OPENSSL_VERSION_PTEXT;
 #define SSL2_NUM_CIPHERS (sizeof(ssl2_ciphers)/sizeof(SSL_CIPHER))
 
 /* list of available SSLv2 ciphers (sorted by id) */
-OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
+OPENSSL_GLOBAL const SSL_CIPHER ssl2_ciphers[]={
 #if 0
 /* NULL_WITH_MD5 v3 */
        {
@@ -279,6 +279,10 @@ OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
        SSL2_TXT_NULL,
        SSL2_CK_NULL,
        0,
+       0,
+       0,
+       0,
+       SSL_SSLV2,
        SSL_STRONG_NONE,
        0,
        0,
@@ -299,7 +303,7 @@ int ssl2_num_ciphers(void)
        return(SSL2_NUM_CIPHERS);
        }
 
-SSL_CIPHER *ssl2_get_cipher(unsigned int u)
+const SSL_CIPHER *ssl2_get_cipher(unsigned int u)
        {
        if (u < SSL2_NUM_CIPHERS)
                return(&(ssl2_ciphers[SSL2_NUM_CIPHERS-1-u]));
@@ -410,22 +414,17 @@ long ssl2_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
 
 /* This function needs to check if the ciphers required are actually
  * available */
-SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
+const SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
        {
-       SSL_CIPHER c,*cp;
+       SSL_CIPHER c;
+       const SSL_CIPHER *cp;
        unsigned long id;
 
        id=0x02000000L|((unsigned long)p[0]<<16L)|
                ((unsigned long)p[1]<<8L)|(unsigned long)p[2];
        c.id=id;
-       cp = (SSL_CIPHER *)OBJ_bsearch((char *)&c,
-               (char *)ssl2_ciphers,
-               SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER),
-               FP_ICC ssl_cipher_id_cmp);
-       if ((cp == NULL) || (cp->valid == 0))
-               return NULL;
-       else
-               return cp;
+       cp = OBJ_bsearch_ssl_cipher_id(&c, ssl2_ciphers, SSL2_NUM_CIPHERS);
+       return cp;
        }
 
 int ssl2_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
@@ -450,6 +449,7 @@ int ssl2_generate_key_material(SSL *s)
        unsigned char *km;
        unsigned char c='0';
        const EVP_MD *md5;
+       int md_size;
 
        md5 = EVP_md5();
 
@@ -466,10 +466,12 @@ int ssl2_generate_key_material(SSL *s)
                SSLerr(SSL_F_SSL2_GENERATE_KEY_MATERIAL, ERR_R_INTERNAL_ERROR);
                return 0;
                }
-
-       for (i=0; i<s->s2->key_material_length; i += EVP_MD_size(md5))
+       md_size = EVP_MD_size(md5);
+       if (md_size < 0)
+           return 0;
+       for (i=0; i<s->s2->key_material_length; i += md_size)
                {
-               if (((km - s->s2->key_material) + EVP_MD_size(md5)) >
+               if (((km - s->s2->key_material) + md_size) >
                                (int)sizeof(s->s2->key_material))
                        {
                        /* EVP_DigestFinal_ex() below would write beyond buffer */
@@ -488,7 +490,7 @@ int ssl2_generate_key_material(SSL *s)
                EVP_DigestUpdate(&ctx,s->s2->challenge,s->s2->challenge_length);
                EVP_DigestUpdate(&ctx,s->s2->conn_id,s->s2->conn_id_length);
                EVP_DigestFinal_ex(&ctx,km,NULL);
-               km += EVP_MD_size(md5);
+               km += md_size;
                }
 
        EVP_MD_CTX_cleanup(&ctx);