Skip to content

Commit

Permalink
PR7648 20240418-exosip-apis peer review:
Browse files Browse the repository at this point in the history
* tweak typography;
* move wolfSSL_i2d_X509_PUBKEY() from ssl.c to x509.c;
* in asn.h, add !NO_ASN_OLD_TYPE_NAMES macros to remap old names (ISSUER, SUBJECT, BEFORE, AFTER) by default unless the macros are already defined.
  • Loading branch information
douzzer committed Jul 17, 2024
1 parent 9023aee commit ee7748f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len)
}

#ifdef WOLFSSL_BIO_HAVE_FLOW_STATS
if ((ret > 0) && (! inhibit_flow_increment)) {
if ((ret > 0) && (!inhibit_flow_increment)) {
bio->bytes_read += (word32)ret;
}
#endif
Expand Down Expand Up @@ -902,7 +902,8 @@ long wolfSSL_BIO_ctrl(WOLFSSL_BIO *bio, int cmd, long larg, void *parg)
if (parg == NULL) {
wolfSSL_BIO_ADDR_clear(&bio->peer_addr);
bio->connected = 0;
} else {
}
else {
socklen_t addr_size = wolfSSL_BIO_ADDR_size((WOLFSSL_BIO_ADDR *)parg);
if (addr_size == 0) {
ret = WOLFSSL_FAILURE;
Expand Down
7 changes: 0 additions & 7 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7347,13 +7347,6 @@ int wolfSSL_i2d_PUBKEY(const WOLFSSL_EVP_PKEY *key, unsigned char **der)
return wolfSSL_i2d_PublicKey(key, der);
}

int wolfSSL_i2d_X509_PUBKEY(WOLFSSL_X509_PUBKEY* x509_PubKey, unsigned char** der)
{
if (x509_PubKey == NULL)
return WOLFSSL_FATAL_ERROR;
return wolfSSL_i2d_PublicKey(x509_PubKey->pkey, der);
}

#endif /* OPENSSL_EXTRA && !NO_CERTS && !NO_ASN && !NO_PWDBASED */

static WOLFSSL_EVP_PKEY* _d2i_PublicKey(int type, WOLFSSL_EVP_PKEY** out,
Expand Down
3 changes: 2 additions & 1 deletion src/wolfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,8 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
#ifdef HAVE_IO_TIMEOUT
if ((ret != 0) && (to_sec > 0)) {
#ifdef USE_WINDOWS_API
if ((ret == SOCKET_ERROR) && (wolfSSL_LastError(ret, *sockfd) == SOCKET_EWOULDBLOCK))
if ((ret == SOCKET_ERROR) &&
(wolfSSL_LastError(ret, *sockfd) == SOCKET_EWOULDBLOCK))
#else
if (errno == EINPROGRESS)
#endif
Expand Down
11 changes: 11 additions & 0 deletions src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -9592,6 +9592,17 @@ int wolfSSL_X509_PUBKEY_set(WOLFSSL_X509_PUBKEY **x, WOLFSSL_EVP_PKEY *key)

#endif /* OPENSSL_ALL || WOLFSSL_APACHE_HTTPD || WOLFSSL_HAPROXY || WOLFSSL_WPAS */

#if !defined(NO_CERTS) && !defined(NO_ASN) && !defined(NO_PWDBASED)

int wolfSSL_i2d_X509_PUBKEY(WOLFSSL_X509_PUBKEY* x509_PubKey, unsigned char** der)
{
if (x509_PubKey == NULL)
return WOLFSSL_FATAL_ERROR;
return wolfSSL_i2d_PublicKey(x509_PubKey->pkey, der);
}

#endif /* !NO_CERTS && !NO_ASN && !NO_PWDBASED */

#endif /* OPENSSL_EXTRA */

#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
Expand Down
15 changes: 15 additions & 0 deletions wolfssl/wolfcrypt/asn.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ enum {
ASN_AFTER = 1
};

#ifndef NO_ASN_OLD_TYPE_NAMES
#ifndef ISSUER
#define ISSUER ASN_ISSUER
#endif
#ifndef SUBJECT
#define SUBJECT ASN_SUBJECT
#endif
#ifndef BEFORE
#define BEFORE ASN_BEFORE
#endif
#ifndef AFTER
#define AFTER ASN_AFTER
#endif
#endif

/* ASN Tags */
enum ASN_Tags {
ASN_EOC = 0x00,
Expand Down

0 comments on commit ee7748f

Please sign in to comment.