Fix declarations and constification for inline stack.
authorDr. Stephen Henson <steve@openssl.org>
Wed, 23 Dec 2015 00:47:28 +0000 (00:47 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 7 Jan 2016 18:00:51 +0000 (18:00 +0000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
21 files changed:
apps/ciphers.c
crypto/asn1/ameth_lib.c
crypto/cms/cms_env.c
crypto/cms/cms_lcl.h
crypto/cms/cms_lib.c
crypto/evp/evp_pbe.c
crypto/evp/pmeth_lib.c
crypto/x509v3/pcy_int.h
crypto/x509v3/pcy_node.c
crypto/x509v3/pcy_tree.c
include/openssl/cms.h
include/openssl/ssl.h
include/openssl/x509v3.h
ssl/s3_lib.c
ssl/ssl_lib.c
ssl/ssl_locl.h
ssl/ssl_sess.c
ssl/statem/statem_clnt.c
ssl/statem/statem_srvr.c
ssl/t1_lib.c
test/ssltest.c

index d5a7631ac1e39e516aad682a150aa2c99401409b..086ad43657bc53b76bbbb24df247fe8c3e88c3f6 100644 (file)
@@ -200,7 +200,7 @@ int ciphers_main(int argc, char **argv)
 
     if (!verbose) {
         for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
-            SSL_CIPHER *c = sk_SSL_CIPHER_value(sk, i);
+            const SSL_CIPHER *c = sk_SSL_CIPHER_value(sk, i);
             p = SSL_CIPHER_get_name(c);
             if (p == NULL)
                 break;
@@ -212,7 +212,7 @@ int ciphers_main(int argc, char **argv)
     } else {
 
         for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
-            SSL_CIPHER *c;
+            const SSL_CIPHER *c;
 
             c = sk_SSL_CIPHER_value(sk, i);
 
index 85115bc5b7e999091811e13bea3c7d797b5a8ebe..cca4a791411a71ef858561103322ba0577e4300b 100644 (file)
@@ -92,7 +92,7 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
 };
 
 typedef int sk_cmp_fn_type(const char *const *a, const char *const *b);
-DECLARE_STACK_OF(EVP_PKEY_ASN1_METHOD)
+DECLARE_CONST_STACK_OF(EVP_PKEY_ASN1_METHOD)
 static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL;
 
 #ifdef TEST
index a9a9d84e600fcc2be1b9819ffcd870cc3241f6c0..0b765486b96f36ce531e8b4a10dfd3f4d57e7b4b 100644 (file)
@@ -65,8 +65,6 @@
 
 /* CMS EnvelopedData Utilities */
 
-DECLARE_STACK_OF(CMS_RecipientInfo)
-
 CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms)
 {
     if (OBJ_obj2nid(cms->contentType) != NID_pkcs7_enveloped) {
index 3d41d4f634e8e05deb105441b994b7109e1bb9b9..abc2a2741c69d88d4799975d446f94ae0ea08c11 100644 (file)
@@ -109,6 +109,8 @@ struct CMS_ContentInfo_st {
     } d;
 };
 
+DECLARE_STACK_OF(CMS_CertificateChoices)
+
 struct CMS_SignedData_st {
     long version;
     STACK_OF(X509_ALGOR) *digestAlgorithms;
index fdc69f6f8fadb535eafdfb8b1b05dc5a02016e12..f6de4efd3a62bd480619f5adaf7adb6990ed8017 100644 (file)
@@ -64,9 +64,6 @@
 IMPLEMENT_ASN1_FUNCTIONS(CMS_ContentInfo)
 IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
 
-DECLARE_STACK_OF(CMS_CertificateChoices)
-DECLARE_STACK_OF(CMS_RevocationInfoChoice)
-
 const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms)
 {
     return cms->contentType;
index 563634ec539f2f7dc9b9e211d333a27d09333678..dc908f804ef8c0e2c2642edc801151012841c1a6 100644 (file)
@@ -66,9 +66,6 @@
 
 /* Password based encryption (PBE) functions */
 
-DECLARE_STACK_OF(EVP_PBE_CTL)
-static STACK_OF(EVP_PBE_CTL) *pbe_algs;
-
 /* Setup a cipher context from a PBE algorithm */
 
 typedef struct {
@@ -79,6 +76,9 @@ typedef struct {
     EVP_PBE_KEYGEN *keygen;
 } EVP_PBE_CTL;
 
+DECLARE_STACK_OF(EVP_PBE_CTL)
+static STACK_OF(EVP_PBE_CTL) *pbe_algs;
+
 static const EVP_PBE_CTL builtin_pbe[] = {
     {EVP_PBE_TYPE_OUTER, NID_pbeWithMD2AndDES_CBC,
      NID_des_cbc, NID_md2, PKCS5_PBE_keyivgen},
index a80fc33ccbed5ebc31f4978c2312677471225640..e880cfa37dae3f6bee50d1fe6596594495b5a82f 100644 (file)
@@ -69,7 +69,7 @@
 
 typedef int sk_cmp_fn_type(const char *const *a, const char *const *b);
 
-DECLARE_STACK_OF(EVP_PKEY_METHOD)
+DECLARE_CONST_STACK_OF(EVP_PKEY_METHOD)
 static STACK_OF(EVP_PKEY_METHOD) *app_pkey_methods = NULL;
 
 static const EVP_PKEY_METHOD *standard_methods[] = {
index b5075f9edbdd91503827a94fc17c1caeb09178ef..cbc94c04198e7916ffc87be1593fc7c917698f8e 100644 (file)
@@ -207,7 +207,7 @@ X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
                                const ASN1_OBJECT *id);
 
 X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
-                                 const X509_POLICY_DATA *data,
+                                 X509_POLICY_DATA *data,
                                  X509_POLICY_NODE *parent,
                                  X509_POLICY_TREE *tree);
 void policy_node_free(X509_POLICY_NODE *node);
index 81b4c78bc23a658a62cb11bc26381995d6b8c8c7..a71f9b8eefc11d26ff33a10a3a223aaf3f37e428 100644 (file)
@@ -109,7 +109,7 @@ X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
 }
 
 X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
-                                 const X509_POLICY_DATA *data,
+                                 X509_POLICY_DATA *data,
                                  X509_POLICY_NODE *parent,
                                  X509_POLICY_TREE *tree)
 {
index 04d7bfc42a6da8019b49d839da4dbc713ce71956..a4603332294c3b98169153629cbd0b66be3554d0 100644 (file)
@@ -292,7 +292,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
 }
 
 static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
-                                    const X509_POLICY_DATA *data)
+                                    X509_POLICY_DATA *data)
 {
     X509_POLICY_LEVEL *last = curr - 1;
     X509_POLICY_NODE *node;
index c424b761d3a6f0d4d35598c0a12552eb7cc669d4..9cbfaf58cee8564c4fef41967117214314d61603 100644 (file)
@@ -56,6 +56,7 @@
 # define HEADER_CMS_H
 
 # include <openssl/x509.h>
+# include <openssl/x509v3.h>
 
 # ifdef OPENSSL_NO_CMS
 #  error CMS is disabled.
@@ -76,8 +77,9 @@ typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
 typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
 
 DECLARE_STACK_OF(CMS_SignerInfo)
-DECLARE_STACK_OF(GENERAL_NAMES)
 DECLARE_STACK_OF(CMS_RecipientEncryptedKey)
+DECLARE_STACK_OF(CMS_RecipientInfo)
+DECLARE_STACK_OF(CMS_RevocationInfoChoice)
 DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
 DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
 DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
index e6342946ddfd2d09db10da2984ff90f8dc8181ca..b2e9209752a2ff87f28864b17e597d7ac5b5c724 100644 (file)
@@ -325,7 +325,7 @@ typedef struct ssl_session_st SSL_SESSION;
 typedef struct tls_sigalgs_st TLS_SIGALGS;
 typedef struct ssl_conf_ctx_st SSL_CONF_CTX;
 
-DECLARE_STACK_OF(SSL_CIPHER)
+DECLARE_CONST_STACK_OF(SSL_CIPHER)
 
 DECLARE_STACK_OF(danetls_record)
 
@@ -343,7 +343,7 @@ typedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,
 typedef int (*tls_session_secret_cb_fn) (SSL *s, void *secret,
                                          int *secret_len,
                                          STACK_OF(SSL_CIPHER) *peer_ciphers,
-                                         SSL_CIPHER **cipher, void *arg);
+                                         const SSL_CIPHER **cipher, void *arg);
 
 /* Typedefs for handling custom extensions */
 
