Skip to content

Commit

Permalink
Add #ifdef cplus_plus to sl_bt_stack_init and sl_malloc because they …
Browse files Browse the repository at this point in the history
…are included in c++ files in CHIP

fix re declaration of the same variables in psa_crypto.c and sl_se_manager_cipher.c
  • Loading branch information
jmartinez-silabs committed Apr 6, 2021
1 parent 678fc06 commit 276dfe4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
8 changes: 8 additions & 0 deletions protocol/bluetooth/inc/sl_bt_stack_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#ifndef SL_BT_STACK_INIT_H
#define SL_BT_STACK_INIT_H

#ifdef __cplusplus
extern "C" {
#endif

#include "sl_status.h"
#include "sl_bt_api.h"
#include "sl_bt_stack_config.h"
Expand Down Expand Up @@ -173,4 +177,8 @@ static inline void sl_bt_init_whitelisting()
*/
sl_status_t sl_bt_init_classes(const struct sli_bgapi_class * const * classes);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions util/silicon_labs/silabs_core/memory_manager/sl_malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@
#ifndef SL_MALLOC_H
#define SL_MALLOC_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

void *sl_malloc(size_t size);
void *sl_calloc(size_t nmemb, size_t size);
void *sl_realloc(void * ptr, size_t size);
void sl_free(void * ptr);

#ifdef __cplusplus
}
#endif

#endif // SL_MALLOC_H
4 changes: 2 additions & 2 deletions util/third_party/crypto/mbedtls/library/psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ static psa_status_t psa_internal_export_key( const psa_key_slot_t *slot,
#if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_KEY_PAIR) || \
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_RSA_PUBLIC_KEY)
mbedtls_rsa_context *rsa = NULL;
psa_status_t status = psa_load_rsa_representation(
status = psa_load_rsa_representation(
slot->attr.type,
slot->data.key.data,
slot->data.key.bytes,
Expand Down Expand Up @@ -1648,7 +1648,7 @@ static psa_status_t psa_internal_export_key( const psa_key_slot_t *slot,
#if defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR) || \
defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_PUBLIC_KEY)
mbedtls_ecp_keypair *ecp = NULL;
psa_status_t status = psa_load_ecp_representation(
status = psa_load_ecp_representation(
slot->attr.type,
slot->data.key.data,
slot->data.key.bytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,8 @@ sl_status_t sl_se_gcm_starts(sl_se_gcm_streaming_context_t *gcm_ctx,
}

{
SE_DataTransfer_t iv_in = SE_DATATRANSFER_DEFAULT(iv, iv_len);
SE_DataTransfer_t add_in = SE_DATATRANSFER_DEFAULT(add, add_len);
iv_in = (SE_DataTransfer_t)SE_DATATRANSFER_DEFAULT(iv, iv_len);
add_in = (SE_DataTransfer_t)SE_DATATRANSFER_DEFAULT(add, add_len);
SE_DataTransfer_t ctx_out =
SE_DATATRANSFER_DEFAULT(gcm_ctx->se_ctx_enc, sizeof(gcm_ctx->se_ctx_enc));

Expand Down Expand Up @@ -1156,8 +1156,8 @@ sl_status_t sl_se_gcm_starts(sl_se_gcm_streaming_context_t *gcm_ctx,

// Do decryption if requested
if (gcm_ctx->mode == SL_SE_DECRYPT) {
SE_DataTransfer_t iv_in = SE_DATATRANSFER_DEFAULT((void*)iv, iv_len);
SE_DataTransfer_t add_in = SE_DATATRANSFER_DEFAULT((void*)add, add_len);
iv_in = (SE_DataTransfer_t)SE_DATATRANSFER_DEFAULT((void*)iv, iv_len);
add_in = (SE_DataTransfer_t)SE_DATATRANSFER_DEFAULT((void*)add, add_len);
SE_DataTransfer_t ctx_out = SE_DATATRANSFER_DEFAULT(gcm_ctx->se_ctx_dec,
sizeof(gcm_ctx->se_ctx_dec));

Expand Down

0 comments on commit 276dfe4

Please sign in to comment.