]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
const up various low hanging things
authorCaolán McNamara <caolanm@gmail.com>
Wed, 17 Sep 2025 18:17:53 +0000 (19:17 +0100)
committerTomas Mraz <tomas@openssl.org>
Fri, 28 Nov 2025 08:36:45 +0000 (09:36 +0100)
to move these symbols out of the .data section

remaining list approx-sorted by size with:
objdump -t libcrypto.so libssl.so | grep -v \\.data.rel.ro | grep \\.data | sort -r -k 4

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28588)

18 files changed:
apps/ca.c
crypto/asn1/standard_methods.h
crypto/cmp/cmp_msg.c
crypto/dsa/dsa_ossl.c
crypto/err/err.c
crypto/evp/e_chacha20_poly1305.c
crypto/evp/e_rc4_hmac_md5.c
crypto/rsa/rsa_ossl.c
crypto/sm4/sm4.c
crypto/ts/ts_rsp_print.c
crypto/x509/standard_exts.h
crypto/x509/v3_timespec.c
providers/implementations/encode_decode/decode_pem2der.c
providers/implementations/keymgmt/ec_kmgmt.c
providers/implementations/keymgmt/ec_kmgmt_imexport.inc
providers/implementations/keymgmt/rsa_kmgmt.c
test/asn1_internal_test.c
test/x509_internal_test.c

index a356b53b725e8b789dae00cf48152717c8b5fafe..3a5689ce5b44608585b58692ac78429928c81cd9 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -2315,7 +2315,7 @@ int do_updatedb(CA_DB *db, time_t *now)
     return cnt;
 }
 
