1 (edited by Scotty2541 2021-03-22 08:31:53)

Topic: Cannot use X509 calls in TI_RTOS

Hey Kaleb, (or anyone else...)

In the TI_RTOS world, using CCS,  I am trying to load an X509 cert just to examine it.  Logically the functions are:

wolfSSL_X509_load_certificate_buffer()
wolfSSL_X509_get_subject_name()
wolfSSL_X509_NAME_get_entry()

etc...
Except these were unresolved at the linker stage.

So the next logical step was to see what needs to be defined:

#if defined(OPENSSL_EXTRA_X509_SMALL) || defined(KEEP_PEER_CERT) || \
    defined(SESSION_CERTS)

wolfSSL_X509_get_subject_name(  X509)

Okay, so I need OPENSSL_EXTRA_X509_SMALL

But

#if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) || \
    defined(KEEP_PEER_CERT) || defined(SESSION_CERTS)

WOLFSSL_X509* wolfSSL_X509_load_certificate_buffer(...)

This needs OPENSSL_EXTRA

So that looks weird...  You define OPENSSL_EXTRA_X509_SMALL to get the subject name from an X509...  But you can't load an X509 unless you define OPENSSL_EXTRA ??

But that's not what is broken...

In Wolf/src/ssl.c : Line 310087  (in version 4-7) 

/* These constant values are protocol values made by egd */
#if defined(USE_WOLFSSL_IO) && !defined(USE_WINDOWS_API)
    #define WOLFSSL_EGD_NBLOCK 0x01
    #include <sys/un.h>
#endif

Well, TI/CCS has never heard of the header file "un.h".  It's not included in any of the NDK 2-25 or 3-61.  Nor is it in any of the TI compilers, or the GNU compilers they package with CCS.

What am I supposed to do?  I can't comment it out, as there are several functions that use the sockaddr_un structure which is unheard of.  I imagine (but haven't tried) if I try to take that header from from a unix/linux environment, there will be additional conflict and missing declarations.

So as it stands now, the X509 functions can't be used in TI-RTOS because the library wants to include support for Unix local interprocess functions (which are not used in TI_RTOS)

Any suggestions?

-Scott
<Code shown is not to scale>

Share

Re: Cannot use X509 calls in TI_RTOS

Hello Scotty2541,

Sounds like there could be a missing check for TI_RTOS. Would you please let us know if this fixes the build issue?

diff --git a/src/ssl.c b/src/ssl.c
index 7432ffe73..486b3129a 100644
--- a/src/ssl.c
+++ b/src/ssl.c
@@ -31736,7 +31736,7 @@ int wolfSSL_RAND_write_file(const char* fname)
     return bytes;
 }
 
-#ifndef FREERTOS_TCP
+#if !defined(FREERTOS_TCP) && !defined(WOLFSSL_TIRTOS)
 
 /* These constant values are protocol values made by egd */
 #if defined(USE_WOLFSSL_IO) && !defined(USE_WINDOWS_API)

Kind regards,
Eric @ wolfSSL Support

Re: Cannot use X509 calls in TI_RTOS

No, I have no idea what that is.

I don't use GIT, and don't run DIFF in my Windows environment...  Please don't assume your environment is a standard, used by everyone in the world.

if "-31736   +31736"  is supposed to be a line number is src/ssl.c  then it's smack in the middle of the "SetDhInternal()" function.  And sure to break my source.  And 700 lines away from what I was referring to.

-Scott
<Code shown is not to scale>

Share

Re: Cannot use X509 calls in TI_RTOS

Scotty2541 wrote:

In Wolf/src/ssl.c : Line 310087  (in version 4-7) 

/* These constant values are protocol values made by egd */
#if defined(USE_WOLFSSL_IO) && !defined(USE_WINDOWS_API)
    #define WOLFSSL_EGD_NBLOCK 0x01
    #include <sys/un.h>
#endif

A couple lines above this, this compiler conditional

#ifndef FREERTOS_TCP

should be changed to:

#if !defined(FREERTOS_TCP) && !defined(WOLFSSL_TIRTOS)

Please let us know if this resolves the issue for your environment.

Re: Cannot use X509 calls in TI_RTOS

No, that just breaks more stuff...

I had to FABRICATE some of the identifiers which were needed from <sys/un.h>

Because TI NDK doesn't have a "socket" in a reasonable location ( including it generates even MORE conflicts with WOLF headers because WOLF seems to think it has to provide definitions for things that are already there)

So I also had to #define socket(a,b,c)  ( (int) NDK_socket(a,b,c) )

-Scott
<Code shown is not to scale>

Share