Commit 5b05b7da7c for openssl.org

commit 5b05b7da7c8109c8128dee71ce5ed73eb326fc15
Author: Eugene Syromiatnikov <esyr@openssl.org>
Date:   Mon Jul 20 19:10:23 2026 +0200

    Rename ASN1_STRING_length_ex() to ASN1_STRING_get_length()

    To make it in line with ASN1_BIT_STRING_get_length() and other (size)
    getters.  The majority of the changes was done by

        for i in `git grep -l ASN1_STRING_length_ex`; do \
            sed -i 's/ASN1_STRING_length_ex/ASN1_STRING_get_length/g' "$i"; \
        done

    with a manual touch-up in util/libcrypto.num.

    Complements: 28179061bfcd "Prepare a now opaque ASN1_STRING for the size_t rapture."
    Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Bob Beck <beck@openssl.org>
    Reviewed-by: Simo Sorce <simo@redhat.com>
    MergeDate: Tue Aug 11 13:56:42 2026
    (Merged from https://github.com/openssl/openssl/pull/32015)

diff --git a/CHANGES.md b/CHANGES.md
index 1bfca49b15..711a2cb380 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -175,7 +175,7 @@ OpenSSL Releases

  *  `ASN1_STRING_set()` and `ASN1_STRING_length()` have been
     deprecated. The replacement functions `ASN1_STRING_set_data()` or
-    `ASN1_STRING_set_string()`, and `ASN1_STRING_length_ex()` should be
+    `ASN1_STRING_set_string()`, and `ASN1_STRING_get_length()` should be
     used in their place. This prepares the ASN1_STRING type to support
     modern size_t length values in the future.

diff --git a/apps/asn1parse.c b/apps/asn1parse.c
index b8449762fe..3f8623edaf 100644
--- a/apps/asn1parse.c
+++ b/apps/asn1parse.c
@@ -273,7 +273,7 @@ int asn1parse_main(int argc, char **argv)
             }
             /* hmm... this is a little evil but it works */
             tmpbuf = ASN1_STRING_get0_data(at->value.asn1_string);
