diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-08-23 10:18:26 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-14 21:53:26 +0000 |
commit | e3d157a403388f9446b07b95a4689e1a8b329aff (patch) | |
tree | 187bd907a5119f78468d96e1d4b37f73247573b2 | |
parent | b194607b6dde669c892f6fd5e2a4e9c0313f440f (diff) | |
download | chrome-ec-e3d157a403388f9446b07b95a4689e1a8b329aff.tar.gz |
fpsensor: Compile more fingerprint files with C++
BRANCH=none
BUG=b:234181908
TEST=./test/run_device_tests.py -b bloonchipper
=> PASS (except http://b/268355032)
TEST=./test/run_device_tests.py -b dartmonkey
=> PASS (except http://b/268355032)
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I3f8d1a95f0f1e844f0bf1e56e5514dda521979b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3852917
Reviewed-by: Andrea Grandi <agrandi@google.com>
-rw-r--r-- | common/fpsensor/fpsensor.cc | 11 | ||||
-rw-r--r-- | common/fpsensor/fpsensor_crypto.cc (renamed from common/fpsensor/fpsensor_crypto.c) | 18 | ||||
-rw-r--r-- | common/fpsensor/fpsensor_detect_strings.cc (renamed from common/fpsensor/fpsensor_detect_strings.c) | 0 | ||||
-rw-r--r-- | common/fpsensor/fpsensor_state.cc (renamed from common/fpsensor/fpsensor_state.c) | 35 | ||||
-rw-r--r-- | include/fpsensor.h | 8 | ||||
-rw-r--r-- | include/fpsensor_alg.h | 8 | ||||
-rw-r--r-- | include/fpsensor_crypto.h | 11 | ||||
-rw-r--r-- | include/fpsensor_detect.h | 8 | ||||
-rw-r--r-- | include/fpsensor_state.h | 8 | ||||
-rw-r--r-- | include/fpsensor_utils.h | 11 |
10 files changed, 97 insertions, 21 deletions
diff --git a/common/fpsensor/fpsensor.cc b/common/fpsensor/fpsensor.cc index 2f961d6f58..f935a8fc99 100644 --- a/common/fpsensor/fpsensor.cc +++ b/common/fpsensor/fpsensor.cc @@ -12,11 +12,6 @@ extern "C" { #include "console.h" #include "cryptoc/util.h" #include "ec_commands.h" -#include "fpsensor.h" -#include "fpsensor_crypto.h" -#include "fpsensor_detect.h" -#include "fpsensor_state.h" -#include "fpsensor_utils.h" #include "gpio.h" #include "host_command.h" #include "link_defs.h" @@ -30,6 +25,12 @@ extern "C" { #include "watchdog.h" } +#include "fpsensor.h" +#include "fpsensor_crypto.h" +#include "fpsensor_detect.h" +#include "fpsensor_state.h" +#include "fpsensor_utils.h" + #if !defined(CONFIG_RNG) #error "fpsensor requires RNG" #endif diff --git a/common/fpsensor/fpsensor_crypto.c b/common/fpsensor/fpsensor_crypto.cc index 0fa387707b..824f3d6c73 100644 --- a/common/fpsensor/fpsensor_crypto.c +++ b/common/fpsensor/fpsensor_crypto.cc @@ -2,16 +2,26 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "aes-gcm.h" -#include "aes.h" -#include "cryptoc/util.h" + #include "fpsensor_crypto.h" #include "fpsensor_state.h" #include "fpsensor_utils.h" + +extern "C" { +#include "aes-gcm.h" +#include "aes.h" +#include "cryptoc/util.h" #include "rollback.h" +#include "sha256.h" -#include <stdbool.h> +test_export_static int get_ikm(uint8_t *ikm); +test_mockable void compute_hmac_sha256(uint8_t *output, const uint8_t *key, + const int key_len, + const uint8_t *message, + const int message_len); +} +#include <stdbool.h> #if !defined(CONFIG_AES) || !defined(CONFIG_AES_GCM) || \ !defined(CONFIG_ROLLBACK_SECRET_SIZE) #error "fpsensor requires AES, AES_GCM and ROLLBACK_SECRET_SIZE" diff --git a/common/fpsensor/fpsensor_detect_strings.c b/common/fpsensor/fpsensor_detect_strings.cc index af08219ced..af08219ced 100644 --- a/common/fpsensor/fpsensor_detect_strings.c +++ b/common/fpsensor/fpsensor_detect_strings.cc diff --git a/common/fpsensor/fpsensor_state.c b/common/fpsensor/fpsensor_state.cc index bf728ab5b6..b1b05ebfcb 100644 --- a/common/fpsensor/fpsensor_state.c +++ b/common/fpsensor/fpsensor_state.cc @@ -3,18 +3,23 @@ * found in the LICENSE file. */ +#include "compile_time_macros.h" +#include "fpsensor_utils.h" + +extern "C" { #include "atomic.h" #include "common.h" #include "cryptoc/util.h" #include "ec_commands.h" -#include "fpsensor.h" -#include "fpsensor_crypto.h" -#include "fpsensor_state.h" -#include "fpsensor_utils.h" #include "host_command.h" #include "system.h" #include "task.h" #include "util.h" +} + +#include "fpsensor.h" +#include "fpsensor_crypto.h" +#include "fpsensor_state.h" /* Last acquired frame (aligned as it is used by arbitrary binary libraries) */ uint8_t fp_buffer[FP_SENSOR_IMAGE_SIZE] FP_FRAME_SECTION __aligned(4); @@ -111,7 +116,8 @@ DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_FINGERPRINT, fp_get_next_event); static enum ec_status fp_command_tpm_seed(struct host_cmd_handler_args *args) { - const struct ec_params_fp_seed *params = args->params; + const struct ec_params_fp_seed *params = + static_cast<const ec_params_fp_seed *>(args->params); if (params->struct_version != FP_TEMPLATE_FORMAT_VERSION) { CPRINTS("Invalid seed format %d", params->struct_version); @@ -137,7 +143,8 @@ int fp_tpm_seed_is_set(void) static enum ec_status fp_command_encryption_status(struct host_cmd_handler_args *args) { - struct ec_response_fp_encryption_status *r = args->response; + struct ec_response_fp_encryption_status *r = + static_cast<ec_response_fp_encryption_status *>(args->response); r->valid_flags = FP_ENC_STATUS_SEED_SET; r->status = fp_encryption_status; @@ -202,8 +209,10 @@ enum ec_status fp_set_sensor_mode(uint32_t mode, uint32_t *mode_output) static enum ec_status fp_command_mode(struct host_cmd_handler_args *args) { - const struct ec_params_fp_mode *p = args->params; - struct ec_response_fp_mode *r = args->response; + const struct ec_params_fp_mode *p = + static_cast<const ec_params_fp_mode *>(args->params); + struct ec_response_fp_mode *r = + static_cast<ec_response_fp_mode *>(args->response); enum ec_status ret = fp_set_sensor_mode(p->mode, &r->mode); @@ -216,7 +225,8 @@ DECLARE_HOST_COMMAND(EC_CMD_FP_MODE, fp_command_mode, EC_VER_MASK(0)); static enum ec_status fp_command_context(struct host_cmd_handler_args *args) { - const struct ec_params_fp_context_v1 *p = args->params; + const struct ec_params_fp_context_v1 *p = + static_cast<const ec_params_fp_context_v1 *>(args->params); uint32_t mode_output; switch (p->action) { @@ -272,8 +282,11 @@ void fp_disable_positive_match_secret(struct positive_match_secret_state *state) static enum ec_status fp_command_read_match_secret(struct host_cmd_handler_args *args) { - const struct ec_params_fp_read_match_secret *params = args->params; - struct ec_response_fp_read_match_secret *response = args->response; + const struct ec_params_fp_read_match_secret *params = + static_cast<const ec_params_fp_read_match_secret *>( + args->params); + struct ec_response_fp_read_match_secret *response = + static_cast<ec_response_fp_read_match_secret *>(args->response); int8_t fgr = params->fgr; timestamp_t now = get_time(); struct positive_match_secret_state state_copy = diff --git a/include/fpsensor.h b/include/fpsensor.h index 890a24f336..df212d8b0b 100644 --- a/include/fpsensor.h +++ b/include/fpsensor.h @@ -16,6 +16,10 @@ #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + #ifndef SPI_FP_DEVICE #define SPI_FP_DEVICE (&spi_devices[0]) #endif @@ -142,4 +146,8 @@ int fp_sensor_acquire_image_with_mode(uint8_t *image_data, int mode); */ int fp_maintenance(void); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPSENSOR_H */ diff --git a/include/fpsensor_alg.h b/include/fpsensor_alg.h index ba86359ba0..725798f8d3 100644 --- a/include/fpsensor_alg.h +++ b/include/fpsensor_alg.h @@ -10,6 +10,10 @@ #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + /** * Compares given finger image against enrolled templates. * @@ -75,4 +79,8 @@ int fp_enrollment_finish(void *templ); */ int fp_finger_enroll(uint8_t *image, int *completion); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPSENSOR_ALG_H */ diff --git a/include/fpsensor_crypto.h b/include/fpsensor_crypto.h index f000b841e4..21b8513f84 100644 --- a/include/fpsensor_crypto.h +++ b/include/fpsensor_crypto.h @@ -8,10 +8,15 @@ #ifndef __CROS_EC_FPSENSOR_CRYPTO_H #define __CROS_EC_FPSENSOR_CRYPTO_H +#include "compile_time_macros.h" + +#ifdef __cplusplus +extern "C" { +#endif + #include "sha256.h" #include <stddef.h> - #define HKDF_MAX_INFO_SIZE 128 #define HKDF_SHA256_MAX_BLOCK_COUNT 255 @@ -90,4 +95,8 @@ int aes_gcm_decrypt(const uint8_t *key, int key_size, uint8_t *plaintext, const uint8_t *nonce, int nonce_size, const uint8_t *tag, int tag_size); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPSENSOR_CRYPTO_H */ diff --git a/include/fpsensor_detect.h b/include/fpsensor_detect.h index 1fc08759ba..b8d7b398d5 100644 --- a/include/fpsensor_detect.h +++ b/include/fpsensor_detect.h @@ -8,6 +8,10 @@ #ifndef __CROS_EC_FPSENSOR_DETECT_H #define __CROS_EC_FPSENSOR_DETECT_H +#ifdef __cplusplus +extern "C" { +#endif + #include "fpsensor_types.h" const char *fp_transport_type_to_str(enum fp_transport_type type); @@ -17,4 +21,8 @@ enum fp_sensor_type get_fp_sensor_type(void); enum fp_transport_type get_fp_transport_type(void); enum fp_sensor_spi_select get_fp_sensor_spi_select(void); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPSENSOR_DETECT_H */ diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h index cfae403e16..e5d1095e8e 100644 --- a/include/fpsensor_state.h +++ b/include/fpsensor_state.h @@ -18,6 +18,10 @@ #include <stdbool.h> #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + /* if no special memory regions are defined, fallback on regular SRAM */ #ifndef FP_FRAME_SECTION #define FP_FRAME_SECTION @@ -135,4 +139,8 @@ int fp_enable_positive_match_secret(uint32_t fgr, */ void fp_disable_positive_match_secret(struct positive_match_secret_state *state); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPSENSOR_STATE_H */ diff --git a/include/fpsensor_utils.h b/include/fpsensor_utils.h index c0d88042d7..59b89b8444 100644 --- a/include/fpsensor_utils.h +++ b/include/fpsensor_utils.h @@ -8,6 +8,12 @@ #ifndef __CROS_EC_FPSENSOR_UTILS_H #define __CROS_EC_FPSENSOR_UTILS_H +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + #define CPRINTF(format, args...) cprintf(CC_FP, format, ##args) #define CPRINTS(format, args...) cprints(CC_FP, format, ##args) @@ -21,4 +27,9 @@ */ int validate_fp_buffer_offset(uint32_t buffer_size, uint32_t offset, uint32_t size); + +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPSENSOR_UTILS_H */ |