-static const char *crl_reasons[] = {
+static const char *const crl_reasons[] = {
     /* CRL reason strings */
     "unspecified",
     "keyCompromise",
index 639cb75b7d8beda36ac25a6fad50eab3d42e7ad8..8b3d068de725b0b8670b08d722a9973d46d89c4f 100644 (file)
@@ -13,7 +13,7 @@
  * represents (corresponding to the pkey_id field) as OBJ_bsearch
  * is used to search it.
  */
-static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
+static const EVP_PKEY_ASN1_METHOD *const standard_methods[] = {
     &ossl_rsa_asn1_meths[0],
     &ossl_rsa_asn1_meths[1],
 #ifndef OPENSSL_NO_DH
index 3c9c9d84ca57d88628c10df101aa2c0b28fb12d6..4e3a4c8ad2f0b2024219337a12ce696d555d37fc 100644 (file)
@@ -65,7 +65,7 @@ OSSL_CMP_PKIHEADER *OSSL_CMP_MSG_get0_header(const OSSL_CMP_MSG *msg)
 
 const char *ossl_cmp_bodytype_to_string(int type)
 {
-    static const char *type_names[] = {
+    static const char *const type_names[] = {
         "IR", "IP", "CR", "CP", "P10CR",
         "POPDECC", "POPDECR", "KUR", "KUP",
         "KRR", "KRP", "RR", "RP", "CCR", "CCP",
index 59b26d73696b90086aa35832f12e1495c7a34780..a7c6930162857f3e0e750aea0d46ee16978b7ed0 100644 (file)
@@ -39,7 +39,7 @@ static int dsa_finish(DSA *dsa);
 static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
                                       BN_CTX *ctx);
 
-static DSA_METHOD openssl_dsa_meth = {
+static const DSA_METHOD openssl_dsa_meth = {
     "OpenSSL DSA method",
     dsa_do_sign,
     dsa_sign_setup_no_digest,
index 63a1bf192af686457686b8d5f6a12c74c8ae331d..a127988a0d61bddfdd0c626f49e3b7fde20c15ad 100644 (file)
@@ -86,7 +86,7 @@ static const ERR_STRING_DATA ERR_str_libraries[] = {
  * Should make sure that all ERR_R_ reasons defined in include/openssl/err.h.in
  * are listed.  For maintainability, please keep all reasons in the same order.
  */
-static ERR_STRING_DATA ERR_str_reasons[] = {
+static const ERR_STRING_DATA ERR_str_reasons[] = {
     {ERR_R_SYS_LIB, "system lib"},
     {ERR_R_BN_LIB, "BN lib"},
     {ERR_R_RSA_LIB, "RSA lib"},
index a06e9a668233ef55370ce77542d920d9ca9ca052..03bf63b50231da6f41dfc39b1b36261f21e430d4 100644 (file)
@@ -609,7 +609,7 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
     }
 }
 
-static EVP_CIPHER chacha20_poly1305 = {
+static const EVP_CIPHER chacha20_poly1305 = {
     NID_chacha20_poly1305,
     1,                  /* block_size */
     CHACHA_KEY_SIZE,    /* key_len */
index 4ea382815ca3d6c4db88ce1addab9f3dc0ea9ef4..ec7dd02ce56068ff5a5ee66562d9692dc0ac7ac7 100644 (file)
@@ -246,7 +246,7 @@ static int rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
     }
 }
 
-static EVP_CIPHER r4_hmac_md5_cipher = {
+static const EVP_CIPHER r4_hmac_md5_cipher = {
 # ifdef NID_rc4_hmac_md5
     NID_rc4_hmac_md5,
 # else
index 90ad0f53fa81ef0b7ed84d4d5649809617e94727..acebee9145353a8c31a3ac24d294d57e09412a80 100644 (file)
@@ -43,7 +43,7 @@ static int rsa_ossl_finish(RSA *rsa);
 #ifdef S390X_MOD_EXP
 static int rsa_ossl_s390x_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
                                 BN_CTX *ctx);
-static RSA_METHOD rsa_pkcs1_ossl_meth = {
+static const RSA_METHOD rsa_pkcs1_ossl_meth = {
     "OpenSSL PKCS#1 RSA",
     rsa_ossl_public_encrypt,
     rsa_ossl_public_decrypt,     /* signature verification */
@@ -61,7 +61,7 @@ static RSA_METHOD rsa_pkcs1_ossl_meth = {
     NULL                        /* rsa_multi_prime_keygen */
 };
 #else
-static RSA_METHOD rsa_pkcs1_ossl_meth = {
+static const RSA_METHOD rsa_pkcs1_ossl_meth = {
     "OpenSSL PKCS#1 RSA",
     rsa_ossl_public_encrypt,
     rsa_ossl_public_decrypt,     /* signature verification */
index 194ef7e4bbf0e9557eca4954daaf6ecb914aae63..d1881b7c7e65127c2bebca5e823fadc4a2334819 100644 (file)
@@ -85,7 +85,7 @@ static const uint32_t SM4_SBOX_T0[256] = {
     0x794C3535, 0xA0208080, 0x9D78E5E5, 0x56EDBBBB, 0x235E7D7D, 0xC63EF8F8,
     0x8BD45F5F, 0xE7C82F2F, 0xDD39E4E4, 0x68492121 };
 
-static uint32_t SM4_SBOX_T1[256] = {
+static const uint32_t SM4_SBOX_T1[256] = {
     0x5B8ED55B, 0x42D09242, 0xA74DEAA7, 0xFB06FDFB, 0x33FCCF33, 0x8765E287,
     0xF4C93DF4, 0xDE6BB5DE, 0x584E1658, 0xDA6EB4DA, 0x50441450, 0x0BCAC10B,
     0xA08828A0, 0xEF17F8EF, 0xB09C2CB0, 0x14110514, 0xAC872BAC, 0x9DFB669D,
@@ -130,7 +130,7 @@ static uint32_t SM4_SBOX_T1[256] = {
     0x35794C35, 0x80A02080, 0xE59D78E5, 0xBB56EDBB, 0x7D235E7D, 0xF8C63EF8,
     0x5F8BD45F, 0x2FE7C82F, 0xE4DD39E4, 0x21684921};
 
-static uint32_t SM4_SBOX_T2[256] = {
+static const uint32_t SM4_SBOX_T2[256] = {
     0x5B5B8ED5, 0x4242D092, 0xA7A74DEA, 0xFBFB06FD, 0x3333FCCF, 0x878765E2,
     0xF4F4C93D, 0xDEDE6BB5, 0x58584E16, 0xDADA6EB4, 0x50504414, 0x0B0BCAC1,
     0xA0A08828, 0xEFEF17F8, 0xB0B09C2C, 0x14141105, 0xACAC872B, 0x9D9DFB66,
@@ -175,7 +175,7 @@ static uint32_t SM4_SBOX_T2[256] = {
     0x3535794C, 0x8080A020, 0xE5E59D78, 0xBBBB56ED, 0x7D7D235E, 0xF8F8C63E,
     0x5F5F8BD4, 0x2F2FE7C8, 0xE4E4DD39, 0x21216849};
 
-static uint32_t SM4_SBOX_T3[256] = {
+static const uint32_t SM4_SBOX_T3[256] = {
     0xD55B5B8E, 0x924242D0, 0xEAA7A74D, 0xFDFBFB06, 0xCF3333FC, 0xE2878765,
     0x3DF4F4C9, 0xB5DEDE6B, 0x1658584E, 0xB4DADA6E, 0x14505044, 0xC10B0BCA,
     0x28A0A088, 0xF8EFEF17, 0x2CB0B09C, 0x05141411, 0x2BACAC87, 0x669D9DFB,
index ca2d8a6dc1541dc78320e1e61600d267d1439f35..c002239905a4cf2f4d1d10907034d2505f65f476 100644 (file)
@@ -41,7 +41,7 @@ int TS_RESP_print_bio(BIO *bio, TS_RESP *a)
 
 int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a)
 {
-    static const char *status_map[] = {
+    static const char *const status_map[] = {
         "Granted.",
         "Granted with modifications.",
         "Rejected.",
index 7449fb0ff62ac6a1242599cb41267a6774d11e49..aef70c2598bdba89e585ea34315ff79d70c617c4 100644 (file)
@@ -12,7 +12,7 @@
  * of the ext_nid values.
  */
 
-static const X509V3_EXT_METHOD *standard_exts[] = {
+static const X509V3_EXT_METHOD *const standard_exts[] = {
     &ossl_v3_nscert,
     &ossl_v3_ns_ia5_list[0],
     &ossl_v3_ns_ia5_list[1],
index 30f6590826fd8b8e48e42a9f82d96b1f0c7ca969..a9cda1f9ba492e754a61122a7f79d32fddd4fe90 100644 (file)
@@ -13,7 +13,7 @@
 #include <crypto/asn1.h>
 #include "ext_dat.h"
 
-static const char *WEEKDAY_NAMES[7] = {
+static const char *const WEEKDAY_NAMES[7] = {
     "SUN",
     "MON",
     "TUE",
@@ -23,7 +23,7 @@ static const char *WEEKDAY_NAMES[7] = {
     "SAT"
 };
 
-static const char *WEEK_NAMES[5] = {
+static const char *const WEEK_NAMES[5] = {
     "first",
     "second",
     "third",
@@ -31,7 +31,7 @@ static const char *WEEK_NAMES[5] = {
     "final"
 };
 
-static const char *MONTH_NAMES[12] = {
+static const char *const MONTH_NAMES[12] = {
     "JAN",
     "FEB",
     "MAR",
index 5eba9fff391bdc7dd058e831c2b2d05e1e398b6d..9c963b180cc8eff80300c48465b1ec3aed5cd25c 100644 (file)
@@ -129,7 +129,7 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection,
      * PEM names we recognise.  Other PEM names should be recognised by
      * other decoder implementations.
      */
-    static struct pem_name_map_st {
+    static const struct pem_name_map_st {
         const char *pem_name;
         int object_type;
         const char *data_type;
index 9e96dffd2c6682ae5afa082853397e7a7338e3a4..89571bb4fcc454fa8399acac673d6ce551d7fcb7 100644 (file)
@@ -1224,7 +1224,7 @@ err:
 static const OSSL_PARAM *ec_gen_settable_params(ossl_unused void *genctx,
                                                 ossl_unused void *provctx)
 {
-    static OSSL_PARAM settable[] = {
+    static const OSSL_PARAM settable[] = {
         OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0),
         OSSL_PARAM_int(OSSL_PKEY_PARAM_USE_COFACTOR_ECDH, NULL),
         OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_EC_ENCODING, NULL, 0),
index b142e0df0c466e34c9dc09e47978ed1fa8580c7f..b242fd17eef27ae8150becf594c7c183d4e4812a 100644 (file)
@@ -89,7 +89,7 @@ static const OSSL_PARAM ec_all_types[] = {
     OSSL_PARAM_END
 };
 
-static const OSSL_PARAM *ec_types[] = {
+static const OSSL_PARAM *const ec_types[] = {
     NULL,
     ec_private_key_types,
     ec_public_key_types,
index 31d65586afd87fec0c2db93ca33bcb8b15370ad3..e2dbe78c0bdd13a1cca3c30dbe7e8b6fa7ff3f7f 100644 (file)
@@ -579,7 +579,7 @@ static int rsa_gen_set_params(void *genctx, const OSSL_PARAM params[])
 static const OSSL_PARAM *rsa_gen_settable_params(ossl_unused void *genctx,
                                                  ossl_unused void *provctx)
 {
-    static OSSL_PARAM settable[] = {
+    static const OSSL_PARAM settable[] = {
         rsa_gen_basic,
         OSSL_PARAM_END
     };
@@ -590,7 +590,7 @@ static const OSSL_PARAM *rsa_gen_settable_params(ossl_unused void *genctx,
 static const OSSL_PARAM *rsapss_gen_settable_params(ossl_unused void *genctx,
                                                     ossl_unused void *provctx)
 {
-    static OSSL_PARAM settable[] = {
+    static const OSSL_PARAM settable[] = {
         rsa_gen_basic,
         rsa_gen_pss,
         OSSL_PARAM_END
index 55bc92cb6448f9152e8ea37dac5f67a7c7cdda6d..5b65402905bf85af2f5ac7547464d7b970e96283 100644 (file)
@@ -71,7 +71,7 @@ static int test_tbl_standard(void)
 
 static int test_standard_methods(void)
 {
-    const EVP_PKEY_ASN1_METHOD **tmp;
+    const EVP_PKEY_ASN1_METHOD * const *tmp;
     int last_pkey_id = -1;
     size_t i;
     int ok = 1;
index e36c3a6aeba89c6ced9a8b4ed38051164c964cf9..f5e5fb68084993e21cc9482ac8e13454c06233cb 100644 (file)
@@ -32,7 +32,7 @@ static int test_standard_exts(void)
 {
     size_t i;
     int prev = -1, good = 1;
-    const X509V3_EXT_METHOD **tmp;
+    const X509V3_EXT_METHOD * const *tmp;
 
     tmp = standard_exts;
     for (i = 0; i < OSSL_NELEM(standard_exts); i++, tmp++) {