Skip to content

Commit 8f5797f

Browse files
committed
Use proper bitfield macro WC_BITFIELD for new AIA fields
1 parent 6a44159 commit 8f5797f

File tree

2 files changed

+75
-39
lines changed

2 files changed

+75
-39
lines changed

src/ssl.c

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8591,42 +8591,6 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** out,
85918591
#if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && !defined(NO_ASN) && \
85928592
!defined(NO_PWDBASED)
85938593

8594-
/* helper function to get raw pointer to DER buffer from WOLFSSL_EVP_PKEY */
8595-
static int wolfSSL_EVP_PKEY_get_der(const WOLFSSL_EVP_PKEY* key,
8596-
unsigned char** der)
8597-
{
8598-
int sz;
8599-
word16 pkcs8HeaderSz;
8600-
8601-
if (!key || !key->pkey_sz)
8602-
return WOLFSSL_FATAL_ERROR;
8603-
8604-
/* return the key without PKCS8 for compatibility */
8605-
/* if pkcs8HeaderSz is invalid, use 0 and return all of pkey */
8606-
pkcs8HeaderSz = 0;
8607-
if (key->pkey_sz > key->pkcs8HeaderSz)
8608-
pkcs8HeaderSz = key->pkcs8HeaderSz;
8609-
sz = key->pkey_sz - pkcs8HeaderSz;
8610-
if (der) {
8611-
unsigned char* pt = (unsigned char*)key->pkey.ptr;
8612-
if (*der) {
8613-
/* since this function signature has no size value passed in it is
8614-
* assumed that the user has allocated a large enough buffer */
8615-
XMEMCPY(*der, pt + pkcs8HeaderSz, (size_t)sz);
8616-
*der += sz;
8617-
}
8618-
else {
8619-
*der = (unsigned char*)XMALLOC((size_t)sz, NULL,
8620-
DYNAMIC_TYPE_OPENSSL);
8621-
if (*der == NULL) {
8622-
return WOLFSSL_FATAL_ERROR;
8623-
}
8624-
XMEMCPY(*der, pt + pkcs8HeaderSz, (size_t)sz);
8625-
}
8626-
}
8627-
return sz;
8628-
}
8629-
86308594
int wolfSSL_i2d_PUBKEY(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
86318595
{
86328596
return wolfSSL_i2d_PublicKey(key, der);
@@ -16305,6 +16269,43 @@ void wolfSSL_set_dynlock_destroy_callback(
1630516269
#ifndef NO_CERTS
1630616270

1630716271
#if !defined(NO_ASN) && !defined(NO_PWDBASED)
16272+
#if defined(OPENSSL_EXTRA)
16273+
/* helper function to get raw pointer to DER buffer from WOLFSSL_EVP_PKEY */
16274+
static int wolfSSL_EVP_PKEY_get_der(const WOLFSSL_EVP_PKEY* key,
16275+
unsigned char** der)
16276+
{
16277+
int sz;
16278+
word16 pkcs8HeaderSz;
16279+
16280+
if (!key || !key->pkey_sz)
16281+
return WOLFSSL_FATAL_ERROR;
16282+
16283+
/* return the key without PKCS8 for compatibility */
16284+
/* if pkcs8HeaderSz is invalid, use 0 and return all of pkey */
16285+
pkcs8HeaderSz = 0;
16286+
if (key->pkey_sz > key->pkcs8HeaderSz)
16287+
pkcs8HeaderSz = key->pkcs8HeaderSz;
16288+
sz = key->pkey_sz - pkcs8HeaderSz;
16289+
if (der) {
16290+
unsigned char* pt = (unsigned char*)key->pkey.ptr;
16291+
if (*der) {
16292+
/* since this function signature has no size value passed in it is
16293+
* assumed that the user has allocated a large enough buffer */
16294+
XMEMCPY(*der, pt + pkcs8HeaderSz, (size_t)sz);
16295+
*der += sz;
16296+
}
16297+
else {
16298+
*der = (unsigned char*)XMALLOC((size_t)sz, NULL,
16299+
DYNAMIC_TYPE_OPENSSL);
16300+
if (*der == NULL) {
16301+
return WOLFSSL_FATAL_ERROR;
16302+
}
16303+
XMEMCPY(*der, pt + pkcs8HeaderSz, (size_t)sz);
16304+
}
16305+
}
16306+
return sz;
16307+
}
16308+
1630816309
/* Copies unencrypted DER key buffer into "der". If "der" is null then the size
1630916310
* of buffer needed is returned. If *der == NULL then it allocates a buffer.
1631016311
* NOTE: This also advances the "der" pointer to be at the end of buffer.
@@ -16318,6 +16319,7 @@ int wolfSSL_i2d_PrivateKey(const WOLFSSL_EVP_PKEY* key, unsigned char** der)
1631816319

1631916320
int wolfSSL_i2d_PrivateKey_bio(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key)
1632016321
{
16322+
#ifndef NO_BIO
1632116323
int ret = WC_NO_ERR_TRACE(WOLFSSL_FAILURE);
1632216324
int derSz = 0;
1632316325
byte* der = NULL;
@@ -16353,6 +16355,11 @@ int wolfSSL_i2d_PrivateKey_bio(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key)
1635316355
cleanup:
1635416356
XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
1635516357
return ret;
16358+
#else
16359+
(void)bio;
16360+
(void)key;
16361+
return WOLFSSL_FAILURE;
16362+
#endif /* NO_BIO */
1635616363
}
1635716364

1635816365
int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
@@ -16487,6 +16494,28 @@ int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
1648716494
return WOLFSSL_FATAL_ERROR;
1648816495
#endif /* !NO_RSA || HAVE_ECC */
1648916496
}
16497+
#else /* OPENSSL_EXTRA_X509_SMALL only */
16498+
int wolfSSL_i2d_PrivateKey(const WOLFSSL_EVP_PKEY* key, unsigned char** der)
16499+
{
16500+
(void)key;
16501+
(void)der;
16502+
return WOLFSSL_FATAL_ERROR;
16503+
}
16504+
16505+
int wolfSSL_i2d_PrivateKey_bio(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key)
16506+
{
16507+
(void)bio;
16508+
(void)key;
16509+
return WOLFSSL_FAILURE;
16510+
}
16511+
16512+
int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
16513+
{
16514+
(void)key;
16515+
(void)der;
16516+
return WOLFSSL_FATAL_ERROR;
16517+
}
16518+
#endif /* OPENSSL_EXTRA */
1649016519
#endif /* !NO_ASN && !NO_PWDBASED */
1649116520

1649216521
#endif /* !NO_CERTS */
@@ -22955,13 +22984,20 @@ int wolfSSL_set_alpn_protos(WOLFSSL* ssl,
2295522984
#endif /* HAVE_ALPN */
2295622985
#endif /* OPENSSL_EXTRA */
2295722986

22958-
#if defined(OPENSSL_EXTRA)
22987+
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
2295922988

2296022989
#ifndef NO_BIO
2296122990
#define WOLFSSL_BIO_INCLUDED
2296222991
#include "src/bio.c"
2296322992
#endif
2296422993

22994+
<<<<<<< Updated upstream
22995+
=======
22996+
#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
22997+
22998+
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
22999+
23000+
>>>>>>> Stashed changes
2296523001
word32 nid2oid(int nid, int grp)
2296623002
{
2296723003
/* get OID type */

wolfssl/wolfcrypt/asn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,8 +2075,8 @@ struct DecodedCert {
20752075
#endif /* WOLFSSL_DUAL_ALG_CERTS */
20762076

20772077
WOLFSSL_AIA_ENTRY extAuthInfoList[WOLFSSL_MAX_AIA_ENTRIES];
2078-
byte extAuthInfoListSz:7;
2079-
byte extAuthInfoListOverflow:1;
2078+
WC_BITFIELD extAuthInfoListSz:7;
2079+
WC_BITFIELD extAuthInfoListOverflow:1;
20802080
};
20812081

20822082
#if defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3)

0 commit comments

Comments
 (0)