Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into enroll_using_otp
Browse files Browse the repository at this point in the history
  • Loading branch information
srieteja committed Dec 12, 2024
2 parents 7286612 + 70d8b46 commit 85f5023
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
8 changes: 8 additions & 0 deletions packages/atchops/include/atchops/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ extern "C" {
#endif

#include <atchops/platform.h> // IWYU pragma: keep

// Only define this if it isn't defined
// Consumers of the SDK should be able to override it so their personalization
// isn't open source
// TODO: later provide more intentional ways of forcing consumers of the SDK
// to override this
#ifndef ATCHOPS_RNG_PERSONALIZATION
#define ATCHOPS_RNG_PERSONALIZATION "@atchops12345"
#endif

#ifdef __cplusplus
}
Expand Down
7 changes: 3 additions & 4 deletions packages/atchops/src/uuid.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "atchops/uuid.h"
#include "atchops/constants.h"
#include <atchops/platform.h>
#include <atlogger/atlogger.h>
#include <stddef.h>
Expand Down Expand Up @@ -105,16 +106,14 @@ static int uuid4_init(void) {
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_entropy_context entropy;

// TODO replace this string
const unsigned char pers[13] = {"Arduino_Seed"};

size_t off = sizeof(uint64_t) / sizeof(unsigned char);
size_t n = off * 2;
unsigned char pointer[n]; // create char pointer to long number
mbedtls_ctr_drbg_init(&ctr_drbg);
mbedtls_entropy_init(&entropy);

ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, pers, sizeof(pers));
ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (unsigned char *)ATCHOPS_RNG_PERSONALIZATION,
sizeof(ATCHOPS_RNG_PERSONALIZATION));
if (ret != 0) {
mbedtls_ctr_drbg_free(&ctr_drbg);
mbedtls_entropy_free(&entropy);
Expand Down
16 changes: 8 additions & 8 deletions packages/atclient/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

file(GLOB_RECURSE files ${CMAKE_CURRENT_LIST_DIR}/test_*.c)
foreach(file ${files})
# ${filename} - without `.c`
get_filename_component(filename ${file} NAME)
string(REPLACE ".c" "" filename ${filename})
# ${filename} - without `.c`
get_filename_component(filename ${file} NAME)
string(REPLACE ".c" "" filename ${filename})

add_executable(${filename} ${file})
target_link_libraries(${filename} PRIVATE atclient)
add_test(NAME ${filename} COMMAND $<TARGET_FILE:${filename}>)
endforeach()

add_executable(${filename} ${file})
target_link_libraries(${filename} PRIVATE atclient)
add_test(NAME ${filename} COMMAND $<TARGET_FILE:${filename}>)
endforeach()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <cJSON.h>
#include <atcommons/json.h>
#include <stddef.h> // IWYU pragma: keep
#include <stdio.h>

Expand Down
10 changes: 5 additions & 5 deletions tests/functional_tests/tests/test_atclient_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,22 @@ static int test_2_notify_long_text(atclient *atclient, char *notification_id) {
goto exit;
}

if((ret = atclient_notify_params_set_operation(&params, ATCLIENT_NOTIFY_OPERATION_UPDATE)) != 0) {
if ((ret = atclient_notify_params_set_operation(&params, ATCLIENT_NOTIFY_OPERATION_UPDATE)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set operation: %d\n", ret);
goto exit;
}

if((ret = atclient_notify_params_set_atkey(&params, &atkey)) != 0) {
if ((ret = atclient_notify_params_set_atkey(&params, &atkey)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set atkey: %d\n", ret);
goto exit;
}

if((ret = atclient_notify_params_set_value(&params, VERY_LONG_TEXT)) != 0) {
if ((ret = atclient_notify_params_set_value(&params, VERY_LONG_TEXT)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set value: %d\n", ret);
goto exit;
}

if((ret = atclient_notify_params_set_should_encrypt(&params, true)) != 0) {
if ((ret = atclient_notify_params_set_should_encrypt(&params, true)) != 0) {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to set should_encrypt: %d\n", ret);
goto exit;
}
Expand All @@ -251,4 +251,4 @@ exit: {
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "test_2_notify_long_text End (%d)\n", ret);
return ret;
}
}
}

0 comments on commit 85f5023

Please sign in to comment.