X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fx509v3%2Fv3_scts.c;h=b1505feb35bb0d31d4110b103c62d359855e5577;hp=a9e1a9782f696ad78de3355f4315da3773729f3f;hb=a46c9789ce2aecedceef119e9883513c7a49f1ca;hpb=d13bd6130bd856e9f512c43499e5fc70943bf133 diff --git a/crypto/x509v3/v3_scts.c b/crypto/x509v3/v3_scts.c index a9e1a9782f..b1505feb35 100644 --- a/crypto/x509v3/v3_scts.c +++ b/crypto/x509v3/v3_scts.c @@ -57,10 +57,12 @@ */ #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include +#include "ext_dat.h" +#ifndef OPENSSL_NO_SCT /* Signature and hash algorithms from RFC 5246 */ #define TLSEXT_hash_sha256 4 @@ -71,22 +73,14 @@ #define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \ (((unsigned int)(c[1])) )),c+=2) -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -# define SCT_TIMESTAMP unsigned __int64 -#elif defined(__arch64__) -# define SCT_TIMESTAMP unsigned long -#else -# define SCT_TIMESTAMP unsigned long long -#endif - -#define n2l8(c,l) (l =((SCT_TIMESTAMP)(*((c)++)))<<56, \ - l|=((SCT_TIMESTAMP)(*((c)++)))<<48, \ - l|=((SCT_TIMESTAMP)(*((c)++)))<<40, \ - l|=((SCT_TIMESTAMP)(*((c)++)))<<32, \ - l|=((SCT_TIMESTAMP)(*((c)++)))<<24, \ - l|=((SCT_TIMESTAMP)(*((c)++)))<<16, \ - l|=((SCT_TIMESTAMP)(*((c)++)))<< 8, \ - l|=((SCT_TIMESTAMP)(*((c)++)))) +#define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \ + l|=((uint64_t)(*((c)++)))<<48, \ + l|=((uint64_t)(*((c)++)))<<40, \ + l|=((uint64_t)(*((c)++)))<<32, \ + l|=((uint64_t)(*((c)++)))<<24, \ + l|=((uint64_t)(*((c)++)))<<16, \ + l|=((uint64_t)(*((c)++)))<< 8, \ + l|=((uint64_t)(*((c)++)))) typedef struct SCT_st { /* The encoded SCT */ @@ -99,7 +93,7 @@ typedef struct SCT_st { unsigned char version; unsigned char *logid; unsigned short logidlen; - SCT_TIMESTAMP timestamp; + uint64_t timestamp; unsigned char *ext; unsigned short extlen; unsigned char hash_alg; @@ -149,7 +143,7 @@ static void tls12_signature_print(BIO *out, const unsigned char hash_alg, BIO_printf(out, "%s", OBJ_nid2ln(nid)); } -static void timestamp_print(BIO *out, SCT_TIMESTAMP timestamp) +static void timestamp_print(BIO *out, uint64_t timestamp) { ASN1_GENERALIZEDTIME *gen; char genstr[20]; @@ -189,8 +183,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; @@ -278,6 +273,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, done: ASN1_OCTET_STRING_free(oct); + *pp = q; return sk; err: @@ -329,3 +325,4 @@ static int i2r_SCT_LIST(X509V3_EXT_METHOD *method, STACK_OF(SCT) *sct_list, return 1; } +#endif