diff options
author | Allen Webb <allenwebb@google.com> | 2018-11-09 09:42:53 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-15 13:16:06 -0800 |
commit | 1c95cff7463ef29bd0c6d087ce8c3d7e17f94c6a (patch) | |
tree | 90de208cb94b874a8fc3a8a1f1082116e908cc48 | |
parent | 268b07da45535033ae39240e958fc00386e37684 (diff) | |
download | chrome-ec-1c95cff7463ef29bd0c6d087ce8c3d7e17f94c6a.tar.gz |
cr50: Add extern "C" to headers used by future fuzzing target.
BRANCH=None
BUG=None
TEST=make -j buildall
Change-Id: Icf2cfb6a2657064c10721c0e527d24fbb3be6ab3
Signed-off-by: Allen Webb <allenwebb@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1330102
Reviewed-by: Mike Frysinger <vapier@chromium.org>
-rw-r--r-- | builtin/assert.h | 8 | ||||
-rw-r--r-- | builtin/endian.h | 7 | ||||
-rw-r--r-- | builtin/string.h | 8 | ||||
-rw-r--r-- | chip/g/dcrypto/dcrypto.h | 8 | ||||
-rw-r--r-- | chip/g/dcrypto/internal.h | 7 | ||||
-rw-r--r-- | chip/host/persistence.h | 8 | ||||
-rw-r--r-- | fuzz/cr50_fuzz.cc | 2 | ||||
-rw-r--r-- | include/crypto_api.h | 8 | ||||
-rw-r--r-- | include/nvmem.h | 8 | ||||
-rw-r--r-- | include/nvmem_vars.h | 8 | ||||
-rw-r--r-- | include/panic.h | 8 | ||||
-rw-r--r-- | include/pinweaver.h | 8 | ||||
-rw-r--r-- | include/pinweaver_tpm_imports.h | 8 | ||||
-rw-r--r-- | include/pinweaver_types.h | 8 | ||||
-rw-r--r-- | include/util.h | 8 |
15 files changed, 110 insertions, 2 deletions
diff --git a/builtin/assert.h b/builtin/assert.h index 6ee2ac1b20..a2a5dd0228 100644 --- a/builtin/assert.h +++ b/builtin/assert.h @@ -11,6 +11,10 @@ #include "common.h" #endif +#ifdef __cplusplus +extern "C" { +#endif + #ifdef CONFIG_DEBUG_ASSERT #ifdef CONFIG_DEBUG_ASSERT_REBOOTS @@ -46,4 +50,8 @@ extern void panic_assert_fail(const char *msg, const char *func, #define assert(x...) ASSERT(x) #endif +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_ASSERT_H__ */ diff --git a/builtin/endian.h b/builtin/endian.h index b27b7cd496..8a50cb4815 100644 --- a/builtin/endian.h +++ b/builtin/endian.h @@ -8,6 +8,10 @@ #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * Functions to convert byte order in various sized big endian integers to * host byte order. Note that the code currently does not require functions @@ -34,5 +38,8 @@ static inline uint64_t be64toh(uint64_t in) #endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ +#ifdef __cplusplus +} +#endif #endif /* __EC_BUILTIN_ENDIAN_H */ diff --git a/builtin/string.h b/builtin/string.h index 21159a5eef..8c9a71bd75 100644 --- a/builtin/string.h +++ b/builtin/string.h @@ -10,6 +10,10 @@ #include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif + int memcmp(const void *s1, const void *s2, size_t len); void *memcpy(void *dest, const void *src, size_t len); void *memmove(void *dest, const void *src, size_t n); @@ -20,4 +24,8 @@ size_t strnlen(const char *s, size_t maxlen); char *strncpy(char *dest, const char *src, size_t n); int strncmp(const char *s1, const char *s2, size_t n); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_STRINGS_H__ */ diff --git a/chip/g/dcrypto/dcrypto.h b/chip/g/dcrypto/dcrypto.h index 93763b1f26..f51907f767 100644 --- a/chip/g/dcrypto/dcrypto.h +++ b/chip/g/dcrypto/dcrypto.h @@ -21,6 +21,10 @@ #include "cryptoc/hmac.h" +#ifdef __cplusplus +extern "C" { +#endif + enum cipher_mode { CIPHER_MODE_ECB = 0, CIPHER_MODE_CTR = 1, @@ -337,4 +341,8 @@ BUILD_ASSERT(DCRYPTO_CIPHER_SALT_SIZE == CIPHER_SALT_SIZE); int DCRYPTO_app_cipher(enum dcrypto_appid appid, const void *salt, void *out, const void *in, size_t len); +#ifdef __cplusplus +} +#endif + #endif /* ! __EC_CHIP_G_DCRYPTO_DCRYPTO_H */ diff --git a/chip/g/dcrypto/internal.h b/chip/g/dcrypto/internal.h index 3e546e90a2..fa280e94b5 100644 --- a/chip/g/dcrypto/internal.h +++ b/chip/g/dcrypto/internal.h @@ -18,6 +18,10 @@ #include "cryptoc/sha384.h" #include "cryptoc/sha512.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * SHA. */ @@ -178,5 +182,8 @@ int dcrypto_ladder_derive(enum dcrypto_appid appid, const uint32_t salt[8], const uint32_t input[8], uint32_t output[8]); #endif +#ifdef __cplusplus +} +#endif #endif /* ! __EC_CHIP_G_DCRYPTO_INTERNAL_H */ diff --git a/chip/host/persistence.h b/chip/host/persistence.h index 1fab1c8235..56e2df2eb4 100644 --- a/chip/host/persistence.h +++ b/chip/host/persistence.h @@ -10,10 +10,18 @@ #include <stdio.h> +#ifdef __cplusplus +extern "C" { +#endif + FILE *get_persistent_storage(const char *tag, const char *mode); void release_persistent_storage(FILE *ps); void remove_persistent_storage(const char *tag); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_PERSISTENCE_H */ diff --git a/fuzz/cr50_fuzz.cc b/fuzz/cr50_fuzz.cc index d73f8774cc..90b8350fc2 100644 --- a/fuzz/cr50_fuzz.cc +++ b/fuzz/cr50_fuzz.cc @@ -11,14 +11,12 @@ #include <cstdlib> #include <cstring> -extern "C" { #define HIDE_EC_STDLIB #include "fuzz_config.h" #include "nvmem.h" #include "nvmem_vars.h" #include "persistence.h" #include "pinweaver.h" -} #define NVMEM_TPM_SIZE ((sizeof((struct nvmem_partition *)0)->buffer) \ - NVMEM_CR50_SIZE) diff --git a/include/crypto_api.h b/include/crypto_api.h index 2628e2bd7b..07bda7f5be 100644 --- a/include/crypto_api.h +++ b/include/crypto_api.h @@ -9,6 +9,10 @@ #include "util.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Calculate hash of an arbitrary data * @@ -52,4 +56,8 @@ void app_compute_hash(uint8_t *p_buf, size_t num_bytes, */ int app_cipher(const void *salt, void *out, const void *in, size_t size); +#ifdef __cplusplus +} +#endif + #endif /* __INCLUDE_CRYPTO_API_H */ diff --git a/include/nvmem.h b/include/nvmem.h index e9fae3d11d..1ca09fff38 100644 --- a/include/nvmem.h +++ b/include/nvmem.h @@ -8,6 +8,10 @@ #include "crypto_api.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * In order to provide maximum robustness for NvMem operations, the NvMem space * is divided into two equal sized partitions. A partition contains a tag @@ -201,4 +205,8 @@ void nvmem_disable_commits(void); */ int nvmem_enable_commits(void); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_NVMEM_UTILS_H */ diff --git a/include/nvmem_vars.h b/include/nvmem_vars.h index 867ea32018..add14345e7 100644 --- a/include/nvmem_vars.h +++ b/include/nvmem_vars.h @@ -6,6 +6,10 @@ #ifndef __EC_INCLUDE_NVMEM_VARS_H #define __EC_INCLUDE_NVMEM_VARS_H +#ifdef __cplusplus +extern "C" { +#endif + /* * CONFIG_FLASH_NVMEM provides persistent, atomic-update storage in * flash. The storage is logically divided into one or more "user regions", as @@ -84,4 +88,8 @@ int setvar(const uint8_t *key, uint8_t key_len, */ int writevars(void); +#ifdef __cplusplus +} +#endif + #endif /* __EC_INCLUDE_NVMEM_VARS_H */ diff --git a/include/panic.h b/include/panic.h index 8a689c4b23..1984081dd7 100644 --- a/include/panic.h +++ b/include/panic.h @@ -13,6 +13,10 @@ #include <stdarg.h> +#ifdef __cplusplus +extern "C" { +#endif + /* ARM Cortex-Mx registers saved on panic */ struct cortex_panic_data { uint32_t regs[12]; /* psp, ipsr, msp, r4-r11, lr(=exc_return). @@ -181,4 +185,8 @@ struct panic_data *panic_get_data(void); */ void chip_panic_data_backup(void); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_PANIC_H */ diff --git a/include/pinweaver.h b/include/pinweaver.h index 1f373ba582..21571da7b0 100644 --- a/include/pinweaver.h +++ b/include/pinweaver.h @@ -13,6 +13,10 @@ #include <common.h> #include <pinweaver_types.h> +#ifdef __cplusplus +extern "C" { +#endif + #define PW_STORAGE_VERSION 0 #define BITS_PER_LEVEL_MIN 1 @@ -177,4 +181,8 @@ int log_remove_leaf(struct label_t label, const uint8_t root[PW_HASH_SIZE]); int log_auth(struct label_t label, const uint8_t root[PW_HASH_SIZE], int code, struct pw_timestamp_t timestamp); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_INCLUDE_PINWEAVER_H */ diff --git a/include/pinweaver_tpm_imports.h b/include/pinweaver_tpm_imports.h index 879bb6bbb8..f1ecd24202 100644 --- a/include/pinweaver_tpm_imports.h +++ b/include/pinweaver_tpm_imports.h @@ -16,6 +16,10 @@ #include <stddef.h> #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + /* This is used to get the storage seed from the TPM implementation so * TPM_Clear() will break the keys used by PinWeaver so that any metadata * that persists on the machine storage is unusable by attackers. @@ -28,4 +32,8 @@ void get_storage_seed(void *buf, size_t *len); uint8_t get_current_pcr_digest(const uint8_t bitmask[2], uint8_t sha256_of_selected_pcr[32]); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_INCLUDE_PINWEAVER_TPM_IMPORTS_H */ diff --git a/include/pinweaver_types.h b/include/pinweaver_types.h index cc4b5832b3..e8787eb29a 100644 --- a/include/pinweaver_types.h +++ b/include/pinweaver_types.h @@ -10,6 +10,10 @@ #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + #define PW_PACKED __packed #define PW_PROTOCOL_VERSION 1 @@ -409,4 +413,8 @@ struct PW_PACKED pw_response_t { */ #define PW_MAX_PATH_SIZE 1024 +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_INCLUDE_PINWEAVER_TYPES_H */ diff --git a/include/util.h b/include/util.h index 9691669c19..39a07e4b1e 100644 --- a/include/util.h +++ b/include/util.h @@ -15,6 +15,10 @@ #include "builtin/assert.h" /* For ASSERT(). */ #include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif + /* Standard macros / definitions */ #ifndef MAX #define MAX(a, b) \ @@ -219,4 +223,8 @@ static inline uint64_t mulaa32(uint32_t a, uint32_t b, uint32_t c, uint32_t d) } #endif +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_UTIL_H */ |