"make update" (added to top Makefile, and applied).
[openssl.git] / ssl / ssl_ciph.c
index 55c3fd06bb2605376b2b6d70c2ebdb68a88e6bca..4c2989c47a3028c0b0580dda57f57fb1d93925c2 100644 (file)
@@ -57,8 +57,8 @@
  */
 
 #include <stdio.h>
-#include "objects.h"
-#include "comp.h"
+#include <openssl/objects.h>
+#include <openssl/comp.h>
 #include "ssl_locl.h"
 
 #define SSL_ENC_DES_IDX                0
@@ -70,7 +70,7 @@
 #define SSL_ENC_NULL_IDX       6
 #define SSL_ENC_NUM_IDX                7
 
-static EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={
+static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={
        NULL,NULL,NULL,NULL,NULL,NULL,
        };
 
@@ -79,7 +79,7 @@ static STACK_OF(SSL_COMP) *ssl_comp_methods=NULL;
 #define SSL_MD_MD5_IDX 0
 #define SSL_MD_SHA1_IDX        1
 #define SSL_MD_NUM_IDX 2
-static EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX]={
+static const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX]={
        NULL,NULL,
        };
 
@@ -159,13 +159,12 @@ static SSL_CIPHER cipher_aliases[]={
 static int init_ciphers=1;
 static void load_ciphers();
 
-static int cmp_by_name(a,b)
-SSL_CIPHER **a,**b;
+static int cmp_by_name(SSL_CIPHER **a, SSL_CIPHER **b)
        {
        return(strcmp((*a)->name,(*b)->name));
        }
 
-static void load_ciphers()
+static void load_ciphers(void)
        {
        init_ciphers=0;
        ssl_cipher_methods[SSL_ENC_DES_IDX]= 
@@ -185,11 +184,8 @@ static void load_ciphers()
                EVP_get_digestbyname(SN_sha1);
        }
 
-int ssl_cipher_get_evp(s,enc,md,comp)
-SSL_SESSION *s;
-EVP_CIPHER **enc;
-EVP_MD **md;
-SSL_COMP **comp;
+int ssl_cipher_get_evp(SSL_SESSION *s, const EVP_CIPHER **enc,
+            const EVP_MD **md, SSL_COMP **comp)
        {
        int i;
        SSL_CIPHER *c;
@@ -282,8 +278,8 @@ SSL_COMP **comp;
 #define ITEM_SEP(a) \
        (((a) == ':') || ((a) == ' ') || ((a) == ';') || ((a) == ','))
 
-static void ll_append_tail(head,curr,tail)
-CIPHER_ORDER **head,*curr,**tail;
+static void ll_append_tail(CIPHER_ORDER **head, CIPHER_ORDER *curr,
+            CIPHER_ORDER **tail)
        {
        if (curr == *tail) return;
        if (curr == *head)
@@ -298,11 +294,10 @@ CIPHER_ORDER **head,*curr,**tail;
        *tail=curr;
        }
 
-STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(ssl_method,cipher_list,
-                                            cipher_list_by_id,str)
-SSL_METHOD *ssl_method;
-STACK_OF(SSL_CIPHER) **cipher_list,**cipher_list_by_id;
-char *str;
+STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_METHOD *ssl_method,
+               STACK_OF(SSL_CIPHER) **cipher_list,
+               STACK_OF(SSL_CIPHER) **cipher_list_by_id,
+               char *str)
        {
        SSL_CIPHER *c;
        char *l;
@@ -463,10 +458,14 @@ char *str;
                        {
                        ch= *l;
                        i=0;
+#ifndef CHARSET_EBCDIC
                        while ( ((ch >= 'A') && (ch <= 'Z')) ||
                                ((ch >= '0') && (ch <= '9')) ||
                                ((ch >= 'a') && (ch <= 'z')) ||
                                 (ch == '-'))
+#else
+                       while ( isalnum(ch) || (ch == '-'))
+#endif
                                 {
                                 buf[i]=ch;
                                 ch= *(++l);
@@ -613,12 +612,9 @@ err:
        return(ok);
        }
 
-char *SSL_CIPHER_description(cipher,buf,len)
-SSL_CIPHER *cipher;
-char *buf;
-int len;
+char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
        {
-        int is_export,pkl,kl;
+       int is_export,pkl,kl;
        char *ver,*exp;
        char *kx,*au,*enc,*mac;
        unsigned long alg,alg2;
@@ -627,10 +623,10 @@ int len;
        alg=cipher->algorithms;
        alg2=cipher->algorithm2;
 
-        is_export=SSL_IS_EXPORT(alg);
+       is_export=SSL_IS_EXPORT(alg);
        pkl=SSL_EXPORT_PKEYLENGTH(alg);
        kl=SSL_EXPORT_KEYLENGTH(alg);
-        exp=is_export?" export":"";
+       exp=is_export?" export":"";
 
        if (alg & SSL_SSLV2)
                ver="SSLv2";
@@ -642,7 +638,7 @@ int len;
        switch (alg&SSL_MKEY_MASK)
                {
        case SSL_kRSA:
-                kx=is_export?(pkl == 512 ? "RSA(512)" : "RSA(1024)"):"RSA";
+               kx=is_export?(pkl == 512 ? "RSA(512)" : "RSA(1024)"):"RSA";
                break;
        case SSL_kDHr:
                kx="DH/RSA";
@@ -654,7 +650,7 @@ int len;
                kx="Fortezza";
                break;
        case SSL_kEDH:
-                kx=is_export?(pkl == 512 ? "DH(512)" : "DH(1024)"):"DH";
+               kx=is_export?(pkl == 512 ? "DH(512)" : "DH(1024)"):"DH";
                break;
        default:
                kx="unknown";
@@ -683,17 +679,17 @@ int len;
        switch (alg&SSL_ENC_MASK)
                {
        case SSL_DES:
-                enc=(is_export && kl == 5)?"DES(40)":"DES(56)";
+               enc=(is_export && kl == 5)?"DES(40)":"DES(56)";
                break;
        case SSL_3DES:
                enc="3DES(168)";
                break;
        case SSL_RC4:
-                enc=is_export?(kl == 5 ? "RC4(40)" : "RC4(56)")
+               enc=is_export?(kl == 5 ? "RC4(40)" : "RC4(56)")
                  :((alg2&SSL2_CF_8_BYTE_ENC)?"RC4(64)":"RC4(128)");
                break;
        case SSL_RC2:
-                enc=is_export?(kl == 5 ? "RC2(40)" : "RC2(56)"):"RC2(128)";
+               enc=is_export?(kl == 5 ? "RC2(40)" : "RC2(56)"):"RC2(128)";
                break;
        case SSL_IDEA:
                enc="IDEA(128)";
@@ -734,8 +730,7 @@ int len;
        return(buf);
        }
 
-char *SSL_CIPHER_get_version(c)
-SSL_CIPHER *c;
+char *SSL_CIPHER_get_version(SSL_CIPHER *c)
        {
        int i;
 
@@ -750,8 +745,7 @@ SSL_CIPHER *c;
        }
 
 /* return the actual cipher being used */
-char *SSL_CIPHER_get_name(c)
-SSL_CIPHER *c;
+const char *SSL_CIPHER_get_name(SSL_CIPHER *c)
        {
        if (c != NULL)
                return(c->name);
@@ -759,13 +753,11 @@ SSL_CIPHER *c;
        }
 
 /* number of bits for symetric cipher */
-int SSL_CIPHER_get_bits(c,alg_bits)
-SSL_CIPHER *c;
-int *alg_bits;
+int SSL_CIPHER_get_bits(SSL_CIPHER *c, int *alg_bits)
        {
        int ret=0,a=0;
-       EVP_CIPHER *enc;
-       EVP_MD *md;
+       const EVP_CIPHER *enc;
+       const EVP_MD *md;
        SSL_SESSION ss;
 
        if (c != NULL)
@@ -794,9 +786,7 @@ int *alg_bits;
        return(ret);
        }
 
-SSL_COMP *ssl3_comp_find(sk,n)
-STACK_OF(SSL_COMP) *sk;
-int n;
+SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n)
        {
        SSL_COMP *ctmp;
        int i,nn;
@@ -812,20 +802,17 @@ int n;
        return(NULL);
        }
 
-static int sk_comp_cmp(a,b)
-SSL_COMP **a,**b;
+static int sk_comp_cmp(SSL_COMP **a,SSL_COMP **b)
        {
        return((*a)->id-(*b)->id);
        }
 
-STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods()
+STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void)
        {
        return(ssl_comp_methods);
        }
 
-int SSL_COMP_add_compression_method(id,cm)
-int id;
-COMP_METHOD *cm;
+int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
        {
        SSL_COMP *comp;
        STACK_OF(SSL_COMP) *sk;