mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-03-07 02:14:03 +01:00
Fixed issues building with nocrypt. Improved logic on ASN_BER_TO_DER. Improved logic on unknown extension callback (new WC_ASN_UNKNOWN_EXT_CB gate).
This commit is contained in:
@@ -3660,7 +3660,7 @@ int StreamOctetString(const byte* inBuf, word32 inBufSz, byte* out, word32* outS
|
||||
|
||||
/* Convert BER to DER */
|
||||
|
||||
/* Pull informtation from the ASN.1 BER encoded item header */
|
||||
/* Pull information from the ASN.1 BER encoded item header */
|
||||
static int GetBerHeader(const byte* data, word32* idx, word32 maxIdx,
|
||||
byte* pTag, word32* pLen, int* indef)
|
||||
{
|
||||
@@ -6226,7 +6226,8 @@ static int RsaPssHashOidToMgf1(word32 oid, int* mgf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef NO_CERTS
|
||||
#if !defined(NO_CERTS) && !defined(NO_ASN_CRYPT)
|
||||
|
||||
/* Convert a hash OID to a fake signature OID.
|
||||
*
|
||||
* @param [in] oid Hash OID.
|
||||
@@ -21407,8 +21408,7 @@ enum {
|
||||
#define certExtASN_Length (sizeof(certExtASN) / sizeof(ASNItem))
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \
|
||||
&& defined(HAVE_OID_DECODING)
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
int wc_SetUnknownExtCallback(DecodedCert* cert,
|
||||
wc_UnknownExtCallback cb) {
|
||||
if (cert == NULL) {
|
||||
@@ -21429,7 +21429,7 @@ int wc_SetUnknownExtCallbackEx(DecodedCert* cert,
|
||||
cert->unknownExtCallbackExCtx = ctx;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* WC_ASN_UNKNOWN_EXT_CB */
|
||||
|
||||
/*
|
||||
* Processing the Certificate Extensions. This does not modify the current
|
||||
@@ -21583,7 +21583,7 @@ end:
|
||||
/* Decode the extension by type. */
|
||||
ret = DecodeExtensionType(input + idx, length, oid, critical, cert,
|
||||
&isUnknownExt);
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(HAVE_OID_DECODING)
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
if (isUnknownExt && (cert->unknownExtCallback != NULL ||
|
||||
cert->unknownExtCallbackEx != NULL)) {
|
||||
word16 decOid[MAX_OID_SZ];
|
||||
@@ -21612,8 +21612,9 @@ end:
|
||||
cert->unknownExtCallbackExCtx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
(void)isUnknownExt;
|
||||
#endif
|
||||
|
||||
/* Move index on to next extension. */
|
||||
idx += length;
|
||||
@@ -34482,7 +34483,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
#endif /* WOLFSSL_ASN_TEMPLATE */
|
||||
}
|
||||
|
||||
#if defined(HAVE_ECC_KEY_EXPORT) && !defined(NO_ASN_CRYPT)
|
||||
#ifdef HAVE_ECC_KEY_EXPORT
|
||||
/* build DER formatted ECC key, include optional public key if requested,
|
||||
* return length on success, negative on error */
|
||||
int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen,
|
||||
@@ -34913,7 +34914,7 @@ int wc_EccKeyToPKCS8(ecc_key* key, byte* output,
|
||||
return eccToPKCS8(key, output, outLen, 1);
|
||||
}
|
||||
#endif /* HAVE_PKCS8 */
|
||||
#endif /* HAVE_ECC_KEY_EXPORT && !NO_ASN_CRYPT */
|
||||
#endif /* HAVE_ECC_KEY_EXPORT */
|
||||
#endif /* HAVE_ECC */
|
||||
|
||||
#ifdef WC_ENABLE_ASYM_KEY_IMPORT
|
||||
|
||||
@@ -830,8 +830,7 @@ int wc_PKCS7_Init(PKCS7* pkcs7, void* heap, int devId)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \
|
||||
&& defined(HAVE_OID_DECODING)
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
void wc_PKCS7_SetUnknownExtCallback(PKCS7* pkcs7, wc_UnknownExtCallback cb)
|
||||
{
|
||||
if (pkcs7 != NULL) {
|
||||
@@ -1083,8 +1082,7 @@ int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz)
|
||||
int devId;
|
||||
Pkcs7Cert* cert;
|
||||
Pkcs7Cert* lastCert;
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \
|
||||
&& defined(HAVE_OID_DECODING)
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
wc_UnknownExtCallback cb;
|
||||
#endif
|
||||
|
||||
@@ -1095,16 +1093,14 @@ int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz)
|
||||
heap = pkcs7->heap;
|
||||
devId = pkcs7->devId;
|
||||
cert = pkcs7->certList;
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \
|
||||
&& defined(HAVE_OID_DECODING)
|
||||
cb = pkcs7->unknownExtCallback;
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
cb = pkcs7->unknownExtCallback; /* save / restore callback */
|
||||
#endif
|
||||
ret = wc_PKCS7_Init(pkcs7, heap, devId);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \
|
||||
&& defined(HAVE_OID_DECODING)
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
pkcs7->unknownExtCallback = cb;
|
||||
#endif
|
||||
pkcs7->certList = cert;
|
||||
@@ -1155,8 +1151,7 @@ int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* derCert, word32 derCertSz)
|
||||
}
|
||||
|
||||
InitDecodedCert(dCert, derCert, derCertSz, pkcs7->heap);
|
||||
#if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) \
|
||||
&& defined(HAVE_OID_DECODING)
|
||||
#ifdef WC_ASN_UNKNOWN_EXT_CB
|
||||
if (pkcs7->unknownExtCallback != NULL)
|
||||
wc_SetUnknownExtCallback(dCert, pkcs7->unknownExtCallback);
|
||||
#endif
|
||||
|
||||
@@ -711,9 +711,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t mp_test(void);
|
||||
#if defined(WOLFSSL_PUBLIC_MP) && defined(WOLFSSL_KEY_GEN)
|
||||
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t prime_test(void);
|
||||
#endif
|
||||
#if defined(ASN_BER_TO_DER) && \
|
||||
(defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \
|
||||
defined(OPENSSL_EXTRA_X509_SMALL))
|
||||
#ifdef ASN_BER_TO_DER
|
||||
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t berder_test(void);
|
||||
#endif
|
||||
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t logging_test(void);
|
||||
@@ -53957,9 +53955,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t prime_test(void)
|
||||
#endif /* WOLFSSL_PUBLIC_MP */
|
||||
|
||||
|
||||
#if defined(ASN_BER_TO_DER) && \
|
||||
(defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \
|
||||
defined(OPENSSL_EXTRA_X509_SMALL))
|
||||
#ifdef ASN_BER_TO_DER
|
||||
/* wc_BerToDer is only public facing in the case of test cert or opensslextra */
|
||||
typedef struct berDerTestData {
|
||||
const byte *in;
|
||||
@@ -54075,7 +54071,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t berder_test(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* ASN_BER_TO_DER */
|
||||
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
static THREAD_LS_T int log_cnt = 0;
|
||||
|
||||
Reference in New Issue
Block a user