Deal with the consequences of constifying getters
authorRichard Levitte <levitte@openssl.org>
Tue, 14 Jun 2016 13:49:05 +0000 (15:49 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 15 Jun 2016 18:09:27 +0000 (20:09 +0200)
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
13 files changed:
apps/apps.c
apps/apps.h
apps/dhparam.c
apps/dsa.c
apps/dsaparam.c
apps/gendsa.c
apps/genrsa.c
apps/req.c
apps/rsa.c
apps/x509.c
crypto/pem/pvkfmt.c
ssl/statem/statem_clnt.c
ssl/statem/statem_srvr.c

index fca3775b770fe51e646e01ad95281268861b40b3..ec1cfe9927b12942787707d9a3b7f6a7cb9d3390 100644 (file)
@@ -1148,7 +1148,7 @@ void print_name(BIO *out, const char *title, X509_NAME *nm,
     }
 }
 
-void print_bignum_var(BIO *out, BIGNUM *in, const char *var,
+void print_bignum_var(BIO *out, const BIGNUM *in, const char *var,
                       int len, unsigned char *buffer)
 {
     BIO_printf(out, "    static unsigned char %s_%d[] = {", var, len);
index 6a0acab58c334586971a4ccec490606832276bb4..d56c07df3177ebc9a12f2d37c387210ec612f6aa 100644 (file)
@@ -380,7 +380,8 @@ int dump_cert_text(BIO *out, X509 *x);
 void print_name(BIO *out, const char *title, X509_NAME *nm,
                 unsigned long lflags);
 # endif
-void print_bignum_var(BIO *, BIGNUM *, const char*, int, unsigned char *);
+void print_bignum_var(BIO *, const BIGNUM *, const char*,
+                      int, unsigned char *);
 void print_array(BIO *, const char *, int, const unsigned char *);
 int set_cert_ex(unsigned long *flags, const char *arg);
 int set_name_ex(unsigned long *flags, const char *arg);
index f86e3155998c15ab87c0ebad0c214ac803253cd1..ab2e787f76e4da3e95aa935214b06c52c891ab0b 100644 (file)
@@ -298,7 +298,7 @@ int dhparam_main(int argc, char **argv)
     if (C) {
         unsigned char *data;
         int len, bits;
-        BIGNUM *pbn, *gbn;
+        const BIGNUM *pbn, *gbn;
 
         len = DH_size(dh);
         bits = DH_bits(dh);
@@ -337,7 +337,7 @@ int dhparam_main(int argc, char **argv)
     }
 
     if (!noout) {
-        BIGNUM *q;
+        const BIGNUM *q;
         DH_get0_pqg(dh, NULL, &q, NULL);
         if (outformat == FORMAT_ASN1)
             i = i2d_DHparams_bio(out, dh);
index ef50fede78742fb3128848a8b74dd2d372d367c1..6ac9a40282904d0c55a172f8130690c94a8e0849 100644 (file)
@@ -195,7 +195,7 @@ int dsa_main(int argc, char **argv)
     }
 
     if (modulus) {
-        BIGNUM *pub_key = NULL;
+        const BIGNUM *pub_key = NULL;
         DSA_get0_key(dsa, &pub_key, NULL);
         BIO_printf(out, "Public Key=");
         BN_print(out, pub_key);
index cd2ca4c3f7c9c4518f99970f41b7c1b2f6094481..404266009eaa7dcb4685bb17d20ac1b8c822154e 100644 (file)
@@ -215,7 +215,7 @@ int dsaparam_main(int argc, char **argv)
     }
 
     if (C) {
-        BIGNUM *p = NULL, *q = NULL, *g = NULL;
+        const BIGNUM *p = NULL, *q = NULL, *g = NULL;
         unsigned char *data;
         int len, bits_p;
 
index 2be3b9a0550e2216b08798689a320d4dc3d6b7de..5dacf1b9fcf14086e6f029d188b564452ff386a2 100644 (file)
@@ -53,7 +53,7 @@ int gendsa_main(int argc, char **argv)
     char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
     OPTION_CHOICE o;
     int ret = 1, private = 0;
-    BIGNUM *p = NULL;
+    const BIGNUM *p = NULL;
 
     prog = opt_init(argc, argv, gendsa_options);
     while ((o = opt_next()) != OPT_EOF) {
index 79e2dae8008b05ba5e1dc6708c6715014fc5c247..4d104d2882c2d6f10d8ed9deb0cc3b0bd85702de 100644 (file)
@@ -59,7 +59,7 @@ int genrsa_main(int argc, char **argv)
     ENGINE *eng = NULL;
     BIGNUM *bn = BN_new();
     BIO *out = NULL;
-    BIGNUM *e;
+    const BIGNUM *e;
     RSA *rsa = NULL;
     const EVP_CIPHER *enc = NULL;
     int ret = 1, num = DEFBITS, private = 0;
index ca8a9af8747d4bcabec6a49ef52084e11665887a..d1f5dcb3450309e754c5944bd8cc16b19709cb7d 100644 (file)
@@ -768,7 +768,7 @@ int req_main(int argc, char **argv)
         fprintf(stdout, "Modulus=");
 #ifndef OPENSSL_NO_RSA
         if (EVP_PKEY_base_id(tpubkey) == EVP_PKEY_RSA) {
-            BIGNUM *n;
+            const BIGNUM *n;
             RSA_get0_key(EVP_PKEY_get0_RSA(tpubkey), &n, NULL, NULL);
             BN_print(out, n);
         } else
index 3a1195f566c64b4616a04253e44abe74898ff8ce..63e88e6762f23cc17bfba81c2b597b0b0833ad3d 100644 (file)
@@ -214,7 +214,7 @@ int rsa_main(int argc, char **argv)
     }
 
     if (modulus) {
-        BIGNUM *n;
+        const BIGNUM *n;
         RSA_get0_key(rsa, &n, NULL, NULL);
         BIO_printf(out, "Modulus=");
         BN_print(out, n);
index 0753817257cc7e40430abc0e2d6f33843f309ff9..4191a345bb26054b59822fd22dcd17ecc89b0053 100644 (file)
@@ -684,14 +684,14 @@ int x509_main(int argc, char **argv)
                 BIO_printf(out, "Modulus=");
 #ifndef OPENSSL_NO_RSA
                 if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) {
-                    BIGNUM *n;
+                    const BIGNUM *n;
                     RSA_get0_key(EVP_PKEY_get0_RSA(pkey), &n, NULL, NULL);
                     BN_print(out, n);
                 } else
 #endif
 #ifndef OPENSSL_NO_DSA
                 if (EVP_PKEY_id(pkey) == EVP_PKEY_DSA) {
-                    BIGNUM *dsapub = NULL;
+                    const BIGNUM *dsapub = NULL;
                     DSA_get0_key(EVP_PKEY_get0_DSA(pkey), &dsapub, NULL);
                     BN_print(out, dsapub);
                 } else
index 4c07aee8f2471ab0a325ad7a57cab974705204a9..bf512ecdf064424ba8469cd886d74ce0a5d02d27 100644 (file)
@@ -467,7 +467,8 @@ static int do_i2b_bio(BIO *out, EVP_PKEY *pk, int ispub)
 static int check_bitlen_dsa(DSA *dsa, int ispub, unsigned int *pmagic)
 {
     int bitlen;
-    BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub_key = NULL, *priv_key = NULL;
+    const BIGNUM *p = NULL, *q = NULL, *g = NULL;
+    const BIGNUM *pub_key = NULL, *priv_key = NULL;
 
     DSA_get0_pqg(dsa, &p, &q, &g);
     DSA_get0_key(dsa, &pub_key, &priv_key);
@@ -494,7 +495,7 @@ static int check_bitlen_dsa(DSA *dsa, int ispub, unsigned int *pmagic)
 static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *pmagic)
 {
     int nbyte, hnbyte, bitlen;
-    BIGNUM *e;
+    const BIGNUM *e;
 
     RSA_get0_key(rsa, &e, NULL, NULL);
     if (BN_num_bits(e) > 32)
@@ -506,7 +507,7 @@ static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *pmagic)
         *pmagic = MS_RSA1MAGIC;
         return bitlen;
     } else {
-        BIGNUM *d, *p, *q, *iqmp, *dmp1, *dmq1;
+        const BIGNUM *d, *p, *q, *iqmp, *dmp1, *dmq1;
 
         *pmagic = MS_RSA2MAGIC;
 
@@ -534,7 +535,7 @@ static int check_bitlen_rsa(RSA *rsa, int ispub, unsigned int *pmagic)
 static void write_rsa(unsigned char **out, RSA *rsa, int ispub)
 {
     int nbyte, hnbyte;
-    BIGNUM *n, *d, *e, *p, *q, *iqmp, *dmp1, *dmq1;
+    const BIGNUM *n, *d, *e, *p, *q, *iqmp, *dmp1, *dmq1;
 
     nbyte = RSA_size(rsa);
     hnbyte = (RSA_bits(rsa) + 15) >> 4;
@@ -556,7 +557,8 @@ static void write_rsa(unsigned char **out, RSA *rsa, int ispub)
 static void write_dsa(unsigned char **out, DSA *dsa, int ispub)
 {
     int nbyte;
-    BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub_key = NULL, *priv_key = NULL;
+    const BIGNUM *p = NULL, *q = NULL, *g = NULL;
+    const BIGNUM *pub_key = NULL, *priv_key = NULL;
 
     DSA_get0_pqg(dsa, &p, &q, &g);
     DSA_get0_key(dsa, &pub_key, &priv_key);
index 078349fbb19c427b49fc54a04f3c0fff060afdd2..9fae19028ca359b17ceb3993a2187c13eeb00ea0 100644 (file)
@@ -2178,7 +2178,7 @@ psk_err:
 #ifndef OPENSSL_NO_DH
     else if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) {
         DH *dh_clnt = NULL;
-        BIGNUM *pub_key;
+        const BIGNUM *pub_key;
         skey = s->s3->peer_tmp;
         if (skey == NULL) {
             SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE,
index f4fe2b9f404b02e2c15572ed67726182cf81ceba..f88b6c8194528aa62660e5ac2b639028eb6512b2 100644 (file)
@@ -1602,7 +1602,7 @@ int tls_construct_server_key_exchange(SSL *s)
     int al, i;
     unsigned long type;
     int n;
-    BIGNUM *r[4];
+    const BIGNUM *r[4];
     int nr[4], kn;
     BUF_MEM *buf;
     EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();