Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
# include "hmac.h"
#endif /* WITH_SHA256 */

#ifdef DTLS_ECC
#include "ext/micro-ecc/uECC.h"
#endif /* DTLS_ECC */

#ifdef WITH_ZEPHYR
LOG_MODULE_DECLARE(TINYDTLS, CONFIG_TINYDTLS_LOG_LEVEL);
#endif /* WITH_ZEPHYR */
Expand Down Expand Up @@ -326,6 +330,14 @@ free_context(dtls_context_t *context) {

#endif /* WITH_POSIX */

#ifdef DTLS_ECC
/* Define wrapper function for uECC_set_rng to map the size parameter
* from unsigned int to size_t. */
static inline int uecc_rng_function(uint8_t *dest, unsigned int size) {
return dtls_prng(dest, size);
}
#endif /* DTLS_ECC */

void
dtls_init(void) {
dtls_clock_init();
Expand All @@ -337,6 +349,9 @@ dtls_init(void) {
memarray_init(&dtlscontext_storage, dtlscontext_storage_data,
sizeof(dtls_context_t), DTLS_CONTEXT_MAX);
#endif /* RIOT_VERSION */
#ifdef DTLS_ECC
uECC_set_rng(uecc_rng_function);
#endif /* DTLS_ECC */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that could be moved to "crypto.c". In my opinion, that would limit the scope of "ecc-related changes" to crypto.

}

/* Calls cb_alert() with given arguments if defined, otherwise an
Expand Down