X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fx509v3%2Fv3_scts.c;h=6d3665cf014fc24d0b1d6ba714009c8ed0f8abbc;hb=3149baf83cb703f060b1e6eeb440a45e010a626b;hp=e9ee66884cd312758a879bfe5144c4ddc4d6fa07;hpb=1c7b2c0ed5d02d0d60179e0df0c49ef3f659fa77;p=oweals%2Fopenssl.git diff --git a/crypto/x509v3/v3_scts.c b/crypto/x509v3/v3_scts.c index e9ee66884c..6d3665cf01 100644 --- a/crypto/x509v3/v3_scts.c +++ b/crypto/x509v3/v3_scts.c @@ -57,10 +57,13 @@ */ #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include +#include "ext_dat.h" +#include "crypto/ct/ct_locl.h" +#ifndef OPENSSL_NO_CT /* Signature and hash algorithms from RFC 5246 */ #define TLSEXT_hash_sha256 4 @@ -80,27 +83,6 @@ l|=((uint64_t)(*((c)++)))<< 8, \ l|=((uint64_t)(*((c)++)))) -typedef struct SCT_st { - /* The encoded SCT */ - unsigned char *sct; - unsigned short sctlen; - /* - * Components of the SCT. "logid", "ext" and "sig" point to addresses - * inside "sct". - */ - unsigned char version; - unsigned char *logid; - unsigned short logidlen; - uint64_t timestamp; - unsigned char *ext; - unsigned short extlen; - unsigned char hash_alg; - unsigned char sig_alg; - unsigned char *sig; - unsigned short siglen; -} SCT; - -DECLARE_STACK_OF(SCT) static void SCT_LIST_free(STACK_OF(SCT) *a); static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, @@ -160,14 +142,6 @@ static void timestamp_print(BIO *out, uint64_t timestamp) ASN1_GENERALIZEDTIME_free(gen); } -static void SCT_free(SCT *sct) -{ - if (!sct) - return; - OPENSSL_free(sct->sct); - OPENSSL_free(sct); -} - static void SCT_LIST_free(STACK_OF(SCT) *a) { sk_SCT_pop_free(a, SCT_free); @@ -181,8 +155,9 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, SCT *sct; unsigned char *p, *p2; unsigned short listlen, sctlen = 0, fieldlen; + const unsigned char *q = *pp; - if (d2i_ASN1_OCTET_STRING(&oct, pp, length) == NULL) + if (d2i_ASN1_OCTET_STRING(&oct, &q, length) == NULL) return NULL; if (oct->length < 2) goto done; @@ -216,7 +191,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, if (!sct->sct) goto err; memcpy(sct->sct, p, sctlen); - sct->sctlen = sctlen; + sct->sct_len = sctlen; p += sctlen; p2 = sct->sct; @@ -234,8 +209,8 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, goto err; sctlen -= 43; - sct->logid = p2; - sct->logidlen = 32; + sct->log_id = p2; + sct->log_id_len = 32; p2 += 32; n2l8(p2, sct->timestamp); @@ -244,7 +219,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, if (sctlen < fieldlen) goto err; sct->ext = p2; - sct->extlen = fieldlen; + sct->ext_len = fieldlen; p2 += fieldlen; sctlen -= fieldlen; @@ -264,12 +239,13 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, if (sctlen != fieldlen) goto err; sct->sig = p2; - sct->siglen = fieldlen; + sct->sig_len = fieldlen; } } done: ASN1_OCTET_STRING_free(oct); + *pp = q; return sk; err: @@ -294,25 +270,25 @@ static int i2r_SCT_LIST(X509V3_EXT_METHOD *method, STACK_OF(SCT) *sct_list, BIO_printf(out, "v1(0)"); BIO_printf(out, "\n%*sLog ID : ", indent + 4, ""); - BIO_hex_string(out, indent + 16, 16, sct->logid, sct->logidlen); + BIO_hex_string(out, indent + 16, 16, sct->log_id, sct->log_id_len); BIO_printf(out, "\n%*sTimestamp : ", indent + 4, ""); timestamp_print(out, sct->timestamp); BIO_printf(out, "\n%*sExtensions: ", indent + 4, ""); - if (sct->extlen == 0) + if (sct->ext_len == 0) BIO_printf(out, "none"); else - BIO_hex_string(out, indent + 16, 16, sct->ext, sct->extlen); + BIO_hex_string(out, indent + 16, 16, sct->ext, sct->ext_len); BIO_printf(out, "\n%*sSignature : ", indent + 4, ""); tls12_signature_print(out, sct->hash_alg, sct->sig_alg); BIO_printf(out, "\n%*s ", indent + 4, ""); - BIO_hex_string(out, indent + 16, 16, sct->sig, sct->siglen); + BIO_hex_string(out, indent + 16, 16, sct->sig, sct->sig_len); } else { /* Unknown version */ BIO_printf(out, "unknown\n%*s", indent + 16, ""); - BIO_hex_string(out, indent + 16, 16, sct->sct, sct->sctlen); + BIO_hex_string(out, indent + 16, 16, sct->sct, sct->sct_len); } if (++i < sk_SCT_num(sct_list)) @@ -321,3 +297,4 @@ static int i2r_SCT_LIST(X509V3_EXT_METHOD *method, STACK_OF(SCT) *sct_list, return 1; } +#endif