-            tmplen = ASN1_STRING_length_ex(at->value.asn1_string);
+            tmplen = ASN1_STRING_get_length(at->value.asn1_string);
             if (tmplen > INT_MAX) {
                 BIO_puts(bio_err, "ASN.1 string length exceeds INT_MAX\n");
                 ERR_print_errors(bio_err);
diff --git a/apps/ca.c b/apps/ca.c
index c7b5a1c22d..a25661956b 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1080,7 +1080,7 @@ end_of_options:
             X509 *xi = sk_X509_value(cert_sk, i);
             const ASN1_INTEGER *serialNumber = X509_get0_serialNumber(xi);
             const unsigned char *psn = ASN1_STRING_get0_data(serialNumber);
-            const size_t snl = ASN1_STRING_length_ex(serialNumber);
+            const size_t snl = ASN1_STRING_get_length(serialNumber);
             const size_t filen_len = 2 * (snl > 0 ? snl : 1) + sizeof(".pem");
             char *n = new_cert + outdirlen;

@@ -1526,7 +1526,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
             goto end;
         }
         if (type != V_ASN1_BMPSTRING && type != V_ASN1_UTF8STRING) {
-            size_t tmp = ASN1_STRING_length_ex(str);
+            size_t tmp = ASN1_STRING_get_length(str);
             if (tmp > INT_MAX)
                 goto end;
             j = ASN1_PRINTABLE_type(ASN1_STRING_get0_data(str), (int)tmp);
@@ -1906,9 +1906,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
     /* We now just add it to the database as DB_TYPE_VAL('V') */
     row[DB_type] = OPENSSL_strdup("V");
     tm = X509_get0_notAfter(ret);
-    row[DB_exp_date] = app_malloc(ASN1_STRING_length_ex(tm) + 1, "row expdate");
-    memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_length_ex(tm));
-    row[DB_exp_date][ASN1_STRING_length_ex(tm)] = '\0';
+    row[DB_exp_date] = app_malloc(ASN1_STRING_get_length(tm) + 1, "row expdate");
+    memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_get_length(tm));
+    row[DB_exp_date][ASN1_STRING_get_length(tm)] = '\0';
     row[DB_rev_date] = NULL;
     row[DB_file] = OPENSSL_strdup("unknown");
     if ((row[DB_type] == NULL) || (row[DB_file] == NULL)
@@ -2142,9 +2142,9 @@ static int do_revoke(X509 *x509, CA_DB *db, REVINFO_TYPE rev_type,
         /* We now just add it to the database as DB_TYPE_REV('V') */
         row[DB_type] = OPENSSL_strdup("V");
         tm = X509_get0_notAfter(x509);
-        row[DB_exp_date] = app_malloc(ASN1_STRING_length_ex(tm) + 1, "row exp_data");
-        memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_length_ex(tm));
-        row[DB_exp_date][ASN1_STRING_length_ex(tm)] = '\0';
+        row[DB_exp_date] = app_malloc(ASN1_STRING_get_length(tm) + 1, "row exp_data");
+        memcpy(row[DB_exp_date], ASN1_STRING_get0_data(tm), ASN1_STRING_get_length(tm));
+        row[DB_exp_date][ASN1_STRING_get_length(tm)] = '\0';
         row[DB_rev_date] = NULL;
         row[DB_file] = OPENSSL_strdup("unknown");

@@ -2412,7 +2412,7 @@ static char *make_revocation_str(REVINFO_TYPE rev_type, const char *rev_arg)
     if (!revtm)
         return NULL;

-    i = ASN1_STRING_length_ex(revtm) + 1;
+    i = ASN1_STRING_get_length(revtm) + 1;

     if (reason)
         i += strlen(reason) + 1;
@@ -2519,7 +2519,7 @@ static int old_entry_print(const ASN1_OBJECT *obj, const ASN1_STRING *str)
         BIO_printf(bio_err, "ASN.1 %2d:'", ASN1_STRING_type(str));

     p = (const char *)ASN1_STRING_get0_data(str);
-    for (j = ASN1_STRING_length_ex(str); j > 0; j--) {
+    for (j = ASN1_STRING_get_length(str); j > 0; j--) {
         if ((*p >= ' ') && (*p <= '~'))
             BIO_printf(bio_err, "%c", *p);
         else if (*p & 0x80)
diff --git a/apps/cms.c b/apps/cms.c
index b7f3394571..c52a4d1b18 100644
--- a/apps/cms.c
+++ b/apps/cms.c
@@ -1584,7 +1584,7 @@ static void receipt_request_print(CMS_ContentInfo *cms)
             CMS_ReceiptRequest_get0_values(rr, &scid, &allorfirst,
                 &rlist, &rto);
             BIO_puts(bio_err, "  Signed Content ID:\n");
-            idlen = ASN1_STRING_length_ex(scid);
+            idlen = ASN1_STRING_get_length(scid);
             if (idlen > INT_MAX)
                 idlen = INT_MAX;
             id = (const char *)ASN1_STRING_get0_data(scid);
diff --git a/apps/lib/apps.c b/apps/lib/apps.c
index 5d082992ec..3b792b5768 100644
--- a/apps/lib/apps.c
+++ b/apps/lib/apps.c
@@ -2830,7 +2830,7 @@ static const char *get_dp_url(DIST_POINT *dp)
     for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
         gen = sk_GENERAL_NAME_value(gens, i);
         uri = GENERAL_NAME_get0_value(gen, &gtype);
-        if (gtype == GEN_URI && ASN1_STRING_length_ex(uri) > 6) {
+        if (gtype == GEN_URI && ASN1_STRING_get_length(uri) > 6) {
             const char *uptr = (const char *)ASN1_STRING_get0_data(uri);

             if (IS_HTTP(uptr)) /* can/should not use HTTPS here */
@@ -3719,7 +3719,7 @@ int has_stdin_waiting(void)
 int corrupt_signature(ASN1_STRING *signature)
 {
     const unsigned char *valid = ASN1_STRING_get0_data(signature);
-    size_t length = ASN1_STRING_length_ex(signature);
+    size_t length = ASN1_STRING_get_length(signature);
     unsigned char *s = OPENSSL_memdup(valid, length);

     if (s == NULL)
diff --git a/apps/lib/cmp_mock_srv.c b/apps/lib/cmp_mock_srv.c
index 825a2b6709..c538c04d28 100644
--- a/apps/lib/cmp_mock_srv.c
+++ b/apps/lib/cmp_mock_srv.c
@@ -360,7 +360,7 @@ static OSSL_CMP_PKISI *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx,
                     ERR_raise(ERR_LIB_CMP, ERR_R_PASSED_INVALID_ARGUMENT);
                     return NULL;
                 }
-                if (((len = ASN1_STRING_length_ex(str)) != sizeof("profile1") - 1)
+                if (((len = ASN1_STRING_get_length(str)) != sizeof("profile1") - 1)
                     || memcmp(data, "profile1", len) != 0) {
                     ERR_raise(ERR_LIB_CMP, CMP_R_UNEXPECTED_CERTPROFILE);
                     return NULL;
diff --git a/apps/pkcs12.c b/apps/pkcs12.c
index e37aefc7a3..7c2c77d4ff 100644
--- a/apps/pkcs12.c
+++ b/apps/pkcs12.c
@@ -833,7 +833,7 @@ int pkcs12_main(int argc, char **argv)
                     ASN1_INTEGER_get(pbkdf2_param->iter));
                 BIO_printf(bio_err, "Key length: %ld, Salt length: %d\n",
                     ASN1_INTEGER_get(pbkdf2_param->keylength),
-                    (int)ASN1_STRING_length_ex(pbkdf2_param->salt->value.octet_string));
+                    (int)ASN1_STRING_get_length(pbkdf2_param->salt->value.octet_string));
                 if (pbkdf2_param->prf == NULL) {
                     prfnid = NID_hmacWithSHA1;
                 } else {
@@ -847,8 +847,8 @@ int pkcs12_main(int argc, char **argv)
             BIO_printf(bio_err, ", Iteration %ld\n",
                 tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L);
             BIO_printf(bio_err, "MAC length: %ld, salt length: %ld\n",
-                tmac != NULL ? (long)ASN1_STRING_length_ex(tmac) : 0L,
-                tsalt != NULL ? (long)ASN1_STRING_length_ex(tsalt) : 0L);
+                tmac != NULL ? (long)ASN1_STRING_get_length(tmac) : 0L,
+                tsalt != NULL ? (long)ASN1_STRING_get_length(tsalt) : 0L);
         }
     }

@@ -1231,7 +1231,7 @@ static int alg_print(const X509_ALGOR *alg)
             }
             BIO_printf(bio_err, ", Salt length: %d, Cost(N): %ld, "
                                 "Block size(r): %ld, Parallelism(p): %ld",
-                (int)ASN1_STRING_length_ex(kdf->salt),
+                (int)ASN1_STRING_get_length(kdf->salt),
                 ASN1_INTEGER_get(kdf->costParameter),
                 ASN1_INTEGER_get(kdf->blockSize),
                 ASN1_INTEGER_get(kdf->parallelizationParameter));
@@ -1282,25 +1282,25 @@ void print_attribute(BIO *out, const ASN1_TYPE *av)
     switch (av->type) {
     case V_ASN1_BMPSTRING:
         value = OPENSSL_uni2asc(ASN1_STRING_get0_data(av->value.bmpstring),
-            (int)ASN1_STRING_length_ex(av->value.bmpstring));
+            (int)ASN1_STRING_get_length(av->value.bmpstring));
         BIO_printf(out, "%s\n", value);
         OPENSSL_free(value);
         break;

     case V_ASN1_UTF8STRING:
-        BIO_printf(out, "%.*s\n", (int)ASN1_STRING_length_ex(av->value.utf8string),
+        BIO_printf(out, "%.*s\n", (int)ASN1_STRING_get_length(av->value.utf8string),
             ASN1_STRING_get0_data(av->value.utf8string));
         break;

     case V_ASN1_OCTET_STRING:
         hex_print(out, ASN1_STRING_get0_data(av->value.octet_string),
-            (int)ASN1_STRING_length_ex(av->value.octet_string));
+            (int)ASN1_STRING_get_length(av->value.octet_string));
         BIO_puts(out, "\n");
         break;

     case V_ASN1_BIT_STRING:
         hex_print(out, ASN1_STRING_get0_data(av->value.bit_string),
-            (int)ASN1_STRING_length_ex(av->value.bit_string));
+            (int)ASN1_STRING_get_length(av->value.bit_string));
         BIO_puts(out, "\n");
         break;

diff --git a/apps/s_client.c b/apps/s_client.c
index d64a2aa4e3..3817a6cc63 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -3097,7 +3097,7 @@ re_start:
             BIO_puts(bio_err, "ASN1_generate_nconf failed\n");
             goto end;
         }