index 7932acb9c80a4f1a6d9ed234e4806d9e366154da..76d3c1f57ebfb0d5aa7a060c68d9dbbfeb7100ff 100644 (file)
@@ -206,8 +206,6 @@ typedef struct GENERAL_NAME_st {
     } d;
 } GENERAL_NAME;
 
-typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
-
 typedef struct ACCESS_DESCRIPTION_st {
     ASN1_OBJECT *method;
     GENERAL_NAME *location;
@@ -220,6 +218,8 @@ typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
 typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE;
 
 DECLARE_STACK_OF(GENERAL_NAME)
+typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
+DECLARE_STACK_OF(GENERAL_NAMES)
 
 DECLARE_STACK_OF(ACCESS_DESCRIPTION)
 
index d307ec05d6c4e3941d3b153e11ffc3d9d2a42417..de8dae22f0ed95f8a156ff2bec48acd672ba3aad 100644 (file)
@@ -4105,10 +4105,10 @@ int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
     return (2);
 }
 
-SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
+const SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
                                STACK_OF(SSL_CIPHER) *srvr)
 {
-    SSL_CIPHER *c, *ret = NULL;
+    const SSL_CIPHER *c, *ret = NULL;
     STACK_OF(SSL_CIPHER) *prio, *allow;
     int i, ii, ok;
     unsigned long alg_k, alg_a, mask_k, mask_a;
@@ -4201,7 +4201,7 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
         if (ii >= 0) {
             /* Check security callback permits this cipher */
             if (!ssl_security(s, SSL_SECOP_CIPHER_SHARED,
-                              c->strength_bits, 0, c))
+                              c->strength_bits, 0, (void *)c))
                 continue;
 #if !defined(OPENSSL_NO_EC)
             if ((alg_k & SSL_kECDHE) && (alg_a & SSL_aECDSA)
index f0f1264cdff5c4453764bf607107940f5900936d..edb368df6799f641a4299639a07c194e439109eb 100644 (file)
@@ -1883,7 +1883,7 @@ STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s)
 /** The old interface to get the same thing as SSL_get_ciphers() */
 const char *SSL_get_cipher_list(const SSL *s, int n)
 {
-    SSL_CIPHER *c;
+    const SSL_CIPHER *c;
     STACK_OF(SSL_CIPHER) *sk;
 
     if (s == NULL)
@@ -1941,7 +1941,7 @@ char *SSL_get_shared_ciphers(const SSL *s, char *buf, int len)
 {
     char *p;
     STACK_OF(SSL_CIPHER) *sk;
-    SSL_CIPHER *c;
+    const SSL_CIPHER *c;
     int i;
 
     if ((s->session == NULL) || (s->session->ciphers == NULL) || (len < 2))
index fee7fa6f154e13ec834b12d3215c9b84d32d033a..6734c4df83943cd0efa6564d8ae885eff91ee0f4 100644 (file)
@@ -1910,8 +1910,9 @@ __owur int ssl3_final_finish_mac(SSL *s, const char *sender, int slen,
 void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
 void ssl3_free_digest_list(SSL *s);
 __owur unsigned long ssl3_output_cert_chain(SSL *s, CERT_PKEY *cpk);
-__owur SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt,
-                               STACK_OF(SSL_CIPHER) *srvr);
+__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
+                                            STACK_OF(SSL_CIPHER) *clnt,
+                                            STACK_OF(SSL_CIPHER) *srvr);
 __owur int ssl3_digest_cached_records(SSL *s, int keep);
 __owur int ssl3_new(SSL *s);
 void ssl3_free(SSL *s);
index baf846deb771ea40fa953d9345e4fa001836094b..80895b6abd6e6d9b9be132090423f31976c016e3 100644 (file)
@@ -989,7 +989,7 @@ int SSL_set_session_secret_cb(SSL *s,
                                                             int *secret_len,
                                                             STACK_OF(SSL_CIPHER)
                                                             *peer_ciphers,
-                                                            SSL_CIPHER
+                                                            const SSL_CIPHER
                                                             **cipher,
                                                             void *arg),
                               void *arg)
