Commit 786353f4c5 for openssl.org

commit 786353f4c56ceadd2f8d8d2351cbd59c89b923f9
Author: Eugene Syromiatnikov <esyr@openssl.org>
Date:   Mon Jul 20 19:18:59 2026 +0200

    Change set suffix in ASN1_STRING_set_{data,string} to set1

    To comply with the naming guidelines for the API functions that transfer
    ownership of the data.  The majority of the changes was done by

        for i in `git grep -l ASN1_STRING_set_data`; do \
            sed -i 's/ASN1_STRING_set_data/ASN1_STRING_set1_data/g' "$i"; \
        done
        for i in `git grep -l ASN1_STRING_set_string`; do \
            sed -i 's/ASN1_STRING_set_string/ASN1_STRING_set1_string/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:44 2026
    (Merged from https://github.com/openssl/openssl/pull/32015)

diff --git a/CHANGES.md b/CHANGES.md
index 711a2cb380..15b07be6be 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -174,8 +174,8 @@ OpenSSL Releases
    *Bob Beck*

  *  `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_get_length()` should be
+    deprecated. The replacement functions `ASN1_STRING_set1_data()` or
+    `ASN1_STRING_set1_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/cmp.c b/apps/cmp.c
index e75ed35a48..278e344b7c 100644
--- a/apps/cmp.c
+++ b/apps/cmp.c
@@ -2140,7 +2140,7 @@ static int add_certProfile(OSSL_CMP_CTX *ctx, const char *name)
         return 0;
     if ((utf8string = ASN1_UTF8STRING_new()) == NULL)
         goto err;
-    if (!ASN1_STRING_set_string(utf8string, name)) {
+    if (!ASN1_STRING_set1_string(utf8string, name)) {
         ASN1_STRING_free(utf8string);
         goto err;
     }
@@ -2215,7 +2215,7 @@ static int handle_opt_geninfo(OSSL_CMP_CTX *ctx)
             else
                 *end++ = '\0';
             if ((text = ASN1_UTF8STRING_new()) == NULL
-                || !ASN1_STRING_set_string(text, ptr))
+                || !ASN1_STRING_set1_string(text, ptr))
                 goto oom;
             ptr = end;
             ASN1_TYPE_set(type, V_ASN1_UTF8STRING, text);
diff --git a/apps/spkac.c b/apps/spkac.c
index 27b2392bb9..9f2d0d0d07 100644
--- a/apps/spkac.c
+++ b/apps/spkac.c
@@ -155,7 +155,7 @@ int spkac_main(int argc, char **argv)
         if (spki == NULL)
             goto end;
         if (challenge != NULL
-            && !ASN1_STRING_set_string(spki->spkac->challenge,
+            && !ASN1_STRING_set1_string(spki->spkac->challenge,
                 challenge))
             goto end;
         if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) {
diff --git a/apps/ts.c b/apps/ts.c
index 2049eb9331..4d5016fcca 100644
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -583,7 +583,7 @@ static ASN1_INTEGER *create_nonce(int bits)
     if ((nonce = ASN1_INTEGER_new()) == NULL)
         goto err;

-    if (!ASN1_STRING_set_data(nonce, buf, len))
+    if (!ASN1_STRING_set1_data(nonce, buf, len))
         goto err;

     ret = nonce;
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c
index 10db6b6a3c..6144ac36fa 100644
--- a/crypto/asn1/a_int.c
+++ b/crypto/asn1/a_int.c
@@ -316,7 +316,7 @@ ASN1_INTEGER *ossl_c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
     } else
         ret = *a;

-    if (ASN1_STRING_set_data(ret, NULL, r) == 0) {
+    if (ASN1_STRING_set1_data(ret, NULL, r) == 0) {
         ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
         goto err;
     }
@@ -371,7 +371,7 @@ static int asn1_string_set_int64(ASN1_STRING *a, int64_t r, int itype)
         off = asn1_put_uint64(tbuf, r);
         a->type &= ~V_ASN1_NEG;
     }
-    return ASN1_STRING_set_data(a, tbuf + off, (sizeof(tbuf) - off));
+    return ASN1_STRING_set1_data(a, tbuf + off, (sizeof(tbuf) - off));
 }

 static int asn1_string_get_uint64(uint64_t *pr, const ASN1_STRING *a,
@@ -399,7 +399,7 @@ static int asn1_string_set_uint64(ASN1_STRING *a, uint64_t r, int itype)

     a->type = itype;
     off = asn1_put_uint64(tbuf, r);
-    return ASN1_STRING_set_data(a, tbuf + off, (sizeof(tbuf) - off));
+    return ASN1_STRING_set1_data(a, tbuf + off, (sizeof(tbuf) - off));
 }

 /*
@@ -503,7 +503,7 @@ static ASN1_STRING *bn_to_asn1_string(const BIGNUM *bn, ASN1_STRING *ai,
     if (len == 0)
         len = 1;

-    if (ASN1_STRING_set_data(ret, NULL, len) == 0) {
+    if (ASN1_STRING_set1_data(ret, NULL, len) == 0) {
         ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
         goto err;
     }
diff --git a/crypto/asn1/a_mbstr.c b/crypto/asn1/a_mbstr.c
index e70fe92db5..7f43b60b87 100644
--- a/crypto/asn1/a_mbstr.c
+++ b/crypto/asn1/a_mbstr.c
@@ -171,7 +171,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
     }
     /* If both the same type just copy across */
     if (inform == outform) {
-        if (!ASN1_STRING_set_data(dest, in, len)) {
+        if (!ASN1_STRING_set1_data(dest, in, len)) {
             if (free_out) {
                 ASN1_STRING_free(dest);
                 *out = NULL;
diff --git a/crypto/asn1/a_octet.c b/crypto/asn1/a_octet.c
index 99df7539a1..27151d841a 100644
--- a/crypto/asn1/a_octet.c
+++ b/crypto/asn1/a_octet.c
@@ -30,6 +30,6 @@ int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
         return 0;
     }
     if (len == -1)
-        return ASN1_STRING_set_string(x, (const char *)d);
-    return ASN1_STRING_set_data(x, d, len);
+        return ASN1_STRING_set1_string(x, (const char *)d);
+    return ASN1_STRING_set1_data(x, d, len);
 }
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c
index 341bd5142d..564df4dd8c 100644
--- a/crypto/asn1/a_time.c
+++ b/crypto/asn1/a_time.c
@@ -271,7 +271,7 @@ ASN1_TIME *ossl_asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)
     if (tmps == NULL)
         return NULL;

-    if (!ASN1_STRING_set_data(tmps, NULL, len))
+    if (!ASN1_STRING_set1_data(tmps, NULL, len))
         goto err;

     tmps->type = type;
diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c
index 6fbf581b49..0cf4f8dcef 100644
--- a/crypto/asn1/asn1_gen.c
+++ b/crypto/asn1/asn1_gen.c
@@ -651,7 +651,7 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
             ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
             goto bad_str;
         }
-        if (!ASN1_STRING_set_string(atmp->value.asn1_string, str)) {
+        if (!ASN1_STRING_set1_string(atmp->value.asn1_string, str)) {
             ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
             goto bad_str;
         }
@@ -706,7 +706,7 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
             atmp->value.asn1_string->length = rdlen;
             atmp->value.asn1_string->type = utype;
         } else if (format == ASN1_GEN_FORMAT_ASCII) {
-            if (!ASN1_STRING_set_string(atmp->value.asn1_string, str)) {
+            if (!ASN1_STRING_set1_string(atmp->value.asn1_string, str)) {
                 ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
                 goto bad_str;
             }
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 396fb0258e..a4d80eaa29 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -381,7 +381,7 @@ void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
     str->length = len;
 }

-int ASN1_STRING_set_data(ASN1_STRING *str, const uint8_t *data, size_t len_in)
+int ASN1_STRING_set1_data(ASN1_STRING *str, const uint8_t *data, size_t len_in)
 {
     if (str->type == V_ASN1_BIT_STRING) {
         ERR_raise(ERR_LIB_ASN1, ASN1_R_ILLEGAL_BITSTRING_FORMAT);
@@ -395,9 +395,9 @@ int ASN1_STRING_set_data(ASN1_STRING *str, const uint8_t *data, size_t len_in)
     return ossl_asn1_string_set_internal(str, data, (int)len_in, /*add_nul_byte=*/0);
 }

-int ASN1_STRING_set_string(ASN1_STRING *str, const char *c_string)
+int ASN1_STRING_set1_string(ASN1_STRING *str, const char *c_string)
 {
-    return ASN1_STRING_set_data(str, (const uint8_t *)c_string,
+    return ASN1_STRING_set1_data(str, (const uint8_t *)c_string,
         strlen(c_string));
 }

diff --git a/crypto/asn1/p5_scrypt.c b/crypto/asn1/p5_scrypt.c
index 9e1b537b9f..6eed32e8e9 100644
--- a/crypto/asn1/p5_scrypt.c
+++ b/crypto/asn1/p5_scrypt.c
@@ -173,7 +173,7 @@ static X509_ALGOR *pkcs5_scrypt_set(const unsigned char *salt, int saltlen,
         saltlen = PKCS5_DEFAULT_PBE2_SALT_LEN;

     /* This will either copy salt or grow the buffer */
-    if (ASN1_STRING_set_data(sparam->salt, salt, saltlen) == 0) {
+    if (ASN1_STRING_set1_data(sparam->salt, salt, saltlen) == 0) {
         ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
         goto err;
     }
diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c
index 911eb42be7..d708e15de1 100644
--- a/crypto/asn1/tasn_dec.c
+++ b/crypto/asn1/tasn_dec.c
@@ -983,7 +983,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, long len,
             ASN1_STRING_set0(stmp, (unsigned char *)cont /* UGLY CAST! */, ilen);
             *free_cont = 0;
         } else {
-            if (!ASN1_STRING_set_data(stmp, cont, len)) {
+            if (!ASN1_STRING_set1_data(stmp, cont, len)) {
                 ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
                 ASN1_STRING_free(stmp);
                 *pval = NULL;
diff --git a/crypto/cmp/cmp_protect.c b/crypto/cmp/cmp_protect.c
index f7460434b1..fa8d128617 100644
--- a/crypto/cmp/cmp_protect.c
+++ b/crypto/cmp/cmp_protect.c
@@ -206,7 +206,7 @@ static X509_ALGOR *pbmac_algor(const OSSL_CMP_CTX *ctx)
         goto err;
     if ((pbm_der_len = i2d_OSSL_CRMF_PBMPARAMETER(pbm, &pbm_der)) < 0)
         goto err;
-    if (!ASN1_STRING_set_data(pbm_str, pbm_der, pbm_der_len))
+    if (!ASN1_STRING_set1_data(pbm_str, pbm_der, pbm_der_len))
         goto err;
     alg = ossl_X509_ALGOR_from_nid(NID_id_PasswordBasedMAC,
         V_ASN1_SEQUENCE, pbm_str);
diff --git a/crypto/cmp/cmp_status.c b/crypto/cmp/cmp_status.c
index bb5fb97897..b13a9a39b0 100644
--- a/crypto/cmp/cmp_status.c
+++ b/crypto/cmp/cmp_status.c
@@ -275,7 +275,7 @@ OSSL_CMP_PKISI *OSSL_CMP_STATUSINFO_new(int status, int fail_info,

     if (text != NULL) {
         if ((utf8_text = ASN1_UTF8STRING_new()) == NULL
-            || !ASN1_STRING_set_string(utf8_text, text))
+            || !ASN1_STRING_set1_string(utf8_text, text))
             goto err;
         if ((si->statusString = sk_ASN1_UTF8STRING_new_null()) == NULL)
             goto err;
diff --git a/crypto/cmp/cmp_util.c b/crypto/cmp/cmp_util.c
index f3a0c86d53..c50d317ddc 100644
--- a/crypto/cmp/cmp_util.c
+++ b/crypto/cmp/cmp_util.c
@@ -227,7 +227,7 @@ int ossl_cmp_sk_ASN1_UTF8STRING_push_str(STACK_OF(ASN1_UTF8STRING) *sk,
         return 0;
     if ((utf8string = ASN1_UTF8STRING_new()) == NULL)
         return 0;
-    if (!ASN1_STRING_set_data(utf8string, (const uint8_t *)text, len))
+    if (!ASN1_STRING_set1_data(utf8string, (const uint8_t *)text, len))
         goto err;
     if (!sk_ASN1_UTF8STRING_push(sk, utf8string))
         goto err;
diff --git a/crypto/cms/cms_dd.c b/crypto/cms/cms_dd.c
index e307460e44..69661e3b40 100644
--- a/crypto/cms/cms_dd.c
+++ b/crypto/cms/cms_dd.c
@@ -92,7 +92,7 @@ int ossl_cms_DigestedData_do_final(const CMS_ContentInfo *cms, BIO *chain,
         else
             r = 1;
     } else {
-        if (!ASN1_STRING_set_data(dd->digest, md, mdlen))
+        if (!ASN1_STRING_set1_data(dd->digest, md, mdlen))
             goto err;
         r = 1;
     }
diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c
index bfe0ccbf3d..b1647b03b7 100644
--- a/crypto/cms/cms_ess.c
+++ b/crypto/cms/cms_ess.c
@@ -131,7 +131,7 @@ CMS_ReceiptRequest *CMS_ReceiptRequest_create0_ex(
     if (id)
         ASN1_STRING_set0(rr->signedContentIdentifier, id, idlen);
     else {
-        if (!ASN1_STRING_set_data(rr->signedContentIdentifier, NULL, 32)) {
+        if (!ASN1_STRING_set1_data(rr->signedContentIdentifier, NULL, 32)) {
             ERR_raise(ERR_LIB_CMS, ERR_R_ASN1_LIB);
             goto err;
         }
diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c
index 20f60235aa..1777b7cd71 100644
--- a/crypto/cms/cms_sd.c
+++ b/crypto/cms/cms_sd.c
@@ -304,7 +304,7 @@ static int ossl_cms_add1_signing_cert(CMS_SignerInfo *si,

     p = pp;
     i2d_ESS_SIGNING_CERT(sc, &p);
-    if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set_data(seq, pp, len)) {
+    if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set1_data(seq, pp, len)) {
         ASN1_STRING_free(seq);
         OPENSSL_free(pp);
         return 0;
@@ -329,7 +329,7 @@ static int ossl_cms_add1_signing_cert_v2(CMS_SignerInfo *si,

     p = pp;
     i2d_ESS_SIGNING_CERT_V2(sc, &p);
-    if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set_data(seq, pp, len)) {
+    if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set1_data(seq, pp, len)) {
         ASN1_STRING_free(seq);
         OPENSSL_free(pp);
         return 0;
diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c
index 038be72b04..ad5a9cdf4e 100644
--- a/crypto/ocsp/ocsp_ext.c
+++ b/crypto/ocsp/ocsp_ext.c
@@ -360,7 +360,7 @@ X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim)
     if (url) {
         if ((cid->crlUrl = ASN1_IA5STRING_new()) == NULL)
             goto err;
-        if (!(ASN1_STRING_set_string(cid->crlUrl, url)))
+        if (!(ASN1_STRING_set1_string(cid->crlUrl, url)))
             goto err;
     }
     if (n) {
@@ -446,7 +446,7 @@ X509_EXTENSION *OCSP_url_svcloc_new(const X509_NAME *issuer, const char **urls)
             goto err;
         if ((ia5 = ASN1_IA5STRING_new()) == NULL)
             goto err;
-        if (!ASN1_STRING_set_string((ASN1_STRING *)ia5, *urls))
+        if (!ASN1_STRING_set1_string((ASN1_STRING *)ia5, *urls))
             goto err;
         /* ad->location is allocated inside ACCESS_DESCRIPTION_new */
         ad->location->type = GEN_URI;
diff --git a/crypto/pkcs7/pk7_attr.c b/crypto/pkcs7/pk7_attr.c
index af0c755e90..601956af9d 100644
--- a/crypto/pkcs7/pk7_attr.c
+++ b/crypto/pkcs7/pk7_attr.c
@@ -132,7 +132,7 @@ int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
     os = ASN1_OCTET_STRING_new();
     if (os == NULL)
         return 0;
-    if (!ASN1_STRING_set_data(os, md, mdlen)
+    if (!ASN1_STRING_set1_data(os, md, mdlen)
         || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
             V_ASN1_OCTET_STRING, os)) {
         ASN1_OCTET_STRING_free(os);
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c
index 0931fdf21c..76afe331f6 100644
--- a/crypto/ts/ts_rsp_sign.c
+++ b/crypto/ts/ts_rsp_sign.c
@@ -298,7 +298,7 @@ int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,
     }
     if (text) {
         if ((utf8_text = ASN1_UTF8STRING_new()) == NULL
-            || !ASN1_STRING_set_string(utf8_text, text)) {
+            || !ASN1_STRING_set1_string(utf8_text, text)) {
             ERR_raise(ERR_LIB_TS, ERR_R_ASN1_LIB);
             goto err;
         }
@@ -645,7 +645,7 @@ static int ossl_ess_add1_signing_cert(PKCS7_SIGNER_INFO *si,

     p = pp;
     i2d_ESS_SIGNING_CERT(sc, &p);
-    if ((seq = ASN1_STRING_new()) == NULL || !ASN1_STRING_set_data(seq, pp, len)) {
+    if ((seq = ASN1_STRING_new()) == NULL || !ASN1_STRING_set1_data(seq, pp, len)) {
         ASN1_STRING_free(seq);
         OPENSSL_free(pp);
         return 0;
@@ -676,7 +676,7 @@ static int ossl_ess_add1_signing_cert_v2(PKCS7_SIGNER_INFO *si,

     p = pp;
     i2d_ESS_SIGNING_CERT_V2(sc, &p);
-    if ((seq = ASN1_STRING_new()) == NULL || !ASN1_STRING_set_data(seq, pp, len)) {
+    if ((seq = ASN1_STRING_new()) == NULL || !ASN1_STRING_set1_data(seq, pp, len)) {
         ASN1_STRING_free(seq);
         OPENSSL_free(pp);
         return 0;
diff --git a/crypto/x509/v3_cpols.c b/crypto/x509/v3_cpols.c
index 2cc71f567b..f9abeaa959 100644
--- a/crypto/x509/v3_cpols.c
+++ b/crypto/x509/v3_cpols.c
@@ -208,7 +208,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
-            if (!ASN1_STRING_set_string(qual->d.cpsuri, cnf->value)) {
+            if (!ASN1_STRING_set1_string(qual->d.cpsuri, cnf->value)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
@@ -324,7 +324,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
             if (tag_len != 0)
                 value += tag_len + 1;
             len = (int)strlen(value);
-            if (!ASN1_STRING_set_data(not->exptext, (uint8_t *)value, len)) {
+            if (!ASN1_STRING_set1_data(not->exptext, (uint8_t *)value, len)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
@@ -343,7 +343,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx,
                 nref->organization->type = V_ASN1_IA5STRING;
             else
                 nref->organization->type = V_ASN1_VISIBLESTRING;
-            if (!ASN1_STRING_set_string(nref->organization, cnf->value)) {
+            if (!ASN1_STRING_set1_string(nref->organization, cnf->value)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
diff --git a/crypto/x509/v3_ia5.c b/crypto/x509/v3_ia5.c
index a8fa52a439..06b06ff70e 100644
--- a/crypto/x509/v3_ia5.c
+++ b/crypto/x509/v3_ia5.c
@@ -52,7 +52,7 @@ ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
         ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
         return NULL;
     }
-    if (!ASN1_STRING_set_string((ASN1_STRING *)ia5, str)) {
+    if (!ASN1_STRING_set1_string((ASN1_STRING *)ia5, str)) {
         ASN1_IA5STRING_free(ia5);
         return NULL;
     }
diff --git a/crypto/x509/v3_ist.c b/crypto/x509/v3_ist.c
index a4d3437192..ee54384c1f 100644
--- a/crypto/x509/v3_ist.c
+++ b/crypto/x509/v3_ist.c
@@ -52,28 +52,28 @@ static ISSUER_SIGN_TOOL *v2i_issuer_sign_tool(X509V3_EXT_METHOD *method, X509V3_
         if (strcmp(cnf->name, "signTool") == 0) {
             if (ist->signTool == NULL
                 || cnf->value == NULL
-                || !ASN1_STRING_set_string(ist->signTool, cnf->value)) {
+                || !ASN1_STRING_set1_string(ist->signTool, cnf->value)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
         } else if (strcmp(cnf->name, "cATool") == 0) {
             if (ist->cATool == NULL
                 || cnf->value == NULL
-                || !ASN1_STRING_set_string(ist->cATool, cnf->value)) {
+                || !ASN1_STRING_set1_string(ist->cATool, cnf->value)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
         } else if (strcmp(cnf->name, "signToolCert") == 0) {
             if (ist->signToolCert == NULL
                 || cnf->value == NULL
-                || !ASN1_STRING_set_string(ist->signToolCert, cnf->value)) {
+                || !ASN1_STRING_set1_string(ist->signToolCert, cnf->value)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
         } else if (strcmp(cnf->name, "cAToolCert") == 0) {
             if (ist->cAToolCert == NULL
                 || cnf->value == NULL
-                || !ASN1_STRING_set_string(ist->cAToolCert, cnf->value)) {
+                || !ASN1_STRING_set1_string(ist->cAToolCert, cnf->value)) {
                 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
                 goto err;
             }
diff --git a/crypto/x509/v3_san.c b/crypto/x509/v3_san.c
index f1b028f78c..611f5ff181 100644
--- a/crypto/x509/v3_san.c
+++ b/crypto/x509/v3_san.c
@@ -576,7 +576,7 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,

     if (is_string) {
         if ((gen->d.ia5 = ASN1_IA5STRING_new()) == NULL
-            || !ASN1_STRING_set_string(gen->d.ia5, value)) {
+            || !ASN1_STRING_set1_string(gen->d.ia5, value)) {
             ASN1_IA5STRING_free(gen->d.ia5);
             gen->d.ia5 = NULL;
             ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
diff --git a/crypto/x509/v3_utf8.c b/crypto/x509/v3_utf8.c
index dc7c86fb7f..aa80d7455e 100644
--- a/crypto/x509/v3_utf8.c
+++ b/crypto/x509/v3_utf8.c
@@ -55,7 +55,7 @@ ASN1_UTF8STRING *s2i_ASN1_UTF8STRING(X509V3_EXT_METHOD *method,
         ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
         return NULL;
     }
-    if (!ASN1_STRING_set_string(utf8, str)) {
+    if (!ASN1_STRING_set1_string(utf8, str)) {
         ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
         ASN1_UTF8STRING_free(utf8);
         return NULL;
diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c
index e08e490274..0badec2b7d 100644
--- a/crypto/x509/x509_att.c
+++ b/crypto/x509/x509_att.c
@@ -365,7 +365,7 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,
         atype = stmp->type;
     } else if (len != -1) {
         if ((stmp = ASN1_STRING_type_new(attrtype)) == NULL
-            || !ASN1_STRING_set_data(stmp, data, len)) {
+            || !ASN1_STRING_set1_data(stmp, data, len)) {
             ERR_raise(ERR_LIB_X509, ERR_R_ASN1_LIB);
             goto err;
         }
diff --git a/crypto/x509/x509name.c b/crypto/x509/x509name.c
index 58167d9a78..653137dd71 100644
--- a/crypto/x509/x509name.c
+++ b/crypto/x509/x509name.c
@@ -335,9 +335,9 @@ int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
     if (len < -1)
         return 0;
     if (len == -1)
-        i = ASN1_STRING_set_string(ne->value, (const char *)bytes);
+        i = ASN1_STRING_set1_string(ne->value, (const char *)bytes);
     else
-        i = ASN1_STRING_set_data(ne->value, bytes, (size_t)len);
+        i = ASN1_STRING_set1_data(ne->value, bytes, (size_t)len);
     if (!i)
         return 0;
     if (type != V_ASN1_UNDEF) {
diff --git a/crypto/x509/x_x509a.c b/crypto/x509/x_x509a.c
index 3fa17fb925..9ac7626577 100644
--- a/crypto/x509/x_x509a.c
+++ b/crypto/x509/x_x509a.c
@@ -72,7 +72,7 @@ int X509_alias_set1(X509 *x, const unsigned char *name, int len)

     if (aux->alias == NULL && (aux->alias = ASN1_UTF8STRING_new()) == NULL)
         return 0;
-    return ASN1_STRING_set_data(aux->alias, name, len_s);
+    return ASN1_STRING_set1_data(aux->alias, name, len_s);
 }

 int X509_keyid_set1(X509 *x, const unsigned char *id, int len)
@@ -101,7 +101,7 @@ int X509_keyid_set1(X509 *x, const unsigned char *id, int len)
     if (aux->keyid == NULL
         && (aux->keyid = ASN1_OCTET_STRING_new()) == NULL)
         return 0;
-    return ASN1_STRING_set_data(aux->keyid, id, len_s);
+    return ASN1_STRING_set1_data(aux->keyid, id, len_s);
 }

 const unsigned char *X509_alias_get0(const X509 *x, int *len)
diff --git a/doc/man3/ASN1_STRING_length.pod b/doc/man3/ASN1_STRING_length.pod
index cfe08430db..d7dc04578a 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_get_length,
+ASN1_STRING_set1_data, ASN1_STRING_set1_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
@@ -21,9 +21,9 @@ ASN1_STRING_to_UTF8 - ASN1_STRING utility functions

  int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);

- int ASN1_STRING_set_data(ASN1_STRING *str, const uint8_t *data, size_t len);
+ int ASN1_STRING_set1_data(ASN1_STRING *str, const uint8_t *data, size_t len);

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

  size_t ASN1_STRING_get_length(const ASN1_STRING *x);

@@ -56,13 +56,13 @@ freed or re-used.  If I<data> is not NULL, I<len> bytes are copied
 from the memory pointed to by I<data> to I<str>. If I<len> is -1 then
 the length is determined by strlen(data).

-ASN1_STRING_set_data() allocates memory for string I<str> to hold
+ASN1_STRING_set1_data() allocates memory for string I<str> to hold
 I<len> bytes of data. Any previously allocated memory owned by I<str>
 will be freed or re-used.  If I<data> is not NULL, I<len> bytes are
 copied from the memory pointed to by I<data> to I<str>. It is an error
 to use this function on a string of type B<ASN1_BIT_STRING>.

-ASN1_STRING_set_string() allocates memory for the string I<str> and makes
+ASN1_STRING_set1_string() allocates memory for the string I<str> and makes
 a copy of the characters from I<cstring>. Any previously
 allocated memory owned by I<str> will be freed or re-used.  I<cstring>
 must point to a valid NUL-terminated C string, and must not be
@@ -99,8 +99,8 @@ be ASCII, for a BMPString two bytes per character in big endian
 format, and for a UTF8String it will be in UTF8 format.

 Similar care should be taken to ensure the data is in the correct
-format when calling ASN1_STRING_set(), ASN1_STRING_set_data(), or
-ASN1_STRING_set_string().
+format when calling ASN1_STRING_set(), ASN1_STRING_set1_data(), or
+ASN1_STRING_set1_string().

 =head1 RETURN VALUES

@@ -115,8 +115,8 @@ error occurred.
 ASN1_STRING_cmp() returns an integer greater than, equal to, or less than 0,
 according to whether I<a> is greater than, equal to, or less than I<b>.

-ASN1_STRING_set(), ASN1_STRING_set_data(), and
-ASN1_STRING_set_string() return 1 on success or 0 on error or failure.
+ASN1_STRING_set(), ASN1_STRING_set1_data(), and
+ASN1_STRING_set1_string() return 1 on success or 0 on error or failure.

 ASN1_STRING_type() returns the type of I<x>.

@@ -129,7 +129,7 @@ L<ERR_get_error(3)>

 =head1 HISTORY

-ASN1_STRING_set_data(), ASN1_STRING_set_string(), and ASN1_STRING_get_length()
+ASN1_STRING_set1_data(), ASN1_STRING_set1_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 5b529333c5..a6f905b073 100644
--- a/include/openssl/asn1.h.in
+++ b/include/openssl/asn1.h.in
@@ -541,14 +541,14 @@ int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
  * make its data void *
  */
 #if !defined(OPENSSL_NO_DEPRECATED_4_1)
-OSSL_DEPRECATEDIN_4_1_FOR(" Use ASN1_STRING_set_data() or ASN1_STRING_set_string() instead.")
+OSSL_DEPRECATEDIN_4_1_FOR(" Use ASN1_STRING_set1_data() or ASN1_STRING_set1_string() instead.")
 int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
 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);
+int ASN1_STRING_set1_data(ASN1_STRING *str, const uint8_t *data, size_t len);
+int ASN1_STRING_set1_string(ASN1_STRING *str, const char *cstring);
 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);
diff --git a/test/asn1_string_test.c b/test/asn1_string_test.c
index 88c19ae3a5..76a3160f63 100644
--- a/test/asn1_string_test.c
+++ b/test/asn1_string_test.c
@@ -410,7 +410,7 @@ asn1_string_new_not_owned_test(void)
     if (!TEST_ptr(tmp = ASN1_STRING_new_not_owned(V_ASN1_OCTET_STRING, data, sizeof(data))))
         goto err;

-    if (!TEST_true(ASN1_STRING_set_string(tmp, "muppet")))
+    if (!TEST_true(ASN1_STRING_set1_string(tmp, "muppet")))
         goto err;

     if (!TEST_mem_eq(data, sizeof(data), data2, sizeof(data2)))
@@ -484,16 +484,16 @@ asn1_string_set_data_test(void)
     if (!TEST_ptr(str = ASN1_STRING_new()))
         goto err;

-    if (!TEST_false(ASN1_STRING_set_data(str, (uint8_t *)"hoobla", -1)))
+    if (!TEST_false(ASN1_STRING_set1_data(str, (uint8_t *)"hoobla", -1)))
         goto err;

-    if (!TEST_false(ASN1_STRING_set_data(str, (uint8_t *)"hoobla", (size_t)INT_MAX + 1)))
+    if (!TEST_false(ASN1_STRING_set1_data(str, (uint8_t *)"hoobla", (size_t)INT_MAX + 1)))
         goto err;

-    if (!TEST_true(ASN1_STRING_set_data(str, NULL, 10)))
+    if (!TEST_true(ASN1_STRING_set1_data(str, NULL, 10)))
         goto err;

-    if (!TEST_true(ASN1_STRING_set_data(str, (uint8_t *)"hoobla", strlen("hoobla"))))
+    if (!TEST_true(ASN1_STRING_set1_data(str, (uint8_t *)"hoobla", strlen("hoobla"))))
         goto err;

     data = ASN1_STRING_get0_data(str);
@@ -504,7 +504,7 @@ asn1_string_set_data_test(void)
     if (!TEST_int_eq(memcmp("hoobla", data, strlen("hoobla")), 0))
         goto err;

-    if (!TEST_true(ASN1_STRING_set_data(str, (uint8_t *)"hoobla", strlen("hoobla") + 1)))
+    if (!TEST_true(ASN1_STRING_set1_data(str, (uint8_t *)"hoobla", strlen("hoobla") + 1)))
         goto err;

     data = ASN1_STRING_get0_data(str);
@@ -531,13 +531,13 @@ asn1_string_set_string_test(void)
     if (!TEST_ptr(str = ASN1_STRING_new()))
         goto err;

-    if (!TEST_true(ASN1_STRING_set_string(str, "foo")))
+    if (!TEST_true(ASN1_STRING_set1_string(str, "foo")))
         goto err;

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

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

     if (!TEST_size_t_eq(ASN1_STRING_get_length(str), 4))
diff --git a/test/cmp_hdr_test.c b/test/cmp_hdr_test.c
index 30f19f6238..008ac4319f 100644
--- a/test/cmp_hdr_test.c
+++ b/test/cmp_hdr_test.c
@@ -252,7 +252,7 @@ static int execute_HDR_push0_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
     if (!TEST_ptr(text))
         return 0;

-    if (!ASN1_STRING_set_string(text, "A free text"))
+    if (!ASN1_STRING_set1_string(text, "A free text"))
         goto err;

     if (!TEST_int_eq(ossl_cmp_hdr_push0_freeText(fixture->hdr, text), 1))
@@ -285,7 +285,7 @@ static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
     if (!TEST_ptr(text))
         goto err;

-    if (!ASN1_STRING_set_string(text, "A free text"))
+    if (!ASN1_STRING_set1_string(text, "A free text"))
         goto err;

     if (!TEST_int_eq(ossl_cmp_hdr_push1_freeText(fixture->hdr, text), 1))
diff --git a/test/v3nametest.c b/test/v3nametest.c
index cfa8376bbb..82777e6086 100644
--- a/test/v3nametest.c
+++ b/test/v3nametest.c
@@ -149,7 +149,7 @@ static int set_altname(X509 *crt, ...)
         ia5 = ASN1_IA5STRING_new();
         if (ia5 == NULL)
             goto out;
-        if (!ASN1_STRING_set_string(ia5, name))
+        if (!ASN1_STRING_set1_string(ia5, name))
             goto out;
         switch (type) {
         case GEN_EMAIL:
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 476a6e9671..0fa1d68539 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -5724,7 +5724,7 @@ OPENSSL_sk_set_copy_thunks              ?	4_1_0	EXIST::FUNCTION:
 ASN1_STRING_new_not_owned               ?	4_1_0	EXIST::FUNCTION:
 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_set1_data                   ?	4_1_0	EXIST::FUNCTION:
+ASN1_STRING_set1_string                 ?	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