Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible use word32 before define when use in Contiki-NG #3117

Closed
kam193 opened this issue Jul 8, 2020 · 5 comments
Closed

Possible use word32 before define when use in Contiki-NG #3117

kam193 opened this issue Jul 8, 2020 · 5 comments
Assignees

Comments

@kam193
Copy link

kam193 commented Jul 8, 2020

When use on Contiki-NG (define WOLFSSL_CONTIKI) , word32 is used before defined because of use in settings.h.

word32 is defined in types.h

#include <wolfssl/wolfcrypt/settings.h>

typedef unsigned int word32;

But it first includes settings.h which contains following define:

#if defined(WOLFSSL_CONTIKI)
#include <contiki.h>
#define WOLFSSL_UIP
#define NO_WOLFSSL_MEMORY
#define NO_WRITEV
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#define CUSTOM_RAND_TYPE uint16_t
#define CUSTOM_RAND_GENERATE random_rand
static inline word32 LowResTimer(void)
{
return clock_seconds();
}
#endif

This results in following error:

  CC        /home/user/contiki-ng/tools/wolfssl/wolfcrypt/src/aes.c
In file included from /home/user/contiki-ng/tools/wolfssl/wolfcrypt/src/aes.c:27:0:
/home/user/contiki-ng/tools/wolfssl/wolfssl/wolfcrypt/settings.h:326:19: error: unknown type name 'word32'
     static inline word32 LowResTimer(void)
                   ^
@kam193
Copy link
Author

kam193 commented Jul 8, 2020

Going deeper:

  • in internal.c there is a place for defining LowResTimer, but without options for WOLFSSL_CONTIKI. So it's not only using word32 before defining, but also redefining of function
  • using random_rand requires including lib/random.h (from Contiki-NG)

@danielinux
Copy link
Member

Hello @kam193 - thanks for reporting this.

There is a patch we maintain on top of contiki-os/contiki, but I did not look into a port for contiki-ng yet.

On contiki-os we created this glue module that can be used to initialize and connect TLS and DTLS sockets on top of Contiki's uIP sockets, which you can find here.
The WOLFSSL_CONTIKI define is intended for use with that module, but I am not sure that it could be adapted "as is" in Contiki-NG as well.

Is there a way to include third-party modules like in the original contiki-os? What would be the best way to propose a wolfSSL module for inclusion there? I see that the directory structure is different than the original contiki-os, and there is no apps/ directory.
I have quickly looked into the contiki-ng documentation but I could not find any indication on how to integrate third party libraries in the repository.

Would you mind sharing with us more details about your current configuration and environment setup? We'll be happy to help defining a generic platform for TLS/DTLS sockets, and make the required configuration options available in the library for proper integration in the OS.

Thanks,

--
Daniele

@danielinux danielinux self-assigned this Jul 9, 2020
@kam193
Copy link
Author

kam193 commented Jul 9, 2020

Hello,

I'm currently during investigation how to integrate wolfSSL and Contiki-NG in the clean way in my project (but I probably will need only a wolfcrypt, so maybe my integration will contain only part). I'm basing e.g. on PR with your module (contiki-os/contiki#2500).

Unfortunately I cannot answer your questions with 100% sure. Currently, to compile Contiki-NG with wolfSSL I use extending CONTIKI_SOURCEFILES and CFLAGS in Makefile (very similar to your PR; the build system is partially described here). When I find the best way to integrate wolfSSL, I will back here.

The main problem I reported - redefining LowResTimer - looks like not Contiki nor Conitki-NG specific, but rather like forgotten when other definitions was moved into internal.c.

For now, I see a few other small incompatibilities with Contiki-NG caused by missed including headers. I think I'll prepare a PR with required changes after successfully integration.

@danielinux
Copy link
Member

Thanks for the clarification! We'll be looking forward to receiving your proposed changes.

Best Regards,

--
Daniele

@danielinux
Copy link
Member

Hi @kam193
I'm closing this issue for now. Feel free to re-open if you find a configuration that works with contiki-ng code, or if you want to propose changes.

Best Regards,

--
Daniele

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants