Commit 17ebf85a authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Add ASN1_STRING_get0_data(), deprecate ASN1_STRING_data().



Deprecate the function ASN1_STRING_data() and replace with a new function
ASN1_STRING_get0_data() which returns a constant pointer. Update library
to use new function.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 1940aa6e
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -1938,7 +1938,7 @@ static const char *get_dp_url(DIST_POINT *dp)
        gen = sk_GENERAL_NAME_value(gens, i);
        uri = GENERAL_NAME_get0_value(gen, &gtype);
        if (gtype == GEN_URI && ASN1_STRING_length(uri) > 6) {
            char *uptr = (char *)ASN1_STRING_data(uri);
            const char *uptr = (const char *)ASN1_STRING_get0_data(uri);
            if (strncmp(uptr, "http://", 7) == 0)
                return uptr;
        }
@@ -2581,3 +2581,17 @@ int has_stdin_waiting(void)
    return _kbhit();
}
#endif

/* Corrupt a signature by modifying final byte */
int corrupt_signature(ASN1_STRING *signature)
{
        unsigned char *s;
        size_t slen = ASN1_STRING_length(signature);

        s = OPENSSL_memdup(ASN1_STRING_get0_data(signature), slen);
        if (s == NULL)
            return 0;
        s[slen - 1] ^= 0x1;
        ASN1_STRING_set0(signature, s, slen);
        return 1;
}
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ void wait_for_async(SSL *s);
int has_stdin_waiting(void);
# endif

int corrupt_signature(ASN1_STRING *signature);

/*
 * Common verification options.
 */
+1 −1
Original line number Diff line number Diff line
@@ -988,7 +988,7 @@ end_of_options:
            x = sk_X509_value(cert_sk, i);

            j = ASN1_STRING_length(serialNumber);
            p = (const char *)ASN1_STRING_data(serialNumber);
            p = (const char *)ASN1_STRING_get0_data(serialNumber);

            if (strlen(outdir) >= (size_t)(j ? BSIZE - j * 2 - 6 : BSIZE - 8)) {
                BIO_printf(bio_err, "certificate file name too long\n");
+2 −2
Original line number Diff line number Diff line
@@ -1177,13 +1177,13 @@ static void receipt_request_print(CMS_ContentInfo *cms)
            BIO_puts(bio_err, "  Receipt Request Parse Error\n");
            ERR_print_errors(bio_err);
        } else {
            char *id;
            const char *id;
            int idlen;
            CMS_ReceiptRequest_get0_values(rr, &scid, &allorfirst,
                                           &rlist, &rto);
            BIO_puts(bio_err, "  Signed Content ID:\n");
            idlen = ASN1_STRING_length(scid);
            id = (char *)ASN1_STRING_data(scid);
            id = (const char *)ASN1_STRING_get0_data(scid);
            BIO_dump_indent(bio_err, id, idlen, 4);
            BIO_puts(bio_err, "  Receipts From");
            if (rlist) {
+2 −3
Original line number Diff line number Diff line
@@ -321,10 +321,9 @@ int crl_main(int argc, char **argv)

    if (badsig) {
        ASN1_BIT_STRING *sig;
        unsigned char *psig;
        X509_CRL_get0_signature(&sig, NULL, x);
        psig = ASN1_STRING_data(sig);
        psig[ASN1_STRING_length(sig) - 1] ^= 0x1;
        if (!corrupt_signature(sig))
            goto end;
    }

    if (outformat == FORMAT_ASN1)
Loading