-        ssl_request_len = ASN1_STRING_length_ex(atyp->value.sequence);
+        ssl_request_len = ASN1_STRING_get_length(atyp->value.sequence);
         if (ssl_request_len > INT_MAX) {
             NCONF_free(cnf);
             ASN1_TYPE_free(atyp);
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 4b9e720bad..396fb0258e 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -512,7 +512,7 @@ int ASN1_STRING_length(const ASN1_STRING *x)
 }
 #endif

-size_t ASN1_STRING_length_ex(const ASN1_STRING *x)
+size_t ASN1_STRING_get_length(const ASN1_STRING *x)
 {
     return (size_t)x->length;
 }
@@ -552,7 +552,7 @@ char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text,
         current = sk_ASN1_UTF8STRING_value(text, i);
         if (i > 0)
             length += sep_len;
-        length += ASN1_STRING_length_ex(current);
+        length += ASN1_STRING_get_length(current);
         if (max_len != 0 && length > max_len)
             return NULL;
     }
@@ -562,7 +562,7 @@ char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text,
     p = result;
     for (i = 0; i < sk_ASN1_UTF8STRING_num(text); i++) {
         current = sk_ASN1_UTF8STRING_value(text, i);
-        length = ASN1_STRING_length_ex(current);
+        length = ASN1_STRING_get_length(current);
         if (i > 0 && sep_len > 0) {
             strncpy(p, sep, sep_len + 1); /* using + 1 to silence gcc warning */
             p += sep_len;
diff --git a/crypto/asn1/evp_asn1.c b/crypto/asn1/evp_asn1.c
index 2f081e56d3..721d80b9f6 100644
--- a/crypto/asn1/evp_asn1.c
+++ b/crypto/asn1/evp_asn1.c
@@ -42,7 +42,7 @@ int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_l
         return -1;
     }
     p = ASN1_STRING_get0_data(a->value.octet_string);
-    tmp = ASN1_STRING_length_ex(a->value.octet_string);
+    tmp = ASN1_STRING_get_length(a->value.octet_string);
     if (tmp > INT_MAX) {
         ERR_raise(ERR_LIB_ASN1, ASN1_R_TOO_LARGE);
         return -1;
@@ -82,7 +82,7 @@ static int asn1_type_get_int_oct(ASN1_OCTET_STRING *oct, int32_t anum,
     if (num != NULL)
         *num = anum;

-    tmp = ASN1_STRING_length_ex(oct);
+    tmp = ASN1_STRING_get_length(oct);

     if (tmp > INT_MAX)
         tmp = INT_MAX;
diff --git a/crypto/asn1/p8_pkey.c b/crypto/asn1/p8_pkey.c
index 77f03e82ef..a79d1fe6b0 100644
--- a/crypto/asn1/p8_pkey.c
+++ b/crypto/asn1/p8_pkey.c
@@ -72,13 +72,13 @@ int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,
     const unsigned char **pk, int *ppklen,
     const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8)
 {
-    if (ASN1_STRING_length_ex(p8->pkey) > INT_MAX)
+    if (ASN1_STRING_get_length(p8->pkey) > INT_MAX)
         return 0;
     if (ppkalg)
         *ppkalg = p8->pkeyalg->algorithm;
     if (pk) {
         *pk = ASN1_STRING_get0_data(p8->pkey);
-        *ppklen = (int)ASN1_STRING_length_ex(p8->pkey);
+        *ppklen = (int)ASN1_STRING_get_length(p8->pkey);
     }
     if (pa)
         *pa = p8->pkeyalg;
diff --git a/crypto/cmp/cmp_protect.c b/crypto/cmp/cmp_protect.c
index c0dba8392d..f7460434b1 100644
--- a/crypto/cmp/cmp_protect.c
+++ b/crypto/cmp/cmp_protect.c
@@ -73,11 +73,11 @@ ASN1_BIT_STRING *ossl_cmp_calc_protection(const OSSL_CMP_CTX *ctx,

         pbm_str = (ASN1_STRING *)ppval;
         pbm_str_uc = ASN1_STRING_get0_data(pbm_str);
-        if (ASN1_STRING_length_ex(pbm_str) > INT_MAX) {
+        if (ASN1_STRING_get_length(pbm_str) > INT_MAX) {
             ERR_raise(ERR_LIB_CMP, CMP_R_WRONG_ALGORITHM_OID);
             goto end;
         }
-        pbm = d2i_OSSL_CRMF_PBMPARAMETER(NULL, &pbm_str_uc, (long)ASN1_STRING_length_ex(pbm_str));
+        pbm = d2i_OSSL_CRMF_PBMPARAMETER(NULL, &pbm_str_uc, (long)ASN1_STRING_get_length(pbm_str));
         if (pbm == NULL) {
             ERR_raise(ERR_LIB_CMP, CMP_R_WRONG_ALGORITHM_OID);
             goto end;
@@ -85,7 +85,7 @@ ASN1_BIT_STRING *ossl_cmp_calc_protection(const OSSL_CMP_CTX *ctx,

         if (!OSSL_CRMF_pbm_new(ctx->libctx, ctx->propq,
                 pbm, prot_part_der, prot_part_der_len,
-                ASN1_STRING_get0_data(ctx->secretValue), ASN1_STRING_length_ex(ctx->secretValue),
+                ASN1_STRING_get0_data(ctx->secretValue), ASN1_STRING_get_length(ctx->secretValue),
                 &protection, &sig_len))
             goto end;

diff --git a/crypto/cmp/cmp_status.c b/crypto/cmp/cmp_status.c
index 063bbe808c..bb5fb97897 100644
--- a/crypto/cmp/cmp_status.c
+++ b/crypto/cmp/cmp_status.c
@@ -214,7 +214,7 @@ static char *snprint_PKIStatusInfo_parts(int status, int fail_info,
         for (i = 0; i < n_status_strings; i++) {
             text = sk_ASN1_UTF8STRING_value(status_strings, i);
             printed_chars = BIO_snprintf(write_ptr, bufsize, "\"%.*s\"%s",
-                (int)ASN1_STRING_length_ex(text),
+                (int)ASN1_STRING_get_length(text),
                 ASN1_STRING_get0_data(text),
                 i < n_status_strings - 1 ? ", " : "");
             ADVANCE_BUFFER;
diff --git a/crypto/cms/cms_dh.c b/crypto/cms/cms_dh.c
index 03cef7455a..a280aa719e 100644
--- a/crypto/cms/cms_dh.c
+++ b/crypto/cms/cms_dh.c
@@ -43,7 +43,7 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
         goto err;

     /* Get public key */
-    plen = ASN1_STRING_length_ex(pubkey);
+    plen = ASN1_STRING_get_length(pubkey);
     if (plen > INT_MAX)
         goto err;
     p = ASN1_STRING_get0_data(pubkey);
@@ -121,7 +121,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
         goto err;

     p = ASN1_STRING_get0_data(parameter);
-    plen = ASN1_STRING_length_ex(parameter);
+    plen = ASN1_STRING_get_length(parameter);
     if (plen > INT_MAX)
         goto err;
     kekalg = d2i_X509_ALGOR(NULL, &p, (int)plen);
@@ -153,7 +153,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
         goto err;

     if (ukm != NULL) {
-        dukmlen = ASN1_STRING_length_ex(ukm);
+        dukmlen = ASN1_STRING_get_length(ukm);
         if (dukmlen > INT_MAX)
             goto err;
         dukm = OPENSSL_memdup(ASN1_STRING_get0_data(ukm), (int)dukmlen);
@@ -307,7 +307,7 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri)
         goto err;

     if (ukm != NULL) {
-        dukmlen = ASN1_STRING_length_ex(ukm);
+        dukmlen = ASN1_STRING_get_length(ukm);
         if (dukmlen > INT_MAX)
             goto err;
         dukm = OPENSSL_memdup(ASN1_STRING_get0_data(ukm), dukmlen);
diff --git a/crypto/cms/cms_ec.c b/crypto/cms/cms_ec.c
index 98ab266779..01c9bbc505 100644
--- a/crypto/cms/cms_ec.c
+++ b/crypto/cms/cms_ec.c
@@ -106,7 +106,7 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
             goto err;
     }
     /* We have parameters now set public key */
-    plen = ASN1_STRING_length_ex(pubkey);
+    plen = ASN1_STRING_get_length(pubkey);
     if (plen > INT_MAX)
         goto err;
     p = ASN1_STRING_get0_data(pubkey);
@@ -189,7 +189,7 @@ static int ecdh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
         return 0;

     p = ASN1_STRING_get0_data(parameter);
-    plen = ASN1_STRING_length_ex(parameter);
+    plen = ASN1_STRING_get_length(parameter);
     if (plen > INT_MAX)
         goto err;
     kekalg = d2i_X509_ALGOR(NULL, &p, (int)plen);
diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c
index c29e2019ee..f03fea6f75 100644
--- a/crypto/cms/cms_env.c
+++ b/crypto/cms/cms_env.c
@@ -286,7 +286,7 @@ BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data,
     }

     if (secret != NULL
-        && (secret_len = ASN1_STRING_length_ex(secret)) > INT_MAX)
+        && (secret_len = ASN1_STRING_get_length(secret)) > INT_MAX)
         return NULL;

     if ((ci = CMS_ContentInfo_new_ex(libctx, propq)) == NULL
diff --git a/crypto/cms/cms_kemri.c b/crypto/cms/cms_kemri.c
index ba5311f8ab..419ce3e437 100644
--- a/crypto/cms/cms_kemri.c
+++ b/crypto/cms/cms_kemri.c
@@ -391,7 +391,7 @@ int ossl_cms_RecipientInfo_kemri_decrypt(const CMS_ContentInfo *cms,
         goto err;

     kem_ct = ASN1_STRING_get0_data(kemri->kemct);
-    kem_ct_len = ASN1_STRING_length_ex(kemri->kemct);
+    kem_ct_len = ASN1_STRING_get_length(kemri->kemct);

     if (EVP_PKEY_decapsulate(kemri->pctx, NULL, &kem_secret_len, kem_ct, kem_ct_len) <= 0)
         return 0;
diff --git a/crypto/cms/cms_rsa.c b/crypto/cms/cms_rsa.c
index 1b351f6cd1..82931a7f0f 100644
--- a/crypto/cms/cms_rsa.c
+++ b/crypto/cms/cms_rsa.c
@@ -90,7 +90,7 @@ static int rsa_cms_decrypt(CMS_RecipientInfo *ri)
         }

         label = ASN1_STRING_get0_data(parameter);
-        labellen = ASN1_STRING_length_ex(parameter);
+        labellen = ASN1_STRING_get_length(parameter);
         if (labellen > INT_MAX)
             goto err;
     }
diff --git a/crypto/ct/ct_oct.c b/crypto/ct/ct_oct.c
index 4f5fd8d027..3f1666baa1 100644
--- a/crypto/ct/ct_oct.c
+++ b/crypto/ct/ct_oct.c
@@ -381,7 +381,7 @@ STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
         return NULL;

     p = ASN1_STRING_get0_data(oct);
-    if ((sk = o2i_SCT_LIST(a, &p, ASN1_STRING_length_ex(oct))) != NULL)
+    if ((sk = o2i_SCT_LIST(a, &p, ASN1_STRING_get_length(oct))) != NULL)
         *pp += len;

     ASN1_OCTET_STRING_free(oct);
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c
index 835f759935..ab9ab45ed8 100644
--- a/crypto/ec/ec_asn1.c
+++ b/crypto/ec/ec_asn1.c
@@ -966,7 +966,7 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)

     if (priv_key->privateKey) {
         ASN1_OCTET_STRING *pkey = priv_key->privateKey;
-        size_t pkey_len = ASN1_STRING_length_ex(pkey);
+        size_t pkey_len = ASN1_STRING_get_length(pkey);
         if (pkey_len > INT_MAX)
             goto err;
         if (EC_KEY_oct2priv(ret, ASN1_STRING_get0_data(pkey), (int)pkey_len) == 0)
@@ -991,7 +991,7 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
         size_t pub_oct_len;

         pub_oct = ASN1_STRING_get0_data(priv_key->publicKey);
-        pub_oct_len = ASN1_STRING_length_ex(priv_key->publicKey);
+        pub_oct_len = ASN1_STRING_get_length(priv_key->publicKey);
         if (pub_oct_len > INT_MAX)
             goto err;
         if (!EC_KEY_oct2key(ret, pub_oct, (int)pub_oct_len, NULL)) {
diff --git a/crypto/ec/ecx_backend.c b/crypto/ec/ecx_backend.c
index d95e8bb084..ad56fa0fea 100644
--- a/crypto/ec/ecx_backend.c
+++ b/crypto/ec/ecx_backend.c
@@ -239,7 +239,7 @@ ECX_KEY *ossl_ecx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf,
     } else {
         size_t tmp;
         p = ASN1_STRING_get0_data(oct);
-        tmp = ASN1_STRING_length_ex(oct);
+        tmp = ASN1_STRING_get_length(oct);
         if (tmp > INT_MAX)
             goto err;
         plen = (int)tmp;
diff --git a/crypto/ocsp/ocsp_srv.c b/crypto/ocsp/ocsp_srv.c
index fa99da8a7f..9e77dcff74 100644
--- a/crypto/ocsp/ocsp_srv.c
+++ b/crypto/ocsp/ocsp_srv.c
@@ -301,7 +301,7 @@ int OCSP_RESPID_match_ex(OCSP_RESPID *respid, X509 *cert, OSSL_LIB_CTX *libctx,
         if (!X509_pubkey_digest(cert, sha1, md, NULL))
             goto err;

-        ret = (ASN1_STRING_length_ex(respid->value.byKey) == SHA_DIGEST_LENGTH)
+        ret = (ASN1_STRING_get_length(respid->value.byKey) == SHA_DIGEST_LENGTH)
             && (memcmp(ASN1_STRING_get0_data(respid->value.byKey), md,
                     SHA_DIGEST_LENGTH)
                 == 0);
diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c
index 60843bd951..6720349d8d 100644
--- a/crypto/pkcs12/p12_mutl.c
+++ b/crypto/pkcs12/p12_mutl.c
@@ -350,7 +350,7 @@ int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen)
         }
     }
     X509_SIG_get0(p12->mac->dinfo, NULL, &macoct);
-    if ((maclen != ASN1_STRING_length_ex(macoct))
+    if ((maclen != ASN1_STRING_get_length(macoct))
         || CRYPTO_memcmp(mac, ASN1_STRING_get0_data(macoct), maclen) != 0)
         return 0;

diff --git a/crypto/pkcs7/pk7_attr.c b/crypto/pkcs7/pk7_attr.c
index 28f073f36f..af0c755e90 100644
--- a/crypto/pkcs7/pk7_attr.c
+++ b/crypto/pkcs7/pk7_attr.c
@@ -30,7 +30,7 @@ int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
     }
     seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data,
         ASN1_ITEM_rptr(X509_ALGORS));
-    if (ASN1_STRING_length_ex(seq) == 0 || ASN1_STRING_get0_data(seq) == NULL) {
+    if (ASN1_STRING_get_length(seq) == 0 || ASN1_STRING_get0_data(seq) == NULL) {
         ASN1_STRING_free(seq);
         return 1;
     }
@@ -52,7 +52,7 @@ STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si)
     if (cap == NULL || (cap->type != V_ASN1_SEQUENCE))
         return NULL;
     p = ASN1_STRING_get0_data(cap->value.sequence);
-    len = ASN1_STRING_length_ex(cap->value.sequence);
+    len = ASN1_STRING_get_length(cap->value.sequence);
     if (len > INT_MAX)
         return NULL;
     return (STACK_OF(X509_ALGOR) *)
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index 33d2eaafdf..6df6dcebc8 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -74,13 +74,13 @@ static ASN1_OCTET_STRING *pkcs7_get1_data(PKCS7 *p7)
     if (PKCS7_type_is_other(p7) && (p7->d.other != NULL)
         && (p7->d.other->type == V_ASN1_SEQUENCE)
         && (p7->d.other->value.sequence != NULL)
-        && (ASN1_STRING_length_ex(p7->d.other->value.sequence) > 0)) {
+        && (ASN1_STRING_get_length(p7->d.other->value.sequence) > 0)) {
         const unsigned char *data = ASN1_STRING_get0_data(p7->d.other->value.sequence);
         long len;
         int inf, tag, class;
         size_t tmp;

-        tmp = ASN1_STRING_length_ex(p7->d.other->value.sequence);
+        tmp = ASN1_STRING_get_length(p7->d.other->value.sequence);
         if (tmp > INT_MAX)
             return NULL;
         os = ASN1_OCTET_STRING_new();
@@ -201,7 +201,7 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
         goto err;

     ret = evp_pkey_decrypt_alloc(pctx, &ek, &eklen, fixlen,
-        ASN1_STRING_get0_data(ri->enc_key), ASN1_STRING_length_ex(ri->enc_key));
+        ASN1_STRING_get0_data(ri->enc_key), ASN1_STRING_get_length(ri->enc_key));
     if (ret <= 0)
         goto err;

@@ -374,7 +374,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
     if (bio == NULL) {
         if (PKCS7_is_detached(p7)) {
             bio = BIO_new(BIO_s_null());
-        } else if (os != NULL && ASN1_STRING_length_ex(os) > 0) {
+        } else if (os != NULL && ASN1_STRING_get_length(os) > 0) {
             /*
              * bio needs a copy of os->data instead of a pointer because
              * the data will be used after os has been freed
@@ -383,7 +383,7 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
             if (bio != NULL) {
                 BIO_set_mem_eof_return(bio, 0);
                 const unsigned char *os_data = ASN1_STRING_get0_data(os);
-                size_t os_len = ASN1_STRING_length_ex(os);
+                size_t os_len = ASN1_STRING_get_length(os);
                 if (os_len > INT_MAX || BIO_write(bio, os_data, (int)os_len) != (int)os_len) {
                     BIO_free_all(bio);
                     bio = NULL;
@@ -659,7 +659,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
     if (in_bio != NULL) {
         bio = in_bio;
     } else {
-        size_t data_body_len = ASN1_STRING_length_ex(data_body);
+        size_t data_body_len = ASN1_STRING_get_length(data_body);
         if (data_body_len > INT_MAX)
             goto err;
         if (data_body_len > 0)
@@ -1115,7 +1115,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
             ERR_raise(ERR_LIB_PKCS7, PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST);
             goto err;
         }
-        if ((ASN1_STRING_length_ex(message_digest) != md_len)
+        if ((ASN1_STRING_get_length(message_digest) != md_len)
             || (memcmp(ASN1_STRING_get0_data(message_digest), md_dat, md_len))) {
             ERR_raise(ERR_LIB_PKCS7, PKCS7_R_DIGEST_FAILURE);
             ret = -1;
@@ -1147,7 +1147,7 @@ int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
     }

     const unsigned char *sig_data = ASN1_STRING_get0_data(os);
-    size_t sig_len = ASN1_STRING_length_ex(os);
+    size_t sig_len = ASN1_STRING_get_length(os);
     if (sig_len > INT_MAX) {
         ret = -1;
         goto err;
diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c
index 6bd33245d1..b595ebe026 100644
--- a/crypto/pkcs7/pk7_smime.c
+++ b/crypto/pkcs7/pk7_smime.c
@@ -212,7 +212,7 @@ static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si)

     if (osdig != NULL) {
         size_t len;
-        len = ASN1_STRING_length_ex(osdig);
+        len = ASN1_STRING_get_length(osdig);
         if (len > INT_MAX)
             goto err;
         return PKCS7_add1_attrib_digest(si, ASN1_STRING_get0_data(osdig), (int)len);
diff --git a/crypto/sm2/sm2_crypt.c b/crypto/sm2/sm2_crypt.c
index 6e787f5d28..7aa8ecb682 100644
--- a/crypto/sm2/sm2_crypt.c
+++ b/crypto/sm2/sm2_crypt.c
@@ -78,7 +78,7 @@ int ossl_sm2_plaintext_size(const unsigned char *ct, size_t ct_size,
         return 0;
     }

-    *pt_size = ASN1_STRING_length_ex(sm2_ctext->C2);
+    *pt_size = ASN1_STRING_get_length(sm2_ctext->C2);
     SM2_Ciphertext_free(sm2_ctext);

     return 1;
@@ -326,11 +326,11 @@ int ossl_sm2_decrypt(const EC_KEY *key,
         goto done;
     }

-    msg_len = ASN1_STRING_length_ex(sm2_ctext->C2);
+    msg_len = ASN1_STRING_get_length(sm2_ctext->C2);
     if (msg_len > INT_MAX)
         goto done;

-    c3_len = ASN1_STRING_length_ex(sm2_ctext->C3);
+    c3_len = ASN1_STRING_get_length(sm2_ctext->C3);
     if (c3_len > INT_MAX || c3_len != (size_t)hash_size) {
         ERR_raise(ERR_LIB_SM2, SM2_R_INVALID_ENCODING);
         goto done;
diff --git a/crypto/ts/ts_asn1.c b/crypto/ts/ts_asn1.c
index 56d41df554..1aa21c9776 100644
--- a/crypto/ts/ts_asn1.c
+++ b/crypto/ts/ts_asn1.c
@@ -231,7 +231,7 @@ TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token)
     }
     tst_info_der = tst_info_wrapper->value.octet_string;
     p = ASN1_STRING_get0_data(tst_info_der);
-    len = ASN1_STRING_length_ex(tst_info_der);
+    len = ASN1_STRING_get_length(tst_info_der);
     if (len > INT_MAX) {
         ERR_raise(ERR_LIB_TS, TS_R_BAD_TYPE);
         return NULL;
diff --git a/crypto/ts/ts_lib.c b/crypto/ts/ts_lib.c
index 26b3994ccb..00b4035551 100644
--- a/crypto/ts/ts_lib.c
+++ b/crypto/ts/ts_lib.c
@@ -86,7 +86,7 @@ int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *a)
     BIO_printf(bio, "Message data:\n");
     msg = a->hashed_msg;
     BIO_dump_indent(bio, (const char *)ASN1_STRING_get0_data(msg),
-        (int)ASN1_STRING_length_ex(msg), 4);
+        (int)ASN1_STRING_get_length(msg), 4);

     return 1;
 }
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c
index e9151f750e..0931fdf21c 100644
--- a/crypto/ts/ts_rsp_sign.c
+++ b/crypto/ts/ts_rsp_sign.c
@@ -487,7 +487,7 @@ static int ts_RESP_check_request(TS_RESP_CTX *ctx)
         return 0;
     }
     digest = msg_imprint->hashed_msg;
-    if (ASN1_STRING_length_ex(digest) != (size_t)md_size) {
+    if (ASN1_STRING_get_length(digest) != (size_t)md_size) {
         TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
             "Bad message digest.");
         TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_DATA_FORMAT);
diff --git a/crypto/ts/ts_rsp_verify.c b/crypto/ts/ts_rsp_verify.c
index 1b45243ca8..5210df04c5 100644
--- a/crypto/ts/ts_rsp_verify.c
+++ b/crypto/ts/ts_rsp_verify.c
@@ -213,7 +213,7 @@ static ESS_SIGNING_CERT *ossl_ess_get_signing_cert(const PKCS7_SIGNER_INFO *si)
     if (attr == NULL || attr->type != V_ASN1_SEQUENCE)
         return NULL;
     p = ASN1_STRING_get0_data(attr->value.sequence);
-    len = ASN1_STRING_length_ex(attr->value.sequence);
+    len = ASN1_STRING_get_length(attr->value.sequence);
     if (len > INT_MAX)
         return NULL;
     return d2i_ESS_SIGNING_CERT(NULL, &p, (int)len);
@@ -229,7 +229,7 @@ static ESS_SIGNING_CERT_V2 *ossl_ess_get_signing_cert_v2(const PKCS7_SIGNER_INFO
     if (attr == NULL || attr->type != V_ASN1_SEQUENCE)
         return NULL;
     p = ASN1_STRING_get0_data(attr->value.sequence);
-    len = ASN1_STRING_length_ex(attr->value.sequence);
+    len = ASN1_STRING_get_length(attr->value.sequence);
     if (len > INT_MAX)
         return NULL;
     return d2i_ESS_SIGNING_CERT_V2(NULL, &p, (int)len);
@@ -504,7 +504,7 @@ static int ts_check_imprints(X509_ALGOR *algor_a,
             goto err;
     }

-    len = ASN1_STRING_length_ex(b->hashed_msg);
+    len = ASN1_STRING_get_length(b->hashed_msg);
     if (len > INT_MAX)
         goto err;

diff --git a/crypto/ts/ts_verify_ctx.c b/crypto/ts/ts_verify_ctx.c
index 76835866d7..5343b8714e 100644
--- a/crypto/ts/ts_verify_ctx.c
+++ b/crypto/ts/ts_verify_ctx.c
@@ -163,7 +163,7 @@ TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx)
     if ((ret->md_alg = X509_ALGOR_dup(md_alg)) == NULL)
         goto err;
     msg = imprint->hashed_msg;
-    tmp = ASN1_STRING_length_ex(msg);
+    tmp = ASN1_STRING_get_length(msg);
     if (tmp > INT_MAX)
         goto err;
     ret->imprint_len = (unsigned int)tmp;
diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c
index abe1b7557d..8e57d9b328 100644
--- a/crypto/x509/t_x509.c
+++ b/crypto/x509/t_x509.c
@@ -244,7 +244,7 @@ int X509_ocspid_print(BIO *bp, const X509 *x)
         goto err;

     if (!EVP_Digest(ASN1_STRING_get0_data(keybstr),
-            ASN1_STRING_length_ex(keybstr), SHA1md, NULL, md, NULL))
+            ASN1_STRING_get_length(keybstr), SHA1md, NULL, md, NULL))
         goto err;
     for (i = 0; i < SHA_DIGEST_LENGTH; i++) {
         if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0)
diff --git a/crypto/x509/v3_akid.c b/crypto/x509/v3_akid.c
index 9ecc22b670..dc660a42b0 100644
--- a/crypto/x509/v3_akid.c
+++ b/crypto/x509/v3_akid.c
@@ -189,7 +189,7 @@ static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
                 goto err;

             /* Ignore empty keyids in the issuer cert */
-            if (ASN1_STRING_length_ex(ikeyid) == 0) {
+            if (ASN1_STRING_get_length(ikeyid) == 0) {
                 ASN1_OCTET_STRING_free(ikeyid);
                 ikeyid = NULL;
             }
diff --git a/crypto/x509/v3_lib.c b/crypto/x509/v3_lib.c
index a099177dba..a4b46d0924 100644
--- a/crypto/x509/v3_lib.c
+++ b/crypto/x509/v3_lib.c
@@ -175,7 +175,7 @@ void *X509V3_EXT_d2i(const X509_EXTENSION *ext)
         return NULL;
     extvalue = X509_EXTENSION_get_data(ext);
     p = ASN1_STRING_get0_data(extvalue);
-    extlen = ASN1_STRING_length_ex(extvalue);
+    extlen = ASN1_STRING_get_length(extvalue);
     if (extlen > INT_MAX)
         return NULL;
     if (method->it)
diff --git a/crypto/x509/v3_prn.c b/crypto/x509/v3_prn.c
index 0fb7c9e38a..e890183134 100644
--- a/crypto/x509/v3_prn.c
+++ b/crypto/x509/v3_prn.c
@@ -80,7 +80,7 @@ int X509V3_EXT_print(BIO *out, const X509_EXTENSION *ext, unsigned long flag,

     extoct = X509_EXTENSION_get_data(ext);
     p = ASN1_STRING_get0_data(extoct);
-    extlen = ASN1_STRING_length_ex(extoct);
+    extlen = ASN1_STRING_get_length(extoct);
     if (extlen > INT_MAX)
         return 0;

diff --git a/doc/man3/ASN1_STRING_length.pod b/doc/man3/ASN1_STRING_length.pod
index 5b047f084a..cfe08430db 100644
--- a/doc/man3/ASN1_STRING_length.pod
+++ b/doc/man3/ASN1_STRING_length.pod
@@ -2,7 +2,7 @@

 =head1 NAME

-ASN1_STRING_set_data, ASN1_STRING_set_string, ASN1_STRING_length_ex,
+ASN1_STRING_set_data, ASN1_STRING_set_string, ASN1_STRING_get_length,
 ASN1_STRING_dup, ASN1_STRING_cmp, ASN1_STRING_set, ASN1_STRING_length,
 ASN1_STRING_type, ASN1_STRING_get0_data,
 ASN1_STRING_to_UTF8 - ASN1_STRING utility functions
@@ -25,7 +25,7 @@ ASN1_STRING_to_UTF8 - ASN1_STRING utility functions

  int ASN1_STRING_set_string(ASN1_STRING *str, const char *data);

- size_t ASN1_STRING_length_ex(const ASN1_STRING *x);
+ size_t ASN1_STRING_get_length(const ASN1_STRING *x);

 The following functions have been deprecated since OpenSSL 4.1, and can be
 hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
@@ -129,7 +129,7 @@ L<ERR_get_error(3)>

 =head1 HISTORY

-ASN1_STRING_set_data(), ASN1_STRING_set_string(), and ASN1_STRING_length_ex()
+ASN1_STRING_set_data(), ASN1_STRING_set_string(), and ASN1_STRING_get_length()
 were added in OpenSSL 4.1.

 =head1 COPYRIGHT
diff --git a/include/openssl/asn1.h.in b/include/openssl/asn1.h.in
index 440a6b3766..5b529333c5 100644
--- a/include/openssl/asn1.h.in
+++ b/include/openssl/asn1.h.in
@@ -543,13 +543,13 @@ int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
 #if !defined(OPENSSL_NO_DEPRECATED_4_1)
 OSSL_DEPRECATEDIN_4_1_FOR(" Use ASN1_STRING_set_data() or ASN1_STRING_set_string() instead.")
 int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
-OSSL_DEPRECATEDIN_4_1_FOR(" Use ASN1_STRING_length_ex() instead.")
+OSSL_DEPRECATEDIN_4_1_FOR(" Use ASN1_STRING_get_length() instead.")
 int ASN1_STRING_length(const ASN1_STRING *x);
 #endif /* !defined(OPENSSL_NO_DEPRECATED_4_1) */
 void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
 int ASN1_STRING_set_data(ASN1_STRING *str, const uint8_t *data, size_t len);
 int ASN1_STRING_set_string(ASN1_STRING *str, const char *cstring);
-size_t ASN1_STRING_length_ex(const ASN1_STRING *x);
+size_t ASN1_STRING_get_length(const ASN1_STRING *x);
 #ifndef OPENSSL_NO_DEPRECATED_3_0
 OSSL_DEPRECATEDIN_3_0 void ASN1_STRING_length_set(ASN1_STRING *x, int n);
 #endif
diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c
index 0ac7f24acb..aa7e2b2310 100644
--- a/ssl/statem/statem_srvr.c
+++ b/ssl/statem/statem_srvr.c
@@ -3632,7 +3632,7 @@ static int tls_process_cke_gost(SSL_CONNECTION *s, PACKET *pkt)
         goto err;
     }

-    inlen = ASN1_STRING_length_ex(pKX->kxBlob->value.sequence);
+    inlen = ASN1_STRING_get_length(pKX->kxBlob->value.sequence);
     if (inlen > INT_MAX)
         goto err;

diff --git a/test/asn1_string_test.c b/test/asn1_string_test.c
index 865003eeb9..88c19ae3a5 100644
--- a/test/asn1_string_test.c
+++ b/test/asn1_string_test.c
@@ -416,7 +416,7 @@ asn1_string_new_not_owned_test(void)
     if (!TEST_mem_eq(data, sizeof(data), data2, sizeof(data2)))
         goto err;

-    if (!TEST_size_t_eq(ASN1_STRING_length_ex(tmp), strlen("muppet")))
+    if (!TEST_size_t_eq(ASN1_STRING_get_length(tmp), strlen("muppet")))
         goto err;

     if (!TEST_mem_eq(ASN1_STRING_get0_data(tmp), strlen("muppet"), "muppet", strlen("muppet")))
@@ -436,13 +436,13 @@ asn1_string_new_not_owned_test(void)
     if (!TEST_mem_eq(data, sizeof(data), data2, sizeof(data2)))
         goto err;

-    if (!TEST_size_t_eq(ASN1_STRING_length_ex(tmp), 4))
+    if (!TEST_size_t_eq(ASN1_STRING_get_length(tmp), 4))
         goto err;

     if (!TEST_mem_eq(ASN1_STRING_get0_data(tmp), strlen("puppet"), "puppet", strlen("puppet")))
         goto err;

-    memset((uint8_t *)ASN1_STRING_get0_data(tmp), 'z', ASN1_STRING_length_ex(tmp));
+    memset((uint8_t *)ASN1_STRING_get0_data(tmp), 'z', ASN1_STRING_get_length(tmp));

     if (!TEST_mem_eq(data, sizeof(data), data2, sizeof(data2)))
         goto err;
@@ -498,7 +498,7 @@ asn1_string_set_data_test(void)

     data = ASN1_STRING_get0_data(str);

-    if (!TEST_size_t_eq(ASN1_STRING_length_ex(str), 6))
+    if (!TEST_size_t_eq(ASN1_STRING_get_length(str), 6))
         goto err;

     if (!TEST_int_eq(memcmp("hoobla", data, strlen("hoobla")), 0))
@@ -509,7 +509,7 @@ asn1_string_set_data_test(void)

     data = ASN1_STRING_get0_data(str);

-    if (!TEST_size_t_eq(ASN1_STRING_length_ex(str), 7))
+    if (!TEST_size_t_eq(ASN1_STRING_get_length(str), 7))
         goto err;

     if (!TEST_int_eq(strcmp("hoobla", (char *)data), 0))
@@ -534,13 +534,13 @@ asn1_string_set_string_test(void)
     if (!TEST_true(ASN1_STRING_set_string(str, "foo")))
         goto err;

-    if (!TEST_size_t_eq(ASN1_STRING_length_ex(str), 3))
+    if (!TEST_size_t_eq(ASN1_STRING_get_length(str), 3))
         goto err;

     if (!TEST_true(ASN1_STRING_set_string(str, "hoob\0la")))
         goto err;

-    if (!TEST_size_t_eq(ASN1_STRING_length_ex(str), 4))
+    if (!TEST_size_t_eq(ASN1_STRING_get_length(str), 4))
         goto err;

     success = 1;
diff --git a/test/helpers/pkcs12.c b/test/helpers/pkcs12.c
index 3ecfd020b6..00965686dd 100644
--- a/test/helpers/pkcs12.c
+++ b/test/helpers/pkcs12.c
@@ -468,21 +468,21 @@ static int check_asn1_string(const ASN1_TYPE *av, const char *txt)
     switch (av->type) {
     case V_ASN1_BMPSTRING:
         value = OPENSSL_uni2asc(ASN1_STRING_get0_data(av->value.bmpstring),
-            (int)ASN1_STRING_length_ex(av->value.bmpstring));
+            (int)ASN1_STRING_get_length(av->value.bmpstring));
         if (!TEST_str_eq(txt, (char *)value))
             goto err;
         break;

     case V_ASN1_UTF8STRING:
         if (!TEST_mem_eq(txt, strlen(txt), ASN1_STRING_get0_data(av->value.utf8string),
-                ASN1_STRING_length_ex(av->value.utf8string)))
+                ASN1_STRING_get_length(av->value.utf8string)))
             goto err;
         break;

     case V_ASN1_OCTET_STRING:
         if (!TEST_mem_eq(txt, strlen(txt),
                 (char *)ASN1_STRING_get0_data(av->value.octet_string),
-                ASN1_STRING_length_ex(av->value.octet_string)))
+                ASN1_STRING_get_length(av->value.octet_string)))
             goto err;
         break;

diff --git a/test/tls-provider.c b/test/tls-provider.c
index 34ea1652a0..76fbf72690 100644
--- a/test/tls-provider.c
+++ b/test/tls-provider.c
@@ -1282,7 +1282,7 @@ static XORKEY *xor_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf,
         plen = 0;
     } else {
         p = ASN1_STRING_get0_data(oct);
-        plen = (int)ASN1_STRING_length_ex(oct);
+        plen = (int)ASN1_STRING_get_length(oct);
     }

     xork = xor_key_op(palg, p, plen, KEY_OP_PRIVATE,
diff --git a/test/x509_internal_test.c b/test/x509_internal_test.c
index 85ef13036f..d2d118dd17 100644
--- a/test/x509_internal_test.c
+++ b/test/x509_internal_test.c
@@ -162,7 +162,7 @@ static int test_a2i_ipaddress(int idx)
         }
     } else {
         if (!TEST_ptr(ip)
-            || !TEST_size_t_eq(ASN1_STRING_length_ex(ip), len)
+            || !TEST_size_t_eq(ASN1_STRING_get_length(ip), len)
             || !TEST_mem_eq(ASN1_STRING_get0_data(ip), len,
                 a2i_ipaddress_tests[idx].data, len)) {
             good = 0;
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 0acb162dde..476a6e9671 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -5726,5 +5726,5 @@ EVP_KDF_CTX_get0_kdf                    ?	4_1_0	EXIST::FUNCTION:
 EVP_KDF_CTX_get1_kdf                    ?	4_1_0	EXIST::FUNCTION:
 ASN1_STRING_set_data                    ?	4_1_0	EXIST::FUNCTION:
 ASN1_STRING_set_string                  ?	4_1_0	EXIST::FUNCTION:
-ASN1_STRING_length_ex                   ?	4_1_0	EXIST::FUNCTION:
+ASN1_STRING_get_length                  ?	4_1_0	EXIST::FUNCTION:
 CMS_add_standard_smimecap_ex            ?	4_1_0	EXIST::FUNCTION:CMS