Skip to content

Commit

Permalink
crypto/*/*.c: make sure libcmp overrides symbols from OpenSSL, also f…
Browse files Browse the repository at this point in the history
…or v3.2+
  • Loading branch information
DDvO committed Feb 9, 2024
1 parent c24de75 commit ac1dd51
Show file tree
Hide file tree
Showing 20 changed files with 12 additions and 88 deletions.
2 changes: 0 additions & 2 deletions crypto/cmp/cmp_asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ ASN1_ADB(OSSL_CMP_ITAV) = {
ADB_ENTRY(NID_id_it_certReqTemplate,
ASN1_OPT(OSSL_CMP_ITAV, infoValue.certReqTemplate,
OSSL_CMP_CERTREQTEMPLATE)),
#endif
#if OPENSSL_VERSION_NUMBER >= 0x30200000L || OPENSSL_VERSION_NUMBER >= 0x30000000L
ADB_ENTRY(NID_id_it_rootCaCert,
ASN1_OPT(OSSL_CMP_ITAV, infoValue.rootCaCert, X509)),
ADB_ENTRY(NID_id_it_certProfile,
Expand Down
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <openssl/x509v3.h>
#include <openssl/cmp_util.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

#define IS_CREP(t) ((t) == OSSL_CMP_PKIBODY_IP || (t) == OSSL_CMP_PKIBODY_CP \
|| (t) == OSSL_CMP_PKIBODY_KUP)

Expand Down Expand Up @@ -1060,5 +1058,3 @@ STACK_OF(OSSL_CMP_ITAV) *OSSL_CMP_exec_GENM_ses(OSSL_CMP_CTX *ctx)

return itavs; /* NULL indicates error case */
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
12 changes: 0 additions & 12 deletions crypto/cmp/cmp_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ TYPE *OSSL_CMP_CTX_get0_##NAME(const OSSL_CMP_CTX *ctx) \
return ctx->FIELD; \
}

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/*
* Get current certificate store containing trusted root CA certs
*/
Expand Down Expand Up @@ -577,8 +575,6 @@ int OSSL_CMP_CTX_set1_##FIELD(OSSL_CMP_CTX *ctx, const TYPE *val) \
return 1; \
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */

#define X509_invalid(cert) (!ossl_x509v3_cache_extensions(cert))
#define EVP_PKEY_invalid(key) 0

Expand All @@ -602,8 +598,6 @@ int PREFIX##_set1_##FIELD(OSSL_CMP_CTX *ctx, TYPE *val) \
return 1; \
}

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

#define DEFINE_OSSL_set1_up_ref(PREFIX, FIELD, TYPE) \
int PREFIX##_set1_##FIELD(OSSL_CMP_CTX *ctx, TYPE *val) \
{ \
Expand Down Expand Up @@ -644,9 +638,7 @@ int PREFIX##_set1_##FIELD(OSSL_CMP_CTX *ctx, TYPE *val) \
return 1; \
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
DEFINE_OSSL_set1_up_ref(ossl_cmp_ctx, validatedSrvCert, X509)
#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/*
* Pins the server certificate to be directly trusted (even if it is expired)
Expand Down Expand Up @@ -783,10 +775,8 @@ DEFINE_OSSL_CMP_CTX_set1(p10CSR, X509_REQ)
*/
DEFINE_OSSL_set0(ossl_cmp_ctx, newCert, X509)

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
/* Get successfully validated server cert, if any, of current transaction */
DEFINE_OSSL_CMP_CTX_get0(validatedSrvCert, X509)
#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/*
* Get the (newly received in IP/KUP/CP) client certificate from the context
Expand Down Expand Up @@ -1062,5 +1052,3 @@ int OSSL_CMP_CTX_get_option(const OSSL_CMP_CTX *ctx, int opt)
return -1;
}
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#ifndef OPENSSL_NO_CMP

# if OPENSSL_VERSION_NUMBER <= 0x30200000L

# ifndef OPENSSL_NO_ERR

static const ERR_STRING_DATA CMP_str_reasons[] = {
Expand Down Expand Up @@ -184,8 +182,6 @@ int ossl_err_load_CMP_strings(void)
return 1;
}

# endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */

#else
NON_EMPTY_TRANSLATION_UNIT
#endif
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_hdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <openssl/cmp.h>
#include <openssl/err.h>

#if OPENSSL_VERSION_NUMBER <= 0x30300000L

