Remove a host of unnecessary OPENSSL_IS_BORINGSSL ifdefs
The <openssl/buf.h> include is relevant in both OpenSSL and BoringSSL because the file uses BUF_MEM (include what you use). OpenSSL just happened to include it via another file. OpenSSL also spells it <openssl/buffer.h>, not matching the type, so use the compatible spelling. Additionally all the CHECKED_CAST and manual STACK_OF(T) definitions call into BoringSSL internals. The correct, public APIs are simply to just use the same code as OpenSSL and call the DEFINE_STACK_OF macros. Signed-off-by: David Benjamin <davidben@google.com>
This commit is contained in:
parent
b9cd5a82f4
commit
faf9c04cb5
3 changed files with 4 additions and 55 deletions
|
@ -17,9 +17,7 @@
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
#ifdef OPENSSL_IS_BORINGSSL
|
#include <openssl/buffer.h>
|
||||||
#include <openssl/buf.h>
|
|
||||||
#endif /* OPENSSL_IS_BORINGSSL */
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "utils/base64.h"
|
#include "utils/base64.h"
|
||||||
|
@ -220,9 +218,7 @@ typedef struct {
|
||||||
} d;
|
} d;
|
||||||
} AttrOrOID;
|
} AttrOrOID;
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
|
|
||||||
DEFINE_STACK_OF(AttrOrOID)
|
DEFINE_STACK_OF(AttrOrOID)
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type;
|
int type;
|
||||||
|
@ -340,30 +336,13 @@ static void add_csrattrs(struct hs20_osu_client *ctx, CsrAttrs *csrattrs,
|
||||||
if (!csrattrs || ! csrattrs->attrs)
|
if (!csrattrs || ! csrattrs->attrs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef OPENSSL_IS_BORINGSSL
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
num = sk_num(CHECKED_CAST(_STACK *, STACK_OF(AttrOrOID) *,
|
|
||||||
csrattrs->attrs));
|
|
||||||
for (i = 0; i < num; i++) {
|
|
||||||
AttrOrOID *ao = sk_value(
|
|
||||||
CHECKED_CAST(_STACK *, const STACK_OF(AttrOrOID) *,
|
|
||||||
csrattrs->attrs), i);
|
|
||||||
switch (ao->type) {
|
|
||||||
case 0:
|
|
||||||
add_csrattrs_oid(ctx, ao->d.oid, exts);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
add_csrattrs_attr(ctx, ao->d.attribute, exts);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else /* OPENSSL_IS_BORINGSSL */
|
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
|
|
||||||
num = sk_AttrOrOID_num(csrattrs->attrs);
|
num = sk_AttrOrOID_num(csrattrs->attrs);
|
||||||
#else
|
#else
|
||||||
num = SKM_sk_num(AttrOrOID, csrattrs->attrs);
|
num = SKM_sk_num(AttrOrOID, csrattrs->attrs);
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(OPENSSL_IS_BORINGSSL)
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
AttrOrOID *ao = sk_AttrOrOID_value(csrattrs->attrs, i);
|
AttrOrOID *ao = sk_AttrOrOID_value(csrattrs->attrs, i);
|
||||||
#else
|
#else
|
||||||
AttrOrOID *ao = SKM_sk_value(AttrOrOID, csrattrs->attrs, i);
|
AttrOrOID *ao = SKM_sk_value(AttrOrOID, csrattrs->attrs, i);
|
||||||
|
@ -377,7 +356,6 @@ static void add_csrattrs(struct hs20_osu_client *ctx, CsrAttrs *csrattrs,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPENSSL_IS_BORINGSSL */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -216,13 +216,7 @@ ASN1_SEQUENCE(BasicOCSPResponse) = {
|
||||||
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(BasicOCSPResponse);
|
IMPLEMENT_ASN1_FUNCTIONS(BasicOCSPResponse);
|
||||||
|
|
||||||
#define sk_SingleResponse_num(sk) \
|
DEFINE_STACK_OF(SingleResponse)
|
||||||
sk_num(CHECKED_CAST(_STACK *, STACK_OF(SingleResponse) *, sk))
|
|
||||||
|
|
||||||
#define sk_SingleResponse_value(sk, i) \
|
|
||||||
((SingleResponse *) \
|
|
||||||
sk_value(CHECKED_CAST(_STACK *, STACK_OF(SingleResponse) *, sk), (i)))
|
|
||||||
|
|
||||||
|
|
||||||
static char * mem_bio_to_str(BIO *out)
|
static char * mem_bio_to_str(BIO *out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -433,28 +433,6 @@ ASN1_SEQUENCE(LogotypeExtn) = {
|
||||||
|
|
||||||
IMPLEMENT_ASN1_FUNCTIONS(LogotypeExtn);
|
IMPLEMENT_ASN1_FUNCTIONS(LogotypeExtn);
|
||||||
|
|
||||||
#ifdef OPENSSL_IS_BORINGSSL
|
|
||||||
#define sk_LogotypeInfo_num(st) \
|
|
||||||
sk_num(CHECKED_CAST(_STACK *, STACK_OF(LogotypeInfo) *, (st)))
|
|
||||||
#define sk_LogotypeInfo_value(st, i) (LogotypeInfo *) \
|
|
||||||
sk_value(CHECKED_CAST(_STACK *, const STACK_OF(LogotypeInfo) *, (st)), (i))
|
|
||||||
#define sk_LogotypeImage_num(st) \
|
|
||||||
sk_num(CHECKED_CAST(_STACK *, STACK_OF(LogotypeImage) *, (st)))
|
|
||||||
#define sk_LogotypeImage_value(st, i) (LogotypeImage *) \
|
|
||||||
sk_value(CHECKED_CAST(_STACK *, const STACK_OF(LogotypeImage) *, (st)), (i))
|
|
||||||
#define sk_LogotypeAudio_num(st) \
|
|
||||||
sk_num(CHECKED_CAST(_STACK *, STACK_OF(LogotypeAudio) *, (st)))
|
|
||||||
#define sk_LogotypeAudio_value(st, i) (LogotypeAudio *) \
|
|
||||||
sk_value(CHECK_CAST(_STACK *, const STACK_OF(LogotypeAudio) *, (st)), (i))
|
|
||||||
#define sk_HashAlgAndValue_num(st) \
|
|
||||||
sk_num(CHECKED_CAST(_STACK *, STACK_OF(HashAlgAndValue) *, (st)))
|
|
||||||
#define sk_HashAlgAndValue_value(st, i) (HashAlgAndValue *) \
|
|
||||||
sk_value(CHECKED_CAST(_STACK *, const STACK_OF(HashAlgAndValue) *, (st)), (i))
|
|
||||||
#define sk_ASN1_IA5STRING_num(st) \
|
|
||||||
sk_num(CHECKED_CAST(_STACK *, STACK_OF(ASN1_IA5STRING) *, (st)))
|
|
||||||
#define sk_ASN1_IA5STRING_value(st, i) (ASN1_IA5STRING *) \
|
|
||||||
sk_value(CHECKED_CAST(_STACK *, const STACK_OF(ASN1_IA5STRING) *, (st)), (i))
|
|
||||||
#else /* OPENSSL_IS_BORINGSSL */
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
#define sk_LogotypeInfo_num(st) SKM_sk_num(LogotypeInfo, (st))
|
#define sk_LogotypeInfo_num(st) SKM_sk_num(LogotypeInfo, (st))
|
||||||
#define sk_LogotypeInfo_value(st, i) SKM_sk_value(LogotypeInfo, (st), (i))
|
#define sk_LogotypeInfo_value(st, i) SKM_sk_value(LogotypeInfo, (st), (i))
|
||||||
|
@ -473,7 +451,6 @@ DEFINE_STACK_OF(LogotypeAudio)
|
||||||
DEFINE_STACK_OF(HashAlgAndValue)
|
DEFINE_STACK_OF(HashAlgAndValue)
|
||||||
DEFINE_STACK_OF(ASN1_IA5STRING)
|
DEFINE_STACK_OF(ASN1_IA5STRING)
|
||||||
#endif
|
#endif
|
||||||
#endif /* OPENSSL_IS_BORINGSSL */
|
|
||||||
|
|
||||||
|
|
||||||
static void add_logo(struct http_ctx *ctx, struct http_cert *hcert,
|
static void add_logo(struct http_ctx *ctx, struct http_cert *hcert,
|
||||||
|
|
Loading…
Reference in a new issue