index cfbfa5f8c3d33d67ef01f437f1a23297963880cd..59259231336d6cdfd86055fb43cacdb3a7d3b77f 100644 (file)
@@ -1090,7 +1090,7 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
      */
     if (s->version >= TLS1_VERSION && s->tls_session_secret_cb &&
         s->session->tlsext_tick) {
-        SSL_CIPHER *pref_cipher = NULL;
+        const SSL_CIPHER *pref_cipher = NULL;
         s->session->master_key_length = sizeof(s->session->master_key);
         if (s->tls_session_secret_cb(s, s->session->master_key,
                                      &s->session->master_key_length,
@@ -2865,7 +2865,7 @@ int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk,
                              unsigned char *p)
 {
     int i, j = 0;
-    SSL_CIPHER *c;
+    const SSL_CIPHER *c;
     unsigned char *q;
     int empty_reneg_info_scsv = !s->renegotiate;
     /* Set disabled masks for this session */
index 604b36565be3fad28c1f11a9b243183c266511d1..de20bcf9e8b2db5994160976a06f348114e75a19 100644 (file)
@@ -965,7 +965,7 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt)
     int i, al = SSL_AD_INTERNAL_ERROR;
     unsigned int j, complen = 0;
     unsigned long id;
-    SSL_CIPHER *c;
+    const SSL_CIPHER *c;
 #ifndef OPENSSL_NO_COMP
     SSL_COMP *comp = NULL;
 #endif
@@ -1295,7 +1295,7 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt)
     }
 
     if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) {
-        SSL_CIPHER *pref_cipher = NULL;
+        const SSL_CIPHER *pref_cipher = NULL;
 
         s->session->master_key_length = sizeof(s->session->master_key);
         if (s->tls_session_secret_cb(s, s->session->master_key,
@@ -1446,7 +1446,7 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt)
 WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst)
 {
     int al = SSL_AD_HANDSHAKE_FAILURE;
-    SSL_CIPHER *cipher;
+    const SSL_CIPHER *cipher;
 
     if (wst == WORK_MORE_A) {
         if (!s->hit) {
index 980f2f5d0bbba6867c747a956cd4b425187d6367..908f8e909c2477adf45e35dc651c6ccb9f3db7cb 100644 (file)
@@ -1127,7 +1127,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf,
         STACK_OF(SSL_CIPHER) *cipher_stack = SSL_get_ciphers(s);
 
         for (i = 0; i < sk_SSL_CIPHER_num(cipher_stack); i++) {
-            SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i);
+            const SSL_CIPHER *c = sk_SSL_CIPHER_value(cipher_stack, i);
 
             alg_k = c->algorithm_mkey;
             alg_a = c->algorithm_auth;
index 58e0f82030f81fa27eb5e339697edd773970a678..44d001965e83955274d5abd1d12ad6784496519b 100644 (file)
@@ -1049,7 +1049,7 @@ int main(int argc, char *argv[])
 
     SSL_CONF_CTX *s_cctx = NULL, *c_cctx = NULL;
     STACK_OF(OPENSSL_STRING) *conf_args = NULL;
-    const char *arg = NULL, *argn = NULL;
+    char *arg = NULL, *argn = NULL;
 
     verbose = 0;
     debug = 0;