int ossl_cmp_hdr_set_pvno(OSSL_CMP_PKIHEADER *hdr, int pvno)
{
if (!ossl_assert(hdr != NULL))
Expand Down Expand Up @@ -370,5 +368,3 @@ int ossl_cmp_hdr_init(OSSL_CMP_CTX *ctx, OSSL_CMP_PKIHEADER *hdr)

return 1;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include <openssl/buffer.h>
#include <openssl/err.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

#define DEFAULT_RETRY_AFTER 60 /* one minute */

static int keep_alive(int keep_alive, int body_type, BIO *bio)
Expand Down Expand Up @@ -120,5 +118,3 @@ OSSL_CMP_MSG *OSSL_CMP_MSG_http_perform(OSSL_CMP_CTX *ctx,
sk_CONF_VALUE_pop_free(headers, X509V3_conf_free);
return res;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
3 changes: 0 additions & 3 deletions crypto/cmp/cmp_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
*/
#endif

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

OSSL_CMP_MSG *OSSL_CMP_MSG_new(OSSL_LIB_CTX *libctx, const char *propq)
{
OSSL_CMP_MSG *msg = NULL;
Expand Down Expand Up @@ -1276,4 +1274,3 @@ int ossl_cmp_is_error_with_waiting(const OSSL_CMP_MSG *msg)
&& ossl_cmp_pkisi_get_status(msg->body->value.error->pKIStatusInfo)
== OSSL_CMP_PKISTATUS_waiting);
}
#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_protect.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <openssl/err.h>
#include <openssl/x509.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/*
* This function is also used by the internal verify_PBMAC() in cmp_vfy.c.
*
Expand Down Expand Up @@ -318,5 +316,3 @@ int ossl_cmp_msg_protect(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg)
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PROTECTING_MESSAGE);
return 0;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include <openssl/cmp.h>
#include <openssl/err.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/* the context for the generic CMP server */
struct ossl_cmp_srv_ctx_st
{
Expand Down Expand Up @@ -774,5 +772,3 @@ OSSL_CMP_MSG *OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx,

return OSSL_CMP_SRV_process_request(srv_ctx, req);
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include <openssl/objects.h>
#include <openssl/x509.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/* CMP functions related to PKIStatus */

int ossl_cmp_pkisi_get_status(const OSSL_CMP_PKISI *si)
Expand Down Expand Up @@ -312,5 +310,3 @@ OSSL_CMP_PKISI *OSSL_CMP_STATUSINFO_new(int status, int fail_info,
ASN1_UTF8STRING_free(utf8_text);
return NULL;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/cmp/cmp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include <openssl/err.h> /* should be implied by cmperr.h */
#include <openssl/x509v3.h>

#if OPENSSL_VERSION_NUMBER <= 0x30300000L

/*
* use trace API for CMP-specific logging, prefixed by "CMP " and severity
*/
Expand Down Expand Up @@ -297,5 +295,3 @@ int ossl_cmp_asn1_octet_string_set1_bytes(ASN1_OCTET_STRING **tgt,
*tgt = new;
return 1;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30300000L */
3 changes: 0 additions & 3 deletions crypto/cmp/cmp_vfy.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <openssl/err.h>
#include <openssl/x509.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

/* Verify a message protected by signature according to RFC section 5.1.3.3 */
static int verify_signature(const OSSL_CMP_CTX *cmp_ctx,
const OSSL_CMP_MSG *msg, X509 *cert)
Expand Down Expand Up @@ -907,4 +905,3 @@ int ossl_cmp_verify_popo(const OSSL_CMP_CTX *ctx,
return 1;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
12 changes: 6 additions & 6 deletions crypto/crmf/crmf_asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ASN1_NDEF_SEQUENCE(CMS_EnvelopedData) = {
/* explicit #includes not strictly needed since implied by the above: */
#include <openssl/crmf.h>

#if OPENSSL_VERSION_NUMBER <= 0x30200000L
#if 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L

ASN1_SEQUENCE(OSSL_CRMF_PRIVATEKEYINFO) = {
ASN1_SIMPLE(OSSL_CRMF_PRIVATEKEYINFO, version, ASN1_INTEGER),
Expand Down Expand Up @@ -87,7 +87,7 @@ ASN1_SEQUENCE(OSSL_CRMF_ENCRYPTEDVALUE) = {
} ASN1_SEQUENCE_END(OSSL_CRMF_ENCRYPTEDVALUE)
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE)

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
#endif /* 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L */

/*
* Note from CMP Updates defining CMPv3:
Expand All @@ -102,7 +102,7 @@ ASN1_CHOICE(OSSL_CRMF_ENCRYPTEDKEY) = {
} ASN1_CHOICE_END(OSSL_CRMF_ENCRYPTEDKEY)
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDKEY)

#if OPENSSL_VERSION_NUMBER <= 0x30200000L
#if 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L

ASN1_SEQUENCE(OSSL_CRMF_SINGLEPUBINFO) = {
ASN1_SIMPLE(OSSL_CRMF_SINGLEPUBINFO, pubMethod, ASN1_INTEGER),
Expand Down Expand Up @@ -180,7 +180,7 @@ ASN1_CHOICE(OSSL_CRMF_POPO) = {
} ASN1_CHOICE_END(OSSL_CRMF_POPO)
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
#endif /* 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L */

ASN1_ADB_TEMPLATE(attributetypeandvalue_default) =
ASN1_OPT(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, value.other, ASN1_ANY);
Expand Down Expand Up @@ -272,7 +272,7 @@ ASN1_SEQUENCE(OSSL_CRMF_CERTREQUEST) = {
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST)
IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST)

#if OPENSSL_VERSION_NUMBER <= 0x30200000L
#if 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L

ASN1_SEQUENCE(OSSL_CRMF_MSG) = {
ASN1_SIMPLE(OSSL_CRMF_MSG, certReq, OSSL_CRMF_CERTREQUEST),
Expand All @@ -289,4 +289,4 @@ ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_MSGS)

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
#endif /* 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/crmf/crmf_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#ifndef OPENSSL_NO_CRMF

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

# ifndef OPENSSL_NO_ERR

static const ERR_STRING_DATA CRMF_str_reasons[] = {
Expand Down Expand Up @@ -83,8 +81,6 @@ int ossl_err_load_CRMF_strings(void)
return 1;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */

#else
NON_EMPTY_TRANSLATION_UNIT
#endif
8 changes: 2 additions & 6 deletions crypto/crmf/crmf_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
IMPLEMENT_ASN1_DUP_FUNCTION(X509_PUBKEY)
#endif

#if OPENSSL_VERSION_NUMBER <= 0x30200000L
/*-
* atyp = Attribute Type
* valt = Value Type
Expand Down Expand Up @@ -616,7 +615,7 @@ int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl,
}

#ifndef OPENSSL_NO_CMS
#if OPENSSL_VERSION_NUMBER < 0x30200000L
# if OPENSSL_VERSION_NUMBER < 0x30200000L
/* added to OpenSSL 3.1 in #18301 */
BIO *CMS_EnvelopedData_decrypt(CMS_EnvelopedData *env, BIO *detached_data,
EVP_PKEY *pkey, X509 *cert,
Expand All @@ -629,9 +628,8 @@ BIO *CMS_SignedData_verify(CMS_SignedData *sd, BIO *detached_data,
STACK_OF(X509) *extra, STACK_OF(X509_CRL) *crls,
unsigned int flags,
OSSL_LIB_CTX *libctx, const char *propq);
#endif
# endif
#endif /* OPENSSL_NO_CMS */
#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */

#ifndef OPENSSL_NO_CMS
DECLARE_ASN1_ITEM(CMS_SignedData) /* copied from cms_local.h */
Expand Down Expand Up @@ -934,7 +932,6 @@ X509
return NULL;
#endif /* OPENSSL_NO_CMS */
}
#if OPENSSL_VERSION_NUMBER < 0x30200000L

#ifndef OPENSSL_NO_CMS
# if OPENSSL_VERSION_NUMBER <= 0x30200000L
Expand Down Expand Up @@ -1052,4 +1049,3 @@ BIO *CMS_SignedData_verify(CMS_SignedData *sd, BIO *detached_data,

# endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
#endif /* OPENSSL_NO_CMS */
#endif /* OPENSSL_VERSION_NUMBER < 0x30200000L */
8 changes: 4 additions & 4 deletions crypto/crmf/crmf_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct ossl_crmf_encryptedkey_st {
} value;
} /* OSSL_CRMF_ENCRYPTEDKEY */;

# if OPENSSL_VERSION_NUMBER <= 0x30200000L
# if 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L

/*-
* Attributes ::= SET OF Attribute
Expand Down Expand Up @@ -303,7 +303,7 @@ typedef struct ossl_crmf_popo_st {
} value;
} OSSL_CRMF_POPO;
DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
#endif /* 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L */

/*-
* OptionalValidity ::= SEQUENCE {
Expand Down Expand Up @@ -362,7 +362,7 @@ struct ossl_crmf_certrequest_st {
} /* OSSL_CRMF_CERTREQUEST */;
DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST)
DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST)
#if OPENSSL_VERSION_NUMBER <= 0x30200000L
#if 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L

/* ossl_crmf_attributetypeandvalue_st decl is in include/internal/crmf.h */

Expand All @@ -383,6 +383,6 @@ struct ossl_crmf_msg_st {
STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *regInfo;
} /* OSSL_CRMF_MSG */;

# endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
# endif /* 1 || OPENSSL_VERSION_NUMBER <= 0x30200000L */

#endif /* !defined(OSSL_CRYPTO_CRMF_LOCAL_H) */
4 changes: 0 additions & 4 deletions crypto/crmf/crmf_pbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

#include "crmf_local.h"

#if OPENSSL_VERSION_NUMBER < 0x30200000L

/*-
* creates and initializes OSSL_CRMF_PBMPARAMETER (section 4.4)
* |slen| SHOULD be at least 8 (16 is common)
Expand Down Expand Up @@ -257,5 +255,3 @@ int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq,
}
return 0;
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
4 changes: 0 additions & 4 deletions crypto/http/http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "internal/sockets.h"
#include "internal/common.h" /* for ossl_assert() */

#if OPENSSL_VERSION_NUMBER <= 0x30200000L

#define HTTP_PREFIX "HTTP/"
#define HTTP_VERSION_PATT "1." /* allow 1.x */
#define HTTP_VERSION_STR_LEN sizeof(HTTP_VERSION_PATT) /* == strlen("1.0") */
Expand Down Expand Up @@ -1683,5 +1681,3 @@ int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port,
return ret;
#undef BUF_SIZE
}

#endif /* OPENSSL_VERSION_NUMBER <= 0x30200000L */
Loading

0 comments on commit ac1dd51

Please sign in to comment.