formatting: Indent preprocessor directives
What changed, and why it matters
This commit is purely a code-style change. It tells the project's automatic formatter (clang-format) to indent preprocessor directives like #if, #include, and #error, and then applies that new rule across many source files. No program logic, security checks, or behavior were changed.
No security action needed. Treat as normal formatting/style maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The only functional configuration change is adding IndentPPDirectives: BeforeHash to .clang-format. The remaining ~670 line changes are whitespace-only reformatting of #include, #define, #if/#else/#endif, #error, and #pragma blocks to be indented according to nesting depth. A few adjacent non-preprocessor lines were also rewrapped by clang-format (e.g., a function call argument list in keystore.c, a cast spacing in qtouch.c, a comment in startup.c), but these are cosmetic. No semantic changes were introduced.
Changed components
.clang-formatsrc/**/*.csrc/**/*.htest/unit-test/**/*.ctest/unit-test/**/*.hInspect captured patch +676 / −672
diff --git a/.clang-format b/.clang-format
index 20791a5d..f6ea9166 100644
--- a/.clang-format
+++ b/.clang-format
@@ -13,6 +13,7 @@ IndentCaseLabels: false
PenaltyReturnTypeOnItsOwnLine: 1000
SpacesBeforeTrailingComments: 1
IncludeBlocks: Preserve
+IndentPPDirectives: BeforeHash
# cmocka must come after some std includes
IncludeCategories:
- Regex: '^(<|")cmocka'
diff --git a/src/atecc/atecc.c b/src/atecc/atecc.c
index aedbf843..872605d6 100644
--- a/src/atecc/atecc.c
+++ b/src/atecc/atecc.c
@@ -51,7 +51,7 @@ typedef enum {
// The Counter0/Counter1 values are overwritten at setup via atcab_write_config_counter().
// Individual slot locking is performed at setup via atcab_lock_data_slot().
#if (ATCA_ECC_CONFIG_SIZE != 128)
-#error "Unexpected configuration size"
+ #error "Unexpected configuration size"
#endif
// clang-format off
static uint8_t _configuration[ATCA_ECC_CONFIG_SIZE] = {
@@ -510,7 +510,7 @@ static ATCA_STATUS _update_kdf_key(void)
UTIL_CLEANUP_32(nonce_contribution);
_interface_functions->random_32_bytes(nonce_contribution);
#if NONCE_NUMIN_SIZE > 32
-#error "size mismatch"
+ #error "size mismatch"
#endif
ATCA_STATUS result = _authorize_key();
@@ -695,9 +695,9 @@ static bool _read_data_slot_block(uint8_t* bytes, uint16_t slot, uint8_t block)
uint8_t nonce_contribution[32] = {0};
UTIL_CLEANUP_32(nonce_contribution);
_interface_functions->random_32_bytes(nonce_contribution);
-#if NONCE_NUMIN_SIZE > 32
-#error "size mismatch"
-#endif
+ #if NONCE_NUMIN_SIZE > 32
+ #error "size mismatch"
+ #endif
ATCA_STATUS result = _authorize_key();
if (result != ATCA_SUCCESS) {
@@ -718,9 +718,9 @@ static bool _write_data_slot_block(uint8_t* bytes, uint16_t slot, uint8_t block)
uint8_t nonce_contribution[32] = {0};
UTIL_CLEANUP_32(nonce_contribution);
_interface_functions->random_32_bytes(nonce_contribution);
-#if NONCE_NUMIN_SIZE > 32
-#error "size mismatch"
-#endif
+ #if NONCE_NUMIN_SIZE > 32
+ #error "size mismatch"
+ #endif
ATCA_STATUS result = _authorize_key();
if (result != ATCA_SUCCESS) {
diff --git a/src/bootloader/bootloader.c b/src/bootloader/bootloader.c
index 3791fe4e..55698749 100644
--- a/src/bootloader/bootloader.c
+++ b/src/bootloader/bootloader.c
@@ -37,16 +37,16 @@
#include <util.h>
#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02PLUS == 1
-#include <memory/memory_spi.h>
-#include <qtouch/qtouch.h>
+ #include <memory/memory_spi.h>
+ #include <qtouch/qtouch.h>
#endif
#if PLATFORM_BITBOX02PLUS == 1
-#include <communication_mode.h>
-#include <da14531/da14531.h>
-#include <da14531/da14531_protocol.h>
-#include <uart.h>
-#include <utils_ringbuffer.h>
+ #include <communication_mode.h>
+ #include <da14531/da14531.h>
+ #include <da14531/da14531_protocol.h>
+ #include <uart.h>
+ #include <utils_ringbuffer.h>
#endif
#include <assert.h>
@@ -108,7 +108,7 @@ COMPILER_PACK_RESET()
#define FIRMWARE_MAX_NUM_CHUNKS \
(FLASH_APP_LEN / FIRMWARE_CHUNK_LEN) // app len must be a multiple of chunk len
#if (FIRMWARE_MAX_NUM_CHUNKS > UINT8_MAX)
-#error "incompatible variable type"
+ #error "incompatible variable type"
#endif
// Be sure to not overflow boot data area
@@ -120,7 +120,7 @@ static_assert(sizeof(((boot_data_t*)0)->fields) <= FLASH_BOOTDATA_LEN, "boot_dat
BOOT_SIG_LEN * BOOT_NUM_ROOT_SIGNING_KEYS + 4 /* firmware data version */ + \
BOOT_SIG_LEN * BOOT_NUM_FIRMWARE_SIGNING_KEYS > \
FIRMWARE_CHUNK_LEN)
-#error "incompatible bootloader data macro"
+ #error "incompatible bootloader data macro"
#endif
static bool _loading_ready = false;
@@ -142,7 +142,7 @@ static const uint8_t _empty_bare_flash_hash[SHA256_DIGEST_LENGTH] = {
0x00, 0xb8, 0xaf, 0x3a, 0x79, 0xf8, 0xc6, 0x56, 0x4a, 0x9b, 0x02, 0xe1, 0x8a, 0xb8, 0x21, 0xae,
};
#if FLASH_APP_LEN != 884736
-#error "FLASH_APP_LEN changed; recompute _empty_bare_flash_hash"
+ #error "FLASH_APP_LEN changed; recompute _empty_bare_flash_hash"
#endif
#if PLATFORM_BITBOX02PLUS == 1
@@ -272,7 +272,7 @@ static void _binary_exec(void)
int i;
#if (FLASH_APP_START & 0x007F)
-#error "app start address not aligned"
+ #error "app start address not aligned"
#else
void* app_start_addr = (void*)FLASH_APP_START;
#endif
@@ -1023,7 +1023,7 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
} else {
UG_PutString(0, SCREEN_HEIGHT - 9, " No firmware found", false);
}
-#if PLATFORM_BITBOX02PLUS == 1
+ #if PLATFORM_BITBOX02PLUS == 1
struct da14531_firmware_version version;
bool res = memory_spi_get_active_ble_firmware_version(&version);
if (res) {
@@ -1031,7 +1031,7 @@ static bool _devdevice_enter(secbool_u32 firmware_verified)
snprintf(buf, sizeof(buf), "ble: %d (%s)", version.version, util_dbg_hex(version.hash, 4));
UG_PutString(0, SCREEN_HEIGHT - 18, buf, false);
}
-#endif
+ #endif
uint16_t ypos = SCREEN_HEIGHT / 2 - 4;
uint16_t xpos = SCREEN_WIDTH - 10;
if (firmware_verified != sectrue_u32) {
diff --git a/src/bootloader/mpu_regions.c b/src/bootloader/mpu_regions.c
index 4ae317d9..5fb2fb94 100644
--- a/src/bootloader/mpu_regions.c
+++ b/src/bootloader/mpu_regions.c
@@ -16,13 +16,13 @@
#ifndef TESTING
-#include <flags.h>
-#include <memory/mpu.h>
+ #include <flags.h>
+ #include <memory/mpu.h>
-#include <core_cm4.h>
-#include <samd51j20a.h>
+ #include <core_cm4.h>
+ #include <samd51j20a.h>
-#include <stdint.h>
+ #include <stdint.h>
static void _set_mpu_regions(void)
{
diff --git a/src/bootloader/startup.c b/src/bootloader/startup.c
index 52959772..3314a029 100644
--- a/src/bootloader/startup.c
+++ b/src/bootloader/startup.c
@@ -27,26 +27,26 @@
#include <usb/usb_processing.h>
#if defined(BOOTLOADER_DEVDEVICE) || PLATFORM_BITBOX02PLUS == 1
-#include <qtouch.h>
+ #include <qtouch.h>
#endif
#if PLATFORM_BITBOX02PLUS == 1
-#include <communication_mode.h>
-#include <da14531/da14531.h>
-#include <da14531/da14531_handler.h>
-#include <da14531/da14531_protocol.h>
-#include <memory/memory.h>
-#include <memory/memory_shared.h>
-#include <uart.h>
-#include <utils_ringbuffer.h>
-
-#if PRODUCT_BITBOX_PLUS_MULTI == 1
-#define DEVICE_MODE "{\"p\":\"bb02p-bl-multi\",\"v\":\"" BOOTLOADER_VERSION "\"}"
-#elif PRODUCT_BITBOX_PLUS_BTCONLY == 1
-#define DEVICE_MODE "{\"p\":\"bb02p-bl-btconly\",\"v\":\"" BOOTLOADER_VERSION "\"}"
-#else
-#error "unknown product"
-#endif
+ #include <communication_mode.h>
+ #include <da14531/da14531.h>
+ #include <da14531/da14531_handler.h>
+ #include <da14531/da14531_protocol.h>
+ #include <memory/memory.h>
+ #include <memory/memory_shared.h>
+ #include <uart.h>
+ #include <utils_ringbuffer.h>
+
+ #if PRODUCT_BITBOX_PLUS_MULTI == 1
+ #define DEVICE_MODE "{\"p\":\"bb02p-bl-multi\",\"v\":\"" BOOTLOADER_VERSION "\"}"
+ #elif PRODUCT_BITBOX_PLUS_BTCONLY == 1
+ #define DEVICE_MODE "{\"p\":\"bb02p-bl-btconly\",\"v\":\"" BOOTLOADER_VERSION "\"}"
+ #else
+ #error "unknown product"
+ #endif
#endif // PLATFORM_BITBOX02PLUS == 1
extern void __attribute__((noreturn)) __stack_chk_fail(void);
@@ -63,8 +63,8 @@ uint32_t __stack_chk_guard = 0;
extern volatile bool measurement_done_touch;
int bootloader_pairing_request = false;
uint8_t bootloader_pairing_code_bytes[4] = {0};
-// Must be power of 2, must fit bond_db
-#define UART_OUT_BUF_LEN 2048
+ // Must be power of 2, must fit bond_db
+ #define UART_OUT_BUF_LEN 2048
struct ringbuffer uart_write_queue;
uint8_t uart_write_buf[UART_OUT_BUF_LEN];
#endif
diff --git a/src/cipher/cipher.c b/src/cipher/cipher.c
index e2b6b732..6600e330 100644
--- a/src/cipher/cipher.c
+++ b/src/cipher/cipher.c
@@ -18,7 +18,7 @@
#include <rust/rust.h>
#ifdef TESTING
-#include <fake_cipher.h>
+ #include <fake_cipher.h>
#endif
bool cipher_aes_hmac_encrypt(
diff --git a/src/da14531/da14531_handler.c b/src/da14531/da14531_handler.c
index 354ba21a..7e2185ec 100644
--- a/src/da14531/da14531_handler.c
+++ b/src/da14531/da14531_handler.c
@@ -70,7 +70,7 @@ static void _ble_pairing_callback(bool ok, void* param)
_ble_pairing_component = NULL;
}
#else
-#include <bootloader/bootloader.h>
+ #include <bootloader/bootloader.h>
extern bool bootloader_pairing_request;
extern uint8_t bootloader_pairing_code_bytes[4];
#endif
diff --git a/src/da14531/da14531_protocol.c b/src/da14531/da14531_protocol.c
index e68343a4..74c8258c 100644
--- a/src/da14531/da14531_protocol.c
+++ b/src/da14531/da14531_protocol.c
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <utils_assert.h>
#ifndef TESTING
-#include "dap.h"
+ #include "dap.h"
#endif
#include <hardfault.h>
diff --git a/src/firmware.c b/src/firmware.c
index 6af86f87..3c909870 100644
--- a/src/firmware.c
+++ b/src/firmware.c
@@ -30,7 +30,7 @@
#include <ui/oled/oled.h>
#if APP_U2F == 1
-#include <u2f.h>
+ #include <u2f.h>
#endif
uint32_t __stack_chk_guard = 0;
diff --git a/src/firmware_main_loop.c b/src/firmware_main_loop.c
index e09bf3a3..34c1a560 100644
--- a/src/firmware_main_loop.c
+++ b/src/firmware_main_loop.c
@@ -37,9 +37,9 @@
#include <ui/fonts/monogram_5X9.h>
#include <utils_ringbuffer.h>
#if APP_U2F == 1
-#include "u2f.h"
-#include "u2f/u2f_packet.h"
-#include "usb/class/hid/u2f/hid_u2f.h"
+ #include "u2f.h"
+ #include "u2f/u2f_packet.h"
+ #include "usb/class/hid/u2f/hid_u2f.h"
#endif
// Must be power of 2
diff --git a/src/flags.h b/src/flags.h
index 5a07eb07..6ace5db5 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -16,11 +16,11 @@
#define _FLAGS_H_
#ifdef TESTING
-#define FLASH_ADDR (0x00000000U)
-#define FLASH_SIZE (0x00100000U)
-#define FLASH_PAGE_SIZE (512U)
+ #define FLASH_ADDR (0x00000000U)
+ #define FLASH_SIZE (0x00100000U)
+ #define FLASH_PAGE_SIZE (512U)
#else
-#include <samd51j20a.h>
+ #include <samd51j20a.h>
#endif
#include "memory/smarteeprom.h"
@@ -107,22 +107,22 @@
// Check MPU conditions
#if (FLASH_APP_START % FLASH_ERASE_MIN_LEN)
-#error "Appdata start must be aligned to the minimum erase granularity"
+ #error "Appdata start must be aligned to the minimum erase granularity"
#endif
#if (FLASH_BOOTDATA_START % FLASH_ERASE_MIN_LEN)
-#error "Bootdata start must be aligned to the minimum erase granularity"
+ #error "Bootdata start must be aligned to the minimum erase granularity"
#endif
#if (FLASH_BOOTDATA_START % FLASH_BOOTDATA_LEN)
-#error "Bootdata start must be a multiple of bootdata length for the MPU setup"
+ #error "Bootdata start must be a multiple of bootdata length for the MPU setup"
#endif
#if (FLASH_APPDATA_START % FLASH_ERASE_MIN_LEN)
-#error "Appdata start must be aligned to the minimum erase granularity"
+ #error "Appdata start must be aligned to the minimum erase granularity"
#endif
#if (FLASH_APPDATA_START % (FLASH_APPDATA_LEN / 2))
-#error "Appdata region 0 start must be a multiple of app region 0 data length for the MPU setup"
+ #error "Appdata region 0 start must be a multiple of app region 0 data length for the MPU setup"
#endif
#if ((FLASH_APPDATA_START + FLASH_APPDATA_LEN / 2) % (FLASH_APPDATA_LEN / 2))
-#error "Appdata region 1 start must be a multiple of app region 1 data length for the MPU setup"
+ #error "Appdata region 1 start must be a multiple of app region 1 data length for the MPU setup"
#endif
#endif
diff --git a/src/hardfault.c b/src/hardfault.c
index 6bd54605..116d095c 100644
--- a/src/hardfault.c
+++ b/src/hardfault.c
@@ -22,8 +22,8 @@
#include <usb/usb.h>
#if defined(TESTING)
-#include <stdio.h>
-#include <stdlib.h>
+ #include <stdio.h>
+ #include <stdlib.h>
#endif
#ifndef TESTING
@@ -47,11 +47,11 @@ void Abort(const char* msg)
util_log("%s", msg);
screen_print_debug(msg, 0);
usb_stop();
-#if defined(BOOTLOADER)
+ #if defined(BOOTLOADER)
bootloader_close_interfaces();
-#else
+ #else
system_close_interfaces();
-#endif
+ #endif
// Break the program if we are debugging
ASSERT(false);
while (1) {
diff --git a/src/hardfault.h b/src/hardfault.h
index c62186e2..8e5e1145 100644
--- a/src/hardfault.h
+++ b/src/hardfault.h
@@ -16,7 +16,7 @@
#define _HARDFAULT_H_
#ifdef TESTING
-#include <stdio.h>
+ #include <stdio.h>
void Dummy_Handler(void);
void HardFault_Handler(void) __attribute__((weak));
diff --git a/src/i2c_ecc.c b/src/i2c_ecc.c
index 5660db22..92e74f17 100644
--- a/src/i2c_ecc.c
+++ b/src/i2c_ecc.c
@@ -14,10 +14,10 @@
#ifndef TESTING
-#include "i2c_ecc.h"
-#include "driver_init.h"
-#include "util.h"
-#include <string.h>
+ #include "i2c_ecc.h"
+ #include "driver_init.h"
+ #include "util.h"
+ #include <string.h>
uint8_t i2c_ecc_read(uint8_t* rxdata, uint32_t rxlen)
{
diff --git a/src/i2c_ecc.h b/src/i2c_ecc.h
index e9b3cfd8..189b94c2 100644
--- a/src/i2c_ecc.h
+++ b/src/i2c_ecc.h
@@ -17,32 +17,32 @@
#ifndef TESTING
-#include <stdint.h>
-
-// Chip commands
-#define I2C_ECC_CHIP_RESET 0x00
-#define I2C_ECC_CHIP_SLEEP 0x01
-#define I2C_ECC_CHIP_IDLE 0x02
-#define I2C_ECC_CHIP_CMD 0x03
-
-// Settings
-#define I2C_ECC_ADDR 0xC0
-#define I2C_ECC_TWLO 70u // tWLO min 60 us
-#define I2C_ECC_TWHI 1550u // tWHI min 1500 us
-#define I2C_ECC_RETRIES 25u
-#define I2C_ECC_RETRY_DELAY 2u
-
-// Status codes
-#define I2C_ECC_SUCCESS 0x00 // Command successful
-#define I2C_ECC_ERR_VERIFY 0x01 // Checkmac or verify error
-#define I2C_ECC_ERR_PARSE 0x03 // Command parse error
-#define I2C_ECC_ERR_ECC 0x05 // ECC fault
-#define I2C_ECC_ERR_SELFTEST 0x07 // Self-test error
-#define I2C_ECC_ERR_EXECUTION 0x0F // Command execution error
-#define I2C_ECC_WAKE 0x11 // Received a proper wake token.
-#define I2C_ECC_ERR_I2C 0xCC // I2C communication error
-#define I2C_ECC_ERR_WATCHDOG 0xEE // Watchdog about to expire
-#define I2C_ECC_ERR_CRC 0xFF // CRC or other communications error
+ #include <stdint.h>
+
+ // Chip commands
+ #define I2C_ECC_CHIP_RESET 0x00
+ #define I2C_ECC_CHIP_SLEEP 0x01
+ #define I2C_ECC_CHIP_IDLE 0x02
+ #define I2C_ECC_CHIP_CMD 0x03
+
+ // Settings
+ #define I2C_ECC_ADDR 0xC0
+ #define I2C_ECC_TWLO 70u // tWLO min 60 us
+ #define I2C_ECC_TWHI 1550u // tWHI min 1500 us
+ #define I2C_ECC_RETRIES 25u
+ #define I2C_ECC_RETRY_DELAY 2u
+
+ // Status codes
+ #define I2C_ECC_SUCCESS 0x00 // Command successful
+ #define I2C_ECC_ERR_VERIFY 0x01 // Checkmac or verify error
+ #define I2C_ECC_ERR_PARSE 0x03 // Command parse error
+ #define I2C_ECC_ERR_ECC 0x05 // ECC fault
+ #define I2C_ECC_ERR_SELFTEST 0x07 // Self-test error
+ #define I2C_ECC_ERR_EXECUTION 0x0F // Command execution error
+ #define I2C_ECC_WAKE 0x11 // Received a proper wake token.
+ #define I2C_ECC_ERR_I2C 0xCC // I2C communication error
+ #define I2C_ECC_ERR_WATCHDOG 0xEE // Watchdog about to expire
+ #define I2C_ECC_ERR_CRC 0xFF // CRC or other communications error
// the following functions are not to be used directly, and serve as the
// communication backend for securechip/securechip.c.
diff --git a/src/keystore.c b/src/keystore.c
index 66fe60af..1357f0d1 100644
--- a/src/keystore.c
+++ b/src/keystore.c
@@ -330,8 +330,7 @@ keystore_error_t keystore_encrypt_and_store_seed(
return KEYSTORE_ERR_MEMORY;
}
if (!rust_keystore_verify_seed(
- rust_util_bytes(secret, sizeof(secret)),
- rust_util_bytes(seed, seed_length))) {
+ rust_util_bytes(secret, sizeof(secret)), rust_util_bytes(seed, seed_length))) {
if (!memory_reset_hww()) {
return KEYSTORE_ERR_MEMORY;
}
diff --git a/src/memory/memory.c b/src/memory/memory.c
index f5b58352..e1e173fe 100644
--- a/src/memory/memory.c
+++ b/src/memory/memory.c
@@ -27,9 +27,9 @@
#include <rust/rust.h>
#ifndef TESTING
-#include <hal_delay.h>
+ #include <hal_delay.h>
#else
-#include <fake_memory.h>
+ #include <fake_memory.h>
#endif
#include <assert.h>
@@ -46,10 +46,10 @@ const char* MEMORY_DEFAULT_DEVICE_NAME = "My BitBox";
// Everything defaults to 0xFF (erased state).
#if (FLASH_APPDATA_START % CHUNK_SIZE)
-#error "Chunk start not aligned with erase granularity"
+ #error "Chunk start not aligned with erase granularity"
#endif
#if (FLASH_APPDATA_LEN % CHUNK_SIZE)
-#error "Chunk end not aligned with erase granularity"
+ #error "Chunk end not aligned with erase granularity"
#endif
#pragma GCC diagnostic push
@@ -123,8 +123,8 @@ typedef union {
static_assert(sizeof(((chunk_2_t*)0)->fields) <= (size_t)CHUNK_SIZE, "chunk too large");
#if FLASH_APPDATA_LEN / CHUNK_SIZE != 8
-#error \
- "We expect 8 chunks in app data. This check is to ensure that chunk_7_t below is the last chunk, so it is not erased during reset."
+ #error \
+ "We expect 8 chunks in app data. This check is to ensure that chunk_7_t below is the last chunk, so it is not erased during reset."
#endif
// CHUNK_7: A chunk that survives device resets (is not erased during `memory_reset_hww()`).
diff --git a/src/memory/memory_shared.c b/src/memory/memory_shared.c
index 755280ce..e355d8b4 100644
--- a/src/memory/memory_shared.c
+++ b/src/memory/memory_shared.c
@@ -28,7 +28,7 @@
#include "random.h"
#ifdef TESTING
-#include <fake_memory.h>
+ #include <fake_memory.h>
#endif
static void _clean_chunk(uint8_t** chunk_bytes)
diff --git a/src/memory/memory_shared.h b/src/memory/memory_shared.h
index 33ca2dd5..7099c0e7 100644
--- a/src/memory/memory_shared.h
+++ b/src/memory/memory_shared.h
@@ -22,7 +22,7 @@
#include <flags.h>
#if (FLASH_SHARED_DATA_LEN != CHUNK_SIZE)
-#error "Shared data chunk not correct length"
+ #error "Shared data chunk not correct length"
#endif
#define BOOT_NUM_FIRMWARE_SIGNING_KEYS 3u
diff --git a/src/memory/memory_spi.h b/src/memory/memory_spi.h
index 9ef20c0c..a4ef6699 100644
--- a/src/memory/memory_spi.h
+++ b/src/memory/memory_spi.h
@@ -30,10 +30,10 @@
#define MEMORY_SPI_BLE_FIRMWARE_2_ADDR MEMORY_SPI_BLE_FIRMWARE_MAX_SIZE
#if (MEMORY_SPI_BLE_FIRMWARE_1_ADDR % MEMORY_SPI_ERASE_GRANULARITY)
-#error "Address must be aligned to an erase sector"
+ #error "Address must be aligned to an erase sector"
#endif
#if (MEMORY_SPI_BLE_FIRMWARE_2_ADDR % MEMORY_SPI_ERASE_GRANULARITY)
-#error "Address must be aligned to an erase sector"
+ #error "Address must be aligned to an erase sector"
#endif
/**
diff --git a/src/memory/mpu.h b/src/memory/mpu.h
index f9e1bdc2..6ff9df39 100644
--- a/src/memory/mpu.h
+++ b/src/memory/mpu.h
@@ -16,60 +16,60 @@
#define _MPU_H_
#ifndef TESTING
-#include <stdint.h>
+ #include <stdint.h>
-/**
- * MPU - Memory Protection Unit
- */
-#define MPU_ENABLE (0x01)
-#define MPU_DISABLE (0x00)
+ /**
+ * MPU - Memory Protection Unit
+ */
+ #define MPU_ENABLE (0x01)
+ #define MPU_DISABLE (0x00)
-/**
- * RBAR - Region Base Address Register (CMSIS: SCB->RBAR)
- *
- * Bit 0..3 - Region number. `0` is lowest priority. `7` is highest priority (see below)
- * Bit 4 - Region valid
- * Bit 5..31 - Base address of the region. Bottom 5 bits ignored. Base address must be a multiple
- * of its region size. Regions can overlap.
- */
+ /**
+ * RBAR - Region Base Address Register (CMSIS: SCB->RBAR)
+ *
+ * Bit 0..3 - Region number. `0` is lowest priority. `7` is highest priority (see below)
+ * Bit 4 - Region valid
+ * Bit 5..31 - Base address of the region. Bottom 5 bits ignored. Base address must be a
+ * multiple of its region size. Regions can overlap.
+ */
-/**
- * Region numbers - as set in the MPU_RNR register (0-7).
- * MPU rules will be evaluated using the order of the region number.
- * The last match for a region will be the one that is enforced; so
- * regions with the higher number have higher priority.
- */
-#define MPU_REGION_NUMBER_FLASH (0u)
-#define MPU_REGION_NUMBER_SRAM (1u)
-#define MPU_REGION_NUMBER_BOOTLOADER (2u)
-#define MPU_REGION_NUMBER_SHARED_DATA (3u)
-#define MPU_REGION_NUMBER_APPDATA_0 (4u)
-#define MPU_REGION_NUMBER_APPDATA_1 (5u)
-#define MPU_REGION_NUMBER_BOOTDATA (6u)
-#define MPU_REGION_VALID (0x01 << MPU_RBAR_VALID_Pos)
+ /**
+ * Region numbers - as set in the MPU_RNR register (0-7).
+ * MPU rules will be evaluated using the order of the region number.
+ * The last match for a region will be the one that is enforced; so
+ * regions with the higher number have higher priority.
+ */
+ #define MPU_REGION_NUMBER_FLASH (0u)
+ #define MPU_REGION_NUMBER_SRAM (1u)
+ #define MPU_REGION_NUMBER_BOOTLOADER (2u)
+ #define MPU_REGION_NUMBER_SHARED_DATA (3u)
+ #define MPU_REGION_NUMBER_APPDATA_0 (4u)
+ #define MPU_REGION_NUMBER_APPDATA_1 (5u)
+ #define MPU_REGION_NUMBER_BOOTDATA (6u)
+ #define MPU_REGION_VALID (0x01 << MPU_RBAR_VALID_Pos)
-/**
- * RASR - MPU Region Attribute and Size Register (CMSIS: SCB->RASR)
- *
- * Bit 0 – Enable region
- * Bit 1..5 – Region size; 2^(flash_size + 1)
- * Bit 16..21 – Memory type; TEX | Shareable | Cacheable | Bufferable
- * Bit 24..26 – Access Privilege
- * Bit 28 – Non-excutable region (XN)
- */
-#define MPU_REGION_DISABLE (0x00 << MPU_RASR_ENABLE_Pos)
-#define MPU_REGION_ENABLE (0x01 << MPU_RASR_ENABLE_Pos)
-#define MPU_REGION_TYPE_NORMAL \
- (0x08 << MPU_RASR_ATTRS_Pos) // TEX:b001 S:b0 C:b0 B:b0 - non-shareable, non-cacheable
-#define MPU_REGION_TYPE_STRONGLY_ORDERED (0x04 << MPU_RASR_ATTRS_Pos) // TEX:b000 S:b1 C:b0 B:b0
-#define MPU_REGION_TYPE_DEVICE (0x05 << MPU_RASR_ATTRS_Pos) // TEX:b000 S:b1 C:b0 B:b1
-#define MPU_REGION_NO_ACCESS (0x00 << MPU_RASR_AP_Pos)
-#define MPU_REGION_PRIVILEGED_READ_WRITE (0x01 << MPU_RASR_AP_Pos) // No user-mode access
-#define MPU_REGION_PRIVILEGED_RW_USER_RO (0x02 << MPU_RASR_AP_Pos) // No user-mode access
-#define MPU_REGION_READ_WRITE (0x03 << MPU_RASR_AP_Pos)
-#define MPU_REGION_PRIVILEGED_READ_ONLY (0x05 << MPU_RASR_AP_Pos) // No user-mode access
-#define MPU_REGION_READ_ONLY (0x06 << MPU_RASR_AP_Pos)
-#define MPU_REGION_EXECUTE_NEVER (0x01 << MPU_RASR_XN_Pos)
+ /**
+ * RASR - MPU Region Attribute and Size Register (CMSIS: SCB->RASR)
+ *
+ * Bit 0 – Enable region
+ * Bit 1..5 – Region size; 2^(flash_size + 1)
+ * Bit 16..21 – Memory type; TEX | Shareable | Cacheable | Bufferable
+ * Bit 24..26 – Access Privilege
+ * Bit 28 – Non-excutable region (XN)
+ */
+ #define MPU_REGION_DISABLE (0x00 << MPU_RASR_ENABLE_Pos)
+ #define MPU_REGION_ENABLE (0x01 << MPU_RASR_ENABLE_Pos)
+ #define MPU_REGION_TYPE_NORMAL \
+ (0x08 << MPU_RASR_ATTRS_Pos) // TEX:b001 S:b0 C:b0 B:b0 - non-shareable, non-cacheable
+ #define MPU_REGION_TYPE_STRONGLY_ORDERED (0x04 << MPU_RASR_ATTRS_Pos) // TEX:b000 S:b1 C:b0 B:b0
+ #define MPU_REGION_TYPE_DEVICE (0x05 << MPU_RASR_ATTRS_Pos) // TEX:b000 S:b1 C:b0 B:b1
+ #define MPU_REGION_NO_ACCESS (0x00 << MPU_RASR_AP_Pos)
+ #define MPU_REGION_PRIVILEGED_READ_WRITE (0x01 << MPU_RASR_AP_Pos) // No user-mode access
+ #define MPU_REGION_PRIVILEGED_RW_USER_RO (0x02 << MPU_RASR_AP_Pos) // No user-mode access
+ #define MPU_REGION_READ_WRITE (0x03 << MPU_RASR_AP_Pos)
+ #define MPU_REGION_PRIVILEGED_READ_ONLY (0x05 << MPU_RASR_AP_Pos) // No user-mode access
+ #define MPU_REGION_READ_ONLY (0x06 << MPU_RASR_AP_Pos)
+ #define MPU_REGION_EXECUTE_NEVER (0x01 << MPU_RASR_XN_Pos)
/**
* Computes the "Region size" (bits 1..5) field of the RASR (see above),
diff --git a/src/optiga/optiga.c b/src/optiga/optiga.c
index a4b68690..04f62dd3 100644
--- a/src/optiga/optiga.c
+++ b/src/optiga/optiga.c
@@ -38,9 +38,9 @@
// causes a noticable delay at boot, so we don't enable it for production firmwares. We also enable
// it in debug builds.
#if FACTORYSETUP == 1 || FACTORY_DURING_PROD == 1 || !defined(NDEBUG)
-#define VERIFY_METADATA 1
+ #define VERIFY_METADATA 1
#else
-#define VERIFY_METADATA 0
+ #define VERIFY_METADATA 0
#endif
// Number of times the first kdf slot can be used over the lifetime of the device.
@@ -455,7 +455,7 @@ static const uint8_t _counter_password_metadata[] = {
#endif
#if SMALL_MONOTONIC_COUNTER_MAX_USE > 255
-#error Max unlock attempts does not fit in one byte
+ #error Max unlock attempts does not fit in one byte
#endif
// The intial/reset buffer for the small monotonic counter. Initial value: 0, threshold:
// `SMALL_MONOTONIC_COUNTER_MAX_USE`. Table "Common data structures" -> "Counter":
diff --git a/src/platform/driver_init.c b/src/platform/driver_init.c
index 69dbf0ea..3db89fb6 100644
--- a/src/platform/driver_init.c
+++ b/src/platform/driver_init.c
@@ -301,7 +301,7 @@ static void _usb_set_pins(void)
*/
#if (CONF_GCLK_USB_FREQUENCY > (48000000 + 48000000 / 400)) || \
(CONF_GCLK_USB_FREQUENCY < (48000000 - 48000000 / 400))
-#warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
+ #warning USB clock should be 48MHz ~ 0.25% clock, check your configuration!
#endif
/**
diff --git a/src/platform/driver_init.h b/src/platform/driver_init.h
index d656433f..b0f77e48 100644
--- a/src/platform/driver_init.h
+++ b/src/platform/driver_init.h
@@ -18,25 +18,25 @@
#define _DRIVER_INIT_H_
#ifndef TESTING
-#include "CryptoLib_Headers_pb.h"
-#include <bitbox02_pins.h>
-#include <hal_atomic.h>
-#include <hal_delay.h>
-#include <hal_flash.h>
-#include <hal_i2c_m_sync.h>
-#include <hal_init.h>
-#include <hal_io.h>
-#include <hal_mci_sync.h>
-#include <hal_pac.h>
-#include <hal_rand_sync.h>
-#include <hal_sha_sync.h>
-#include <hal_sleep.h>
-#include <hal_timer.h>
-#include <hal_usart_async.h>
-#include <hal_usb_device.h>
-#include <hpl_rtc_base.h>
-#include <sd_mmc.h>
-#include <spi_lite.h>
+ #include "CryptoLib_Headers_pb.h"
+ #include <bitbox02_pins.h>
+ #include <hal_atomic.h>
+ #include <hal_delay.h>
+ #include <hal_flash.h>
+ #include <hal_i2c_m_sync.h>
+ #include <hal_init.h>
+ #include <hal_io.h>
+ #include <hal_mci_sync.h>
+ #include <hal_pac.h>
+ #include <hal_rand_sync.h>
+ #include <hal_sha_sync.h>
+ #include <hal_sleep.h>
+ #include <hal_timer.h>
+ #include <hal_usart_async.h>
+ #include <hal_usb_device.h>
+ #include <hpl_rtc_base.h>
+ #include <sd_mmc.h>
+ #include <spi_lite.h>
#endif
#include <utils.h>
#include <utils_assert.h>
diff --git a/src/platform/platform_config.h b/src/platform/platform_config.h
index 3056b06e..1c1425ea 100644
--- a/src/platform/platform_config.h
+++ b/src/platform/platform_config.h
@@ -18,65 +18,65 @@
// Force the PRODUCT_ defines to be 0 or 1, so they can be used safely without risk of typos.
#if !defined(PRODUCT_BITBOX_MULTI)
-#define PRODUCT_BITBOX_MULTI 0
+ #define PRODUCT_BITBOX_MULTI 0
#elif PRODUCT_BITBOX_MULTI != 1
-#error "invalid product value"
+ #error "invalid product value"
#endif
#if !defined(PRODUCT_BITBOX_BTCONLY)
-#define PRODUCT_BITBOX_BTCONLY 0
+ #define PRODUCT_BITBOX_BTCONLY 0
#elif PRODUCT_BITBOX_BTCONLY != 1
-#error "invalid product value"
+ #error "invalid product value"
#endif
#if !defined(PRODUCT_BITBOX_PLUS_MULTI)
-#define PRODUCT_BITBOX_PLUS_MULTI 0
+ #define PRODUCT_BITBOX_PLUS_MULTI 0
#elif PRODUCT_BITBOX_PLUS_MULTI != 1
-#error "invalid product value"
+ #error "invalid product value"
#endif
#if !defined(PRODUCT_BITBOX_PLUS_BTCONLY)
-#define PRODUCT_BITBOX_PLUS_BTCONLY 0
+ #define PRODUCT_BITBOX_PLUS_BTCONLY 0
#elif PRODUCT_BITBOX_PLUS_BTCONLY != 1
-#error "invalid product value"
+ #error "invalid product value"
#endif
#if !defined(PRODUCT_BITBOX02_FACTORYSETUP)
-#define PRODUCT_BITBOX02_FACTORYSETUP 0
+ #define PRODUCT_BITBOX02_FACTORYSETUP 0
#elif PRODUCT_BITBOX02_FACTORYSETUP != 1
-#error "invald product value"
+ #error "invald product value"
#endif
// Derive other useful definitions from the product.
#if PRODUCT_BITBOX_MULTI == 1
-#define PLATFORM_BITBOX02PLUS 0
-#define PLATFORM_BITBOX02 1
-#define FACTORYSETUP 0
+ #define PLATFORM_BITBOX02PLUS 0
+ #define PLATFORM_BITBOX02 1
+ #define FACTORYSETUP 0
#endif
#if PRODUCT_BITBOX_BTCONLY == 1
-#define PLATFORM_BITBOX02PLUS 0
-#define PLATFORM_BITBOX02 1
-#define FACTORYSETUP 0
+ #define PLATFORM_BITBOX02PLUS 0
+ #define PLATFORM_BITBOX02 1
+ #define FACTORYSETUP 0
#endif
#if PRODUCT_BITBOX_PLUS_MULTI == 1
-#define PLATFORM_BITBOX02PLUS 1
-#define PLATFORM_BITBOX02 0
-#define FACTORYSETUP 0
+ #define PLATFORM_BITBOX02PLUS 1
+ #define PLATFORM_BITBOX02 0
+ #define FACTORYSETUP 0
#endif
#if PRODUCT_BITBOX_PLUS_BTCONLY == 1
-#define PLATFORM_BITBOX02PLUS 1
-#define PLATFORM_BITBOX02 0
-#define FACTORYSETUP 0
+ #define PLATFORM_BITBOX02PLUS 1
+ #define PLATFORM_BITBOX02 0
+ #define FACTORYSETUP 0
#endif
#if PRODUCT_BITBOX02_FACTORYSETUP == 1
-#define PLATFORM_BITBOX02PLUS 0
-#define PLATFORM_BITBOX02 1
-#define FACTORYSETUP 1
+ #define PLATFORM_BITBOX02PLUS 0
+ #define PLATFORM_BITBOX02 1
+ #define FACTORYSETUP 1
#endif
#endif
diff --git a/src/platform/platform_init.c b/src/platform/platform_init.c
index 36a480a9..735bed44 100644
--- a/src/platform/platform_init.c
+++ b/src/platform/platform_init.c
@@ -18,18 +18,18 @@
#include <driver_init.h>
#include <ui/oled/oled.h>
#if !defined(BOOTLOADER)
-#include "sd_mmc/sd_mmc_start.h"
+ #include "sd_mmc/sd_mmc_start.h"
#endif
#include "util.h"
#if !(defined(BOOTLOADER) && PLATFORM_BITBOX02 == 1)
-#include "uart.h"
+ #include "uart.h"
#endif
#if defined(BOOTLOADER)
-#define PREFIX "boot"
+ #define PREFIX "boot"
#else
-#define PREFIX "fw"
+ #define PREFIX "fw"
#endif
void platform_init(void)
diff --git a/src/pukcc/curve_p256.c b/src/pukcc/curve_p256.c
index c5f2a383..75065c5f 100644
--- a/src/pukcc/curve_p256.c
+++ b/src/pukcc/curve_p256.c
@@ -19,7 +19,7 @@
#define CURVE_TEST_MSG "abcd"
#if (CURVE_TEST_MSG_LEN > PUKCC_ECC_TEST_MSG_MAX_LEN)
-#error "macro mismatch"
+ #error "macro mismatch"
#endif
// clang-format off
diff --git a/src/qtouch/qtouch.c b/src/qtouch/qtouch.c
index f6ad8f57..ad146e0d 100644
--- a/src/qtouch/qtouch.c
+++ b/src/qtouch/qtouch.c
@@ -462,7 +462,7 @@ void qtouch_process(void)
/* if the Acquistion request was successful then clear the request flag */
if (TOUCH_SUCCESS == touch_ret) {
/* Clear the Measure request flag */
- p_qtm_control->binding_layer_flags &= (uint8_t) ~(1U << time_to_measure_touch);
+ p_qtm_control->binding_layer_flags &= (uint8_t)~(1U << time_to_measure_touch);
}
}
@@ -481,7 +481,7 @@ void qtouch_process(void)
}
/* Reset the flags for node_level_post_processing */
- p_qtm_control->binding_layer_flags &= (uint8_t) ~(1U << node_pp_request);
+ p_qtm_control->binding_layer_flags &= (uint8_t)~(1U << node_pp_request);
if (p_qtm_control->binding_layer_flags & (1U << reburst_request)) {
p_qtm_control->binding_layer_flags |= (1U << time_to_measure_touch);
diff --git a/src/queue.c b/src/queue.c
index 5fc3c713..33c42616 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -17,10 +17,10 @@
#include <util.h>
#ifndef TESTING
-#include <hal_atomic.h>
+ #include <hal_atomic.h>
#else
-#define CRITICAL_SECTION_ENTER()
-#define CRITICAL_SECTION_LEAVE()
+ #define CRITICAL_SECTION_ENTER()
+ #define CRITICAL_SECTION_LEAVE()
#endif
#include "hardfault.h"
diff --git a/src/random.c b/src/random.c
index a5e143b4..b874fa8e 100644
--- a/src/random.c
+++ b/src/random.c
@@ -15,10 +15,10 @@
#include <stdio.h>
#include <string.h>
#ifndef TESTING
-#include "driver_init.h"
-#include "flags.h"
-#include "securechip/securechip.h"
-#include <hal_rand_sync.h>
+ #include "driver_init.h"
+ #include "flags.h"
+ #include "securechip/securechip.h"
+ #include <hal_rand_sync.h>
#endif
#include "hardfault.h"
#include "random.h"
diff --git a/src/reset.c b/src/reset.c
index 0184d5e3..16edbd17 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -26,11 +26,11 @@
#include <screen.h>
#ifndef TESTING
-#include "securechip/securechip.h"
-#include <driver_init.h>
-#include <hal_delay.h>
-#include <ui/components/status.h>
-#include <ui/ugui/ugui.h>
+ #include "securechip/securechip.h"
+ #include <driver_init.h>
+ #include <hal_delay.h>
+ #include <ui/components/status.h>
+ #include <ui/ugui/ugui.h>
#endif
#if !defined(TESTING)
@@ -77,7 +77,7 @@ void reset_reset(bool status)
if (!sc_result_reset_keys) {
Abort("Could not reset secure chip.");
}
-#if APP_U2F == 1
+ #if APP_U2F == 1
bool sc_result_u2f_counter_set = false;
for (int retries = 0; retries < 5; retries++) {
sc_result_u2f_counter_set = securechip_u2f_counter_set(0);
@@ -88,7 +88,7 @@ void reset_reset(bool status)
if (!sc_result_u2f_counter_set) {
Abort("Could not initialize U2F counter.");
}
-#endif
+ #endif
#endif
if (!memory_reset_hww()) {
Abort("Could not reset memory.");
diff --git a/src/rust/bitbox02-sys/wrapper.h b/src/rust/bitbox02-sys/wrapper.h
index af56304a..94a38d56 100644
--- a/src/rust/bitbox02-sys/wrapper.h
+++ b/src/rust/bitbox02-sys/wrapper.h
@@ -52,11 +52,11 @@
#include <util.h>
#if defined(TESTING)
-#include <fake_memory.h>
+ #include <fake_memory.h>
#endif
#if !defined(TESTING)
-#include <hal_delay.h>
+ #include <hal_delay.h>
#else
void delay_us(const uint16_t us);
void delay_ms(const uint16_t ms);
diff --git a/src/screen.c b/src/screen.c
index f0fbecda..fa3af691 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -26,7 +26,7 @@
#include <utils_assert.h>
#ifndef TESTING
-#include <hal_delay.h>
+ #include <hal_delay.h>
#endif
static UG_GUI guioled; // Global GUI structure for OLED screen
diff --git a/src/sd.c b/src/sd.c
index 98bf0d59..d6cf14e7 100644
--- a/src/sd.c
+++ b/src/sd.c
@@ -18,10 +18,10 @@
#include <string.h>
#ifndef TESTING
-#include "driver_init.h"
-#include "sd_mmc.h"
-#include "sd_mmc/sd_mmc_ext.h"
-#include "sd_mmc/sd_mmc_start.h"
+ #include "driver_init.h"
+ #include "sd_mmc.h"
+ #include "sd_mmc/sd_mmc_ext.h"
+ #include "sd_mmc/sd_mmc_start.h"
#endif
#include "flags.h"
@@ -35,7 +35,7 @@
// max number of files returned by sd_list/sd_list_subdir.
#define LIST_MAX 200u
#if LIST_MAX < 1
-#error LIST_MAX must be at least 1
+ #error LIST_MAX must be at least 1
#endif
static const char* ROOTDIR = "0:/bitbox02";
@@ -326,7 +326,7 @@ bool sd_card_inserted(void)
}
}
sd_mmc_pause_clock();
-#if !defined(NDEBUG)
+ #if !defined(NDEBUG)
switch (err) {
case SD_MMC_OK:
break;
@@ -340,7 +340,7 @@ bool sd_card_inserted(void)
util_log("sd_mmc_check returned %d", err);
break;
}
-#endif
+ #endif
return err == SD_MMC_OK;
#endif
}
diff --git a/src/system.c b/src/system.c
index 40e9dc07..c7c2c4f9 100644
--- a/src/system.c
+++ b/src/system.c
@@ -19,8 +19,8 @@
#include <memory/memory_shared.h>
#include <screen.h>
#ifndef TESTING
-#include "uart.h"
-#include <driver_init.h>
+ #include "uart.h"
+ #include <driver_init.h>
#endif
static void _ble_clear_product(void)
diff --git a/src/touch/gestures.c b/src/touch/gestures.c
index 640bf6dd..d80b5ab8 100644
--- a/src/touch/gestures.c
+++ b/src/touch/gestures.c
@@ -19,10 +19,10 @@
#include <string.h>
#ifndef TESTING
-#include "qtouch.h"
-#include <driver_init.h>
+ #include "qtouch.h"
+ #include <driver_init.h>
#else
-#include "fake_qtouch.h"
+ #include "fake_qtouch.h"
#endif
#include "gestures.h"
diff --git a/src/touch/gestures.h b/src/touch/gestures.h
index c6bc771c..90069e06 100644
--- a/src/touch/gestures.h
+++ b/src/touch/gestures.h
@@ -21,14 +21,14 @@
#include <ui/component.h>
#ifndef TESTING
-#include "qtouch.h"
-#define TOUCH_NUM_BUTTONS DEF_NUM_CHANNELS
-#define TOUCH_NUM_SLIDERS DEF_NUM_SCROLLERS
-#define MAX_SLIDER_POS (DEF_SCROLLER_RESOLUTION - 1)
+ #include "qtouch.h"
+ #define TOUCH_NUM_BUTTONS DEF_NUM_CHANNELS
+ #define TOUCH_NUM_SLIDERS DEF_NUM_SCROLLERS
+ #define MAX_SLIDER_POS (DEF_SCROLLER_RESOLUTION - 1)
#else
-#define TOUCH_NUM_BUTTONS (8)
-#define TOUCH_NUM_SLIDERS (2)
-#define MAX_SLIDER_POS (255)
+ #define TOUCH_NUM_BUTTONS (8)
+ #define TOUCH_NUM_SLIDERS (2)
+ #define MAX_SLIDER_POS (255)
#endif
#define SLIDER_POSITION_ONE_THIRD (MAX_SLIDER_POS / 3)
#define SLIDER_POSITION_TWO_THIRD (MAX_SLIDER_POS / 3 * 2)
diff --git a/src/u2f.c b/src/u2f.c
index 70f37c2a..04e07374 100644
--- a/src/u2f.c
+++ b/src/u2f.c
@@ -36,7 +36,7 @@
#include <version.h>
#ifndef TESTING
-#include <hal_timer.h>
+ #include <hal_timer.h>
extern struct timer_descriptor TIMER_0;
#endif
@@ -52,7 +52,7 @@ typedef struct {
#define HMAC_SHA256_LEN 32
#if (U2F_EC_KEY_SIZE != SHA256_LEN) || (U2F_EC_KEY_SIZE != U2F_NONCE_LENGTH)
-#error "Incorrect macro values for u2f"
+ #error "Incorrect macro values for u2f"
#endif
typedef enum {
diff --git a/src/ui/components/orientation_arrows.c b/src/ui/components/orientation_arrows.c
index 1de20389..7e642830 100644
--- a/src/ui/components/orientation_arrows.c
+++ b/src/ui/components/orientation_arrows.c
@@ -24,9 +24,9 @@
#include <string.h>
#if !defined(TESTING)
-#include <qtouch.h>
+ #include <qtouch.h>
#else
-#include <fake_qtouch.h>
+ #include <fake_qtouch.h>
#endif
#define SCALE 2 // Divide `count` by scale to slow down motion
diff --git a/src/ui/components/trinary_input_string.c b/src/ui/components/trinary_input_string.c
index 28af00d1..43de3fd2 100644
--- a/src/ui/components/trinary_input_string.c
+++ b/src/ui/components/trinary_input_string.c
@@ -36,7 +36,7 @@
#include <string.h>
#ifndef TESTING
-#include <driver_init.h>
+ #include <driver_init.h>
#endif
#define EMPTY_CHAR '_'
diff --git a/src/ui/components/ui_images.c b/src/ui/components/ui_images.c
index 1894c0f7..fcec8cb9 100644
--- a/src/ui/components/ui_images.c
+++ b/src/ui/components/ui_images.c
@@ -132,9 +132,9 @@ void image_sdcard(bool mirror)
#if (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_PLUS_BTCONLY == 1)
-#if !defined(BOOTLOADER) || (PRODUCT_BITBOX_BTCONLY == 1)
-#define IMAGE_BITBOX02_LOGO_W 79
-#define IMAGE_BITBOX02_LOGO_H 25
+ #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_BTCONLY == 1)
+ #define IMAGE_BITBOX02_LOGO_W 79
+ #define IMAGE_BITBOX02_LOGO_H 25
const uint8_t IMAGE_BITBOX02_LOGO[] = {
0xfe, 0x0c, 0x30, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x18, 0x60, 0xff, 0x00, 0x00,
0x00, 0x07, 0x80, 0xf3, 0x06, 0x00, 0xc1, 0x83, 0x00, 0x00, 0x00, 0x10, 0x82, 0x16, 0x0c, 0x67,
@@ -152,11 +152,11 @@ const uint8_t IMAGE_BITBOX02_LOGO[] = {
0x92, 0x52, 0xa4, 0x12, 0x94, 0xa1, 0x09, 0x49, 0x4a, 0x79, 0x23, 0x19, 0x48, 0x19, 0x28, 0x81,
0xce, 0x92, 0x64, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00};
-#endif
+ #endif
-#if !defined(BOOTLOADER) || (PRODUCT_BITBOX_PLUS_BTCONLY == 1)
-#define IMAGE_BITBOX02_PLUS_LOGO_W 125
-#define IMAGE_BITBOX02_PLUS_LOGO_H 25
+ #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_PLUS_BTCONLY == 1)
+ #define IMAGE_BITBOX02_PLUS_LOGO_W 125
+ #define IMAGE_BITBOX02_PLUS_LOGO_H 25
static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = {
0xfe, 0x0c, 0x30, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x07,
0xf8, 0x61, 0x83, 0xfc, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xc0, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x30,
@@ -184,14 +184,14 @@ static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-#endif
+ #endif
#elif (PRODUCT_BITBOX_MULTI == 1) || (PRODUCT_BITBOX_PLUS_MULTI == 1) || \
PRODUCT_BITBOX02_FACTORYSETUP == 1
-#if !defined(BOOTLOADER) || (PRODUCT_BITBOX_MULTI == 1)
-#define IMAGE_BITBOX02_LOGO_W 79
-#define IMAGE_BITBOX02_LOGO_H 23
+ #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_MULTI == 1)
+ #define IMAGE_BITBOX02_LOGO_W 79
+ #define IMAGE_BITBOX02_LOGO_H 23
static const uint8_t IMAGE_BITBOX02_LOGO[] = {
0xfe, 0x0c, 0x30, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x18, 0x60, 0xff, 0x00, 0x00,
0x00, 0x07, 0x80, 0xf3, 0x06, 0x00, 0xc1, 0x83, 0x00, 0x00, 0x00, 0x10, 0x82, 0x16, 0x0c, 0x67,
@@ -208,11 +208,11 @@ static const uint8_t IMAGE_BITBOX02_LOGO[] = {
0x25, 0x29, 0x00, 0x00, 0x00, 0x09, 0x29, 0x49, 0x0f, 0x4a, 0x4a, 0x52, 0x00, 0x00, 0x00, 0x12,
0x52, 0x92, 0x10, 0x94, 0x94, 0xa4, 0x00, 0x00, 0x00, 0x20, 0x99, 0x24, 0x1c, 0xe9, 0x26, 0x48,
0x00, 0x00, 0x00, 0x00};
-#endif
+ #endif
-#if !defined(BOOTLOADER) || (PRODUCT_BITBOX_PLUS_MULTI == 1)
-#define IMAGE_BITBOX02_PLUS_LOGO_W 125
-#define IMAGE_BITBOX02_PLUS_LOGO_H 23
+ #if !defined(BOOTLOADER) || (PRODUCT_BITBOX_PLUS_MULTI == 1)
+ #define IMAGE_BITBOX02_PLUS_LOGO_W 125
+ #define IMAGE_BITBOX02_PLUS_LOGO_H 23
static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = {
0xfe, 0x0c, 0x30, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x07,
0xf8, 0x61, 0x83, 0xfc, 0x00, 0x00, 0x00, 0x1e, 0x03, 0xc0, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x30,
@@ -238,11 +238,11 @@ static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x09, 0x92, 0x41, 0xce, 0x92, 0x64, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-#endif
+ #endif
#else
-#error "Invalid product"
+ #error "Invalid product"
#endif
@@ -250,8 +250,8 @@ static const uint8_t IMAGE_BITBOX02_PLUS_LOGO[] = {
// image logo for bootloader.
image_logo_data_t image_logo_data(void)
{
-#if (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_MULTI == 1) || \
- (PRODUCT_BITBOX02_FACTORYSETUP == 1)
+ #if (PRODUCT_BITBOX_BTCONLY == 1) || (PRODUCT_BITBOX_MULTI == 1) || \
+ (PRODUCT_BITBOX02_FACTORYSETUP == 1)
image_logo_data_t result = {
.buffer =
{
@@ -265,7 +265,7 @@ image_logo_data_t image_logo_data(void)
},
};
return result;
-#elif (PRODUCT_BITBOX_PLUS_BTCONLY == 1) || (PRODUCT_BITBOX_PLUS_MULTI == 1)
+ #elif (PRODUCT_BITBOX_PLUS_BTCONLY == 1) || (PRODUCT_BITBOX_PLUS_MULTI == 1)
image_logo_data_t result = {
.buffer =
{
@@ -279,9 +279,9 @@ image_logo_data_t image_logo_data(void)
},
};
return result;
-#else
-#error "unknown platform"
-#endif
+ #else
+ #error "unknown platform"
+ #endif
}
#else
// image logo for firmware.
diff --git a/src/ui/oled/oled.h b/src/ui/oled/oled.h
index c73faeda..bad57f2e 100644
--- a/src/ui/oled/oled.h
+++ b/src/ui/oled/oled.h
@@ -61,7 +61,7 @@
#include <stdint.h>
#ifndef _OLED_H_
-#define _OLED_H_
+ #define _OLED_H_
/**
* Initialize the hardware interface and the OLED controller.
diff --git a/src/ui/screen_saver.c b/src/ui/screen_saver.c
index 837e3958..3cbaf56f 100644
--- a/src/ui/screen_saver.c
+++ b/src/ui/screen_saver.c
@@ -17,7 +17,7 @@
#include <hardfault.h>
#include <ui/components/screensaver.h>
#ifndef TESTING
-#include <ui/oled/oled.h>
+ #include <ui/oled/oled.h>
#endif
#include <stdbool.h>
diff --git a/src/usb/class/hid/hid.c b/src/usb/class/hid/hid.c
index 28200c76..8ee5e6a9 100644
--- a/src/usb/class/hid/hid.c
+++ b/src/usb/class/hid/hid.c
@@ -15,7 +15,7 @@
#include "hid.h"
#include "usb_desc.h"
#if !defined(TESTING)
-#include "usb_protocol.h"
+ #include "usb_protocol.h"
#endif
#include <string.h>
diff --git a/src/usb/class/hid/hid.h b/src/usb/class/hid/hid.h
index 7569c0c1..35e3e2e1 100644
--- a/src/usb/class/hid/hid.h
+++ b/src/usb/class/hid/hid.h
@@ -19,9 +19,9 @@
#include <stdint.h>
#if !defined(TESTING)
-#include "usb_protocol.h"
-#include "usb_protocol_hid.h"
-#include "usbdc.h"
+ #include "usb_protocol.h"
+ #include "usb_protocol_hid.h"
+ #include "usbdc.h"
#else
struct usbdc_handler;
struct usbdf_handler;
diff --git a/src/usb/class/usb_desc.h b/src/usb/class/usb_desc.h
index 08b8efb4..02e2b7dc 100644
--- a/src/usb/class/usb_desc.h
+++ b/src/usb/class/usb_desc.h
@@ -21,41 +21,42 @@
#include <bootloader/bootloader_version.h>
#include <version.h>
#ifndef TESTING
-#include "usb_protocol.h"
-#include "usb_protocol_hid.h"
-#include <usb_u2f_desc.h>
+ #include "usb_protocol.h"
+ #include "usb_protocol_hid.h"
+ #include <usb_u2f_desc.h>
#endif
#if defined(BOOTLOADER)
-#if PRODUCT_BITBOX_BTCONLY == 1
-#define USB_DESC_IPRODUCT_STR_DESC \
- 38, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'b', 0, 'b', 0, '0', 0, '2', 0, 'b', 0, 't', 0, 'c', 0, '-', 0, 'b', 0, 'o', 0, 'o', 0, \
- 't', 0, 'l', 0, 'o', 0, 'a', 0, 'd', 0, 'e', 0, 'r', 0,
-#else
-#define USB_DESC_IPRODUCT_STR_DESC \
- 32, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'b', 0, 'b', 0, '0', 0, '2', 0, '-', 0, 'b', 0, 'o', 0, 'o', 0, 't', 0, 'l', 0, 'o', 0, \
- 'a', 0, 'd', 0, 'e', 0, 'r', 0,
-#endif
+ #if PRODUCT_BITBOX_BTCONLY == 1
+ #define USB_DESC_IPRODUCT_STR_DESC \
+ 38, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'b', 0, 'b', 0, '0', 0, '2', 0, 'b', 0, 't', 0, 'c', 0, '-', 0, 'b', 0, 'o', 0, \
+ 'o', 0, 't', 0, 'l', 0, 'o', 0, 'a', 0, 'd', 0, 'e', 0, 'r', 0,
+ #else
+ #define USB_DESC_IPRODUCT_STR_DESC \
+ 32, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'b', 0, 'b', 0, '0', 0, '2', 0, '-', 0, 'b', 0, 'o', 0, 'o', 0, 't', 0, 'l', 0, \
+ 'o', 0, 'a', 0, 'd', 0, 'e', 0, 'r', 0,
+ #endif
#elif FACTORYSETUP == 1
-#define USB_DESC_IPRODUCT_STR_DESC \
- 26, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'b', 0, 'b', 0, '0', 0, '2', 0, '-', 0, 'f', 0, 'a', 0, 'c', 0, 't', 0, 'o', 0, 'r', 0, \
- 'y', 0,
+ #define USB_DESC_IPRODUCT_STR_DESC \
+ 26, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'b', 0, 'b', 0, '0', 0, '2', 0, '-', 0, 'f', 0, 'a', 0, 'c', 0, 't', 0, 'o', 0, 'r', \
+ 0, 'y', 0,
#elif PRODUCT_BITBOX_BTCONLY == 1
-#define USB_DESC_IPRODUCT_STR_DESC \
- 24, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, 'B', 0, 'T', 0, 'C', 0,
+ #define USB_DESC_IPRODUCT_STR_DESC \
+ 24, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, 'B', 0, 'T', 0, 'C', \
+ 0,
#else
-#define USB_DESC_IPRODUCT_STR_DESC \
- 18, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0,
+ #define USB_DESC_IPRODUCT_STR_DESC \
+ 18, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0,
#endif
#define USB_STR_DESC \
@@ -128,10 +129,10 @@
// (= supported endpoints) - is that the one that needs to change?
// ** If add more endpoints, adjust USB_DESC_D_MAX_EP_N **
#if APP_U2F == 0
-#define USB_DESC_FS USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_STR_DESC
+ #define USB_DESC_FS USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_STR_DESC
#else
-#define USB_DESC_FS \
- USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_DESC_IFACE_U2F, USB_STR_DESC
+ #define USB_DESC_FS \
+ USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_DESC_IFACE_U2F, USB_STR_DESC
#endif
#endif
diff --git a/src/usb/class/usb_desc_bitbox02plus.h b/src/usb/class/usb_desc_bitbox02plus.h
index 5d04096d..42dd90e8 100644
--- a/src/usb/class/usb_desc_bitbox02plus.h
+++ b/src/usb/class/usb_desc_bitbox02plus.h
@@ -20,44 +20,46 @@
#include <bootloader/bootloader_version.h>
#include <version.h>
#ifndef TESTING
-#include "usb_protocol.h"
-#include "usb_protocol_hid.h"
-#include <usb_u2f_desc.h>
+ #include "usb_protocol.h"
+ #include "usb_protocol_hid.h"
+ #include <usb_u2f_desc.h>
#endif
#if defined(BOOTLOADER)
-#if PRODUCT_BITBOX_PLUS_BTCONLY == 1
-#define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
- 52, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', 0, \
- 'v', 0, 'a', 0, ' ', 0, 'B', 0, 'T', 0, 'C', 0, '-', 0, 'o', 0, 'n', 0, 'l', 0, 'y', 0, \
- ' ', 0, 'b', 0, 'l', 0,
-#else
-#define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
- 46, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', 0, \
- 'v', 0, 'a', 0, ' ', 0, 'M', 0, 'u', 0, 'l', 0, 't', 0, 'i', 0, ' ', 0, 'b', 0, 'l', 0,
-#endif
+ #if PRODUCT_BITBOX_PLUS_BTCONLY == 1
+ #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
+ 52, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, \
+ 'o', 0, 'v', 0, 'a', 0, ' ', 0, 'B', 0, 'T', 0, 'C', 0, '-', 0, 'o', 0, 'n', 0, \
+ 'l', 0, 'y', 0, ' ', 0, 'b', 0, 'l', 0,
+ #else
+ #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
+ 46, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, \
+ 'o', 0, 'v', 0, 'a', 0, ' ', 0, 'M', 0, 'u', 0, 'l', 0, 't', 0, 'i', 0, ' ', 0, \
+ 'b', 0, 'l', 0,
+ #endif
#elif FACTORYSETUP == 1
-#define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
- 44, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', 0, \
- 'v', 0, 'a', 0, ' ', 0, 'F', 0, 'a', 0, 'c', 0, 't', 0, 'o', 0, 'r', 0, 'y', 0,
+ #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
+ 44, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', \
+ 0, 'v', 0, 'a', 0, ' ', 0, 'F', 0, 'a', 0, 'c', 0, 't', 0, 'o', 0, 'r', 0, 'y', 0,
#elif PRODUCT_BITBOX_BTCONLY == 1
-#define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
- 46, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', 0, \
- 'v', 0, 'a', 0, ' ', 0, 'B', 0, 'T', 0, 'C', 0, '-', 0, 'o', 0, 'n', 0, 'l', 0, 'y', 0,
+ #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
+ 46, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', \
+ 0, 'v', 0, 'a', 0, ' ', 0, 'B', 0, 'T', 0, 'C', 0, '-', 0, 'o', 0, 'n', 0, 'l', 0, \
+ 'y', 0,
#else
-#define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
- 40, /* bLength */ \
- 0x03, /* bDescriptorType */ \
- 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', 0, \
- 'v', 0, 'a', 0, ' ', 0, 'M', 0, 'u', 0, 'l', 0, 't', 0, 'i', 0,
+ #define USB_DESC_BB02PLUS_IPRODUCT_STR_DESC \
+ 40, /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ 'B', 0, 'i', 0, 't', 0, 'B', 0, 'o', 0, 'x', 0, '0', 0, '2', 0, ' ', 0, 'N', 0, 'o', \
+ 0, 'v', 0, 'a', 0, ' ', 0, 'M', 0, 'u', 0, 'l', 0, 't', 0, 'i', 0,
#endif
#define USB_STR_DESC_BB02PLUS \
@@ -90,11 +92,11 @@
// (= supported endpoints) - is that the one that needs to change?
// ** If add more endpoints, adjust USB_DESC_BB02PLUS_D_MAX_EP_N **
#if APP_U2F == 0
-#define USB_DESC_BB02PLUS_FS \
- USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_STR_DESC_BB02PLUS
+ #define USB_DESC_BB02PLUS_FS \
+ USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_STR_DESC_BB02PLUS
#else
-#define USB_DESC_BB02PLUS_FS \
- USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_DESC_IFACE_U2F, USB_STR_DESC_BB02PLUS
+ #define USB_DESC_BB02PLUS_FS \
+ USB_DEV_DESC, USB_DESC_CONFIG, USB_DESC_IFACE_HWW, USB_DESC_IFACE_U2F, USB_STR_DESC_BB02PLUS
#endif
#endif
diff --git a/src/usb/class/usb_desc_common.h b/src/usb/class/usb_desc_common.h
index c5bc7d35..512f0294 100644
--- a/src/usb/class/usb_desc_common.h
+++ b/src/usb/class/usb_desc_common.h
@@ -24,10 +24,10 @@
#define USB_DESC_HWW_EP_IN (1 | USB_EP_DIR_IN)
#define USB_DESC_HWW_EP_OUT (2 | USB_EP_DIR_OUT)
#if APP_U2F == 1
-#define USB_DESC_IFACE_NUM_U2F 1
-#define USB_DESC_NUM_IFACES 2
+ #define USB_DESC_IFACE_NUM_U2F 1
+ #define USB_DESC_NUM_IFACES 2
#else
-#define USB_DESC_NUM_IFACES 1
+ #define USB_DESC_NUM_IFACES 1
#endif
#define USB_DESC_IFACE_NUM_HWW 0
#define USB_DESC_IFACE_LEN 32
@@ -58,26 +58,26 @@
#define USB_DESC_ISERIALNUM 3
#ifdef BOOTLOADER
-#define USB_DESC_ISERIALNUM_STR_DESC \
- (2 + BOOTLOADER_VERSION_LEN * 2 + BOOTLOADER_VERSION_APPEND_LEN * 2), /* bLength */ \
- 0x03, /* bDescriptorType */ \
- BOOTLOADER_VERSION_W16 BOOTLOADER_VERSION_APPEND_W16
+ #define USB_DESC_ISERIALNUM_STR_DESC \
+ (2 + BOOTLOADER_VERSION_LEN * 2 + BOOTLOADER_VERSION_APPEND_LEN * 2), /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ BOOTLOADER_VERSION_W16 BOOTLOADER_VERSION_APPEND_W16
#else
-#define USB_DESC_ISERIALNUM_STR_DESC \
- (2 + DIGITAL_BITBOX_VERSION_LEN * 2), /* bLength */ \
- 0x03, /* bDescriptorType */ \
- DIGITAL_BITBOX_VERSION_W16
+ #define USB_DESC_ISERIALNUM_STR_DESC \
+ (2 + DIGITAL_BITBOX_VERSION_LEN * 2), /* bLength */ \
+ 0x03, /* bDescriptorType */ \
+ DIGITAL_BITBOX_VERSION_W16
#endif
#if defined(BOOTLOADER_DEVDEVICE) && defined(BOOTLOADER_VERSION_HAS_METADATA)
-#define BOOTLOADER_VERSION_APPEND_LEN 4
-#define BOOTLOADER_VERSION_APPEND_W16 '.', 0, 'd', 0, 'e', 0, 'v', 0,
+ #define BOOTLOADER_VERSION_APPEND_LEN 4
+ #define BOOTLOADER_VERSION_APPEND_W16 '.', 0, 'd', 0, 'e', 0, 'v', 0,
#elif defined(BOOTLOADER_DEVDEVICE)
-#define BOOTLOADER_VERSION_APPEND_LEN 4
-#define BOOTLOADER_VERSION_APPEND_W16 '+', 0, 'd', 0, 'e', 0, 'v', 0,
+ #define BOOTLOADER_VERSION_APPEND_LEN 4
+ #define BOOTLOADER_VERSION_APPEND_W16 '+', 0, 'd', 0, 'e', 0, 'v', 0,
#else
-#define BOOTLOADER_VERSION_APPEND_LEN 0
-#define BOOTLOADER_VERSION_APPEND_W16
+ #define BOOTLOADER_VERSION_APPEND_LEN 0
+ #define BOOTLOADER_VERSION_APPEND_W16
#endif
#define USB_DESC_IFACE_HWW \
diff --git a/src/usb/class/usb_u2f_desc.h b/src/usb/class/usb_u2f_desc.h
index 498a9c78..c0c4521f 100644
--- a/src/usb/class/usb_u2f_desc.h
+++ b/src/usb/class/usb_u2f_desc.h
@@ -17,31 +17,31 @@
#if APP_U2F == 1
-#ifndef TESTING
-#include "usb_protocol.h"
-#endif
+ #ifndef TESTING
+ #include "usb_protocol.h"
+ #endif
-#define USB_DESC_U2F_EP_IN (3 | USB_EP_DIR_IN)
-#define USB_DESC_U2F_EP_OUT (4 | USB_EP_DIR_OUT)
+ #define USB_DESC_U2F_EP_IN (3 | USB_EP_DIR_IN)
+ #define USB_DESC_U2F_EP_OUT (4 | USB_EP_DIR_OUT)
-#define USB_DESC_U2F_REPORT_LEN 34
-#define USB_DESC_U2F_REPORT \
- 0x06, 0xd0, 0xf1, /* USAGE_PAGE (Reserved 0xFIDO) */ \
- 0x09, 0x01, /* USAGE (HID Generic Device) */ \
- 0xa1, 0x01, /* COLLECTION (Application) */ /* In Report */ \
- 0x09, 0x20, /* USAGE (Input Report Data) */ \
- 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
- 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ \
- 0x75, 0x08, /* REPORT_SIZE (8) */ \
- 0x95, 0x40, /* REPORT_COUNT (64) */ \
- 0x81, 0x02, /* INPUT (Data,Var,Abs) */ /* Out Report */ \
- 0x09, 0x21, /* USAGE (Output Report Data) */ \
- 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
- 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ \
- 0x75, 0x08, /* REPORT_SIZE (8) */ \
- 0x95, 0x40, /* REPORT_COUNT (64) */ \
- 0x91, 0x02, /* OUTPUT (Data,Var,Abs) */ \
- 0xc0 /* END_COLLECTION */
+ #define USB_DESC_U2F_REPORT_LEN 34
+ #define USB_DESC_U2F_REPORT \
+ 0x06, 0xd0, 0xf1, /* USAGE_PAGE (Reserved 0xFIDO) */ \
+ 0x09, 0x01, /* USAGE (HID Generic Device) */ \
+ 0xa1, 0x01, /* COLLECTION (Application) */ /* In Report */ \
+ 0x09, 0x20, /* USAGE (Input Report Data) */ \
+ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
+ 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ \
+ 0x75, 0x08, /* REPORT_SIZE (8) */ \
+ 0x95, 0x40, /* REPORT_COUNT (64) */ \
+ 0x81, 0x02, /* INPUT (Data,Var,Abs) */ /* Out Report */ \
+ 0x09, 0x21, /* USAGE (Output Report Data) */ \
+ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
+ 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ \
+ 0x75, 0x08, /* REPORT_SIZE (8) */ \
+ 0x95, 0x40, /* REPORT_COUNT (64) */ \
+ 0x91, 0x02, /* OUTPUT (Data,Var,Abs) */ \
+ 0xc0 /* END_COLLECTION */
#endif
#define USB_DESC_IFACE_U2F \
diff --git a/src/usb/usb.c b/src/usb/usb.c
index 6ebe8610..4a08a323 100644
--- a/src/usb/usb.c
+++ b/src/usb/usb.c
@@ -14,24 +14,24 @@
#include "usb.h"
#ifndef TESTING
-#include "hid_hww.h"
-#include "usb_desc.h"
-#include "usb_desc_bitbox02plus.h"
-#include "usb_size.h"
-#include "usbdc.h"
-#include <da14531/da14531.h>
-#include <da14531/da14531_handler.h>
-#include <memory/memory_shared.h>
-#if APP_U2F == 1
-#include "u2f.h"
-#include <usb/class/hid/u2f/hid_u2f.h>
-#endif
+ #include "hid_hww.h"
+ #include "usb_desc.h"
+ #include "usb_desc_bitbox02plus.h"
+ #include "usb_size.h"
+ #include "usbdc.h"
+ #include <da14531/da14531.h>
+ #include <da14531/da14531_handler.h>
+ #include <memory/memory_shared.h>
+ #if APP_U2F == 1
+ #include "u2f.h"
+ #include <usb/class/hid/u2f/hid_u2f.h>
+ #endif
#endif
#ifndef TESTING
-#include <hal_timer.h>
-#include <u2f/u2f_packet.h>
-#include <usb/usb_packet.h>
+ #include <hal_timer.h>
+ #include <u2f/u2f_packet.h>
+ #include <usb/usb_packet.h>
extern struct timer_descriptor TIMER_0;
#endif
@@ -49,9 +49,9 @@ static struct usbd_descriptors _descriptor_bitbox02plus[] = {
{_descriptor_bytes_bitbox02plus,
_descriptor_bytes_bitbox02plus + sizeof(_descriptor_bytes_bitbox02plus)}};
static void _hww_endpoint_available(void);
-#if APP_U2F == 1
+ #if APP_U2F == 1
static void _u2f_endpoint_available(void);
-#endif
+ #endif
/* ==== HWW ==== */
static void _hww_endpoint_available(void)
@@ -62,7 +62,7 @@ static void _hww_endpoint_available(void)
hid_hww_setup();
}
-#if APP_U2F == 1
+ #if APP_U2F == 1
/* ==== U2F ==== */
static void _u2f_endpoint_available(void)
{
@@ -71,7 +71,7 @@ static void _u2f_endpoint_available(void)
};
hid_u2f_setup();
}
-#endif
+ #endif
#endif
#if !defined(TESTING) && APP_U2F == 1
@@ -106,12 +106,12 @@ int32_t usb_start(void)
if (ret != 0) {
return ret;
}
-#if APP_U2F == 1
+ #if APP_U2F == 1
ret = hid_u2f_init(_u2f_endpoint_available);
if (ret != 0) {
return ret;
}
-#endif
+ #endif
switch (memory_get_platform()) {
case MEMORY_PLATFORM_BITBOX02_PLUS:
usbdc_start(_descriptor_bitbox02plus);
diff --git a/src/usb/usb_frame.c b/src/usb/usb_frame.c
index 64a036b0..683428f8 100644
--- a/src/usb/usb_frame.c
+++ b/src/usb/usb_frame.c
@@ -15,7 +15,7 @@
#include "usb_frame.h"
#include "queue.h"
#if APP_U2F == 1
-#include "u2f/u2f_packet.h"
+ #include "u2f/u2f_packet.h"
#endif
#include "usb/u2f/u2f_hid.h"
#include "usb/usb_packet.h"
diff --git a/src/usb/usb_processing.c b/src/usb/usb_processing.c
index 4045e9d0..ed04a50d 100644
--- a/src/usb/usb_processing.c
+++ b/src/usb/usb_processing.c
@@ -22,11 +22,11 @@
#include <hardfault.h>
#if !defined(BOOTLOADER)
-#include <hww.h>
-#ifndef TESTING
-#include <hal_timer.h>
+ #include <hww.h>
+ #ifndef TESTING
+ #include <hal_timer.h>
extern struct timer_descriptor TIMER_0;
-#endif
+ #endif
#endif
#include <queue.h>
diff --git a/src/util.c b/src/util.c
index d984a674..f80ae726 100644
--- a/src/util.c
+++ b/src/util.c
@@ -28,15 +28,15 @@ void util_zero(volatile void* dst, size_t len)
// Rust doesn't have a volatile qualifier becuase volatile refers to the act of writing/reading
// not the data type.
#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
rust_util_zero(rust_util_bytes_mut(dst, len));
-#pragma clang diagnostic pop
+ #pragma clang diagnostic pop
#else
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
rust_util_zero(rust_util_bytes_mut(dst, len));
-#pragma GCC diagnostic pop
+ #pragma GCC diagnostic pop
#endif
}
diff --git a/src/util.h b/src/util.h
index ad671e24..cee22353 100644
--- a/src/util.h
+++ b/src/util.h
@@ -130,14 +130,14 @@ typedef enum { ASYNC_OP_TRUE, ASYNC_OP_FALSE, ASYNC_OP_NOT_READY } async_op_resu
void util_log(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void util_log_flush(void);
#else
-#define util_log(...)
-#define util_log_flush(...)
+ #define util_log(...)
+ #define util_log_flush(...)
#endif
#if !defined(NDEBUG) || FACTORYSETUP == 1
void util_log_init(void);
#else
-#define util_log_init(...)
+ #define util_log_init(...)
#endif
#endif
diff --git a/src/workflow/orientation_screen.c b/src/workflow/orientation_screen.c
index f6984791..e00dec70 100644
--- a/src/workflow/orientation_screen.c
+++ b/src/workflow/orientation_screen.c
@@ -16,8 +16,8 @@
#include "orientation_screen.h"
#ifndef TESTING
-#include <hal_timer.h>
-#include <platform/driver_init.h>
+ #include <hal_timer.h>
+ #include <platform/driver_init.h>
#endif
#include <da14531/da14531.h>
#include <da14531/da14531_handler.h>
@@ -32,24 +32,25 @@
#include <version.h>
#ifndef TESTING
-#define IDLE_PERIOD_MS 1300
+ #define IDLE_PERIOD_MS 1300
-// Currently we have one firmware for both BB02 and BB02_PLUS, and only the
-// PRODUCT_BITBOX_MULTI/BTCONLY definitions apply. The PRODUCT_BITBOX_PLUS_MULTI/BTCONLY defs
-// currently only apply in the bootloader, which we don't need here.
-#if PRODUCT_BITBOX_MULTI == 1
-#define PRODUCT_STRING_SUFFIX "multi"
-#elif PRODUCT_BITBOX_BTCONLY == 1
-#define PRODUCT_STRING_SUFFIX "btconly"
-#elif PRODUCT_BITBOX02_FACTORYSETUP == 1
-// Dummy, not actually needed, but this file is currently needlessly compiled for factorysetup.
-#define PRODUCT_STRING_SUFFIX "factory"
-#else
-#error "unknown edition"
-#endif
+ // Currently we have one firmware for both BB02 and BB02_PLUS, and only the
+ // PRODUCT_BITBOX_MULTI/BTCONLY definitions apply. The PRODUCT_BITBOX_PLUS_MULTI/BTCONLY defs
+ // currently only apply in the bootloader, which we don't need here.
+ #if PRODUCT_BITBOX_MULTI == 1
+ #define PRODUCT_STRING_SUFFIX "multi"
+ #elif PRODUCT_BITBOX_BTCONLY == 1
+ #define PRODUCT_STRING_SUFFIX "btconly"
+ #elif PRODUCT_BITBOX02_FACTORYSETUP == 1
+ // Dummy, not actually needed, but this file is currently needlessly compiled for
+ // factorysetup.
+ #define PRODUCT_STRING_SUFFIX "factory"
+ #else
+ #error "unknown edition"
+ #endif
-#define DEVICE_MODE \
- "{\"p\":\"bb02p-" PRODUCT_STRING_SUFFIX "\",\"v\":\"" DIGITAL_BITBOX_VERSION "\"}"
+ #define DEVICE_MODE \
+ "{\"p\":\"bb02p-" PRODUCT_STRING_SUFFIX "\",\"v\":\"" DIGITAL_BITBOX_VERSION "\"}"
static struct timer_task _idle_timer_task = {0};
diff --git a/test/unit-test/test_u2f_hid.c b/test/unit-test/test_u2f_hid.c
index f7e25742..f979a526 100644
--- a/test/unit-test/test_u2f_hid.c
+++ b/test/unit-test/test_u2f_hid.c
@@ -13,8 +13,8 @@
#include <string.h>
#include <time.h>
#ifdef __linux__
-#include <linux/hidraw.h>
-#include <sys/ioctl.h>
+ #include <linux/hidraw.h>
+ #include <sys/ioctl.h>
#endif
#include "random.h"
diff --git a/test/unit-test/u2f/sha2.c b/test/unit-test/u2f/sha2.c
index 3263eecb..5c79455c 100644
--- a/test/unit-test/u2f/sha2.c
+++ b/test/unit-test/u2f/sha2.c
@@ -82,16 +82,16 @@
*/
#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#define BIG_ENDIAN 4321
+ #define LITTLE_ENDIAN 1234
+ #define BIG_ENDIAN 4321
#endif
#ifndef BYTE_ORDER
-#define BYTE_ORDER LITTLE_ENDIAN
+ #define BYTE_ORDER LITTLE_ENDIAN
#endif
#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
-#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
+ #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
#endif
typedef uint8_t sha2_byte; /* Exactly 1 byte */
@@ -105,19 +105,19 @@ typedef uint64_t sha2_word64; /* Exactly 8 bytes */
/*** ENDIAN REVERSAL MACROS *******************************************/
#if BYTE_ORDER == LITTLE_ENDIAN
-#define REVERSE32(w, x) \
- { \
- sha2_word32 tmp = (w); \
- tmp = (tmp >> 16) | (tmp << 16); \
- (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \
- }
-#define REVERSE64(w, x) \
- { \
- sha2_word64 tmp = (w); \
- tmp = (tmp >> 32) | (tmp << 32); \
- tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | ((tmp & 0x00ff00ff00ff00ffULL) << 8); \
- (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | ((tmp & 0x0000ffff0000ffffULL) << 16); \
- }
+ #define REVERSE32(w, x) \
+ { \
+ sha2_word32 tmp = (w); \
+ tmp = (tmp >> 16) | (tmp << 16); \
+ (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \
+ }
+ #define REVERSE64(w, x) \
+ { \
+ sha2_word64 tmp = (w); \
+ tmp = (tmp >> 32) | (tmp << 32); \
+ tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | ((tmp & 0x00ff00ff00ff00ffULL) << 8); \
+ (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | ((tmp & 0x0000ffff0000ffffULL) << 16); \
+ }
#endif /* BYTE_ORDER == LITTLE_ENDIAN */
/*
@@ -257,35 +257,35 @@ void sha256_Init(SHA256_CTX* context)
/* Unrolled SHA-256 round macros: */
-#if BYTE_ORDER == LITTLE_ENDIAN
+ #if BYTE_ORDER == LITTLE_ENDIAN
-#define ROUND256_0_TO_15(a, b, c, d, e, f, g, h) \
- REVERSE32(*data++, W256[j]); \
- T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + W256[j]; \
- (d) += T1; \
- (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
- j++
+ #define ROUND256_0_TO_15(a, b, c, d, e, f, g, h) \
+ REVERSE32(*data++, W256[j]); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + W256[j]; \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ #else /* BYTE_ORDER == LITTLE_ENDIAN */
-#define ROUND256_0_TO_15(a, b, c, d, e, f, g, h) \
- T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + (W256[j] = *data++); \
- (d) += T1; \
- (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
- j++
+ #define ROUND256_0_TO_15(a, b, c, d, e, f, g, h) \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + (W256[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
-#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ #endif /* BYTE_ORDER == LITTLE_ENDIAN */
-#define ROUND256(a, b, c, d, e, f, g, h) \
- s0 = W256[(j + 1) & 0x0f]; \
- s0 = sigma0_256(s0); \
- s1 = W256[(j + 14) & 0x0f]; \
- s1 = sigma1_256(s1); \
- T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
- (W256[j & 0x0f] += s1 + W256[(j + 9) & 0x0f] + s0); \
- (d) += T1; \
- (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
- j++
+ #define ROUND256(a, b, c, d, e, f, g, h) \
+ s0 = W256[(j + 1) & 0x0f]; \
+ s0 = sigma0_256(s0); \
+ s1 = W256[(j + 14) & 0x0f]; \
+ s1 = sigma1_256(s1); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
+ (W256[j & 0x0f] += s1 + W256[(j + 9) & 0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
void sha256_Transform(SHA256_CTX* context, const sha2_word32* data)
{
@@ -366,15 +366,15 @@ void sha256_Transform(SHA256_CTX* context, const sha2_word32* data)
j = 0;
do {
-#if BYTE_ORDER == LITTLE_ENDIAN
+ #if BYTE_ORDER == LITTLE_ENDIAN
/* Copy data while converting to host byte order */
REVERSE32(*data++, W256[j]);
/* Apply the SHA-256 compression function to update a..h */
T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j];
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ #else /* BYTE_ORDER == LITTLE_ENDIAN */
/* Apply the SHA-256 compression function to update a..h with copy */
T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++);
-#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ #endif /* BYTE_ORDER == LITTLE_ENDIAN */
T2 = Sigma0_256(a) + Maj(a, b, c);
h = g;
g = f;
@@ -556,34 +556,34 @@ void sha512_Init(SHA512_CTX* context)
#ifdef SHA2_UNROLL_TRANSFORM
-/* Unrolled SHA-512 round macros: */
-#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Unrolled SHA-512 round macros: */
+ #if BYTE_ORDER == LITTLE_ENDIAN
-#define ROUND512_0_TO_15(a, b, c, d, e, f, g, h) \
- REVERSE64(*data++, W512[j]); \
- T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + W512[j]; \
- (d) += T1, (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), j++
+ #define ROUND512_0_TO_15(a, b, c, d, e, f, g, h) \
+ REVERSE64(*data++, W512[j]); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + W512[j]; \
+ (d) += T1, (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), j++
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ #else /* BYTE_ORDER == LITTLE_ENDIAN */
-#define ROUND512_0_TO_15(a, b, c, d, e, f, g, h) \
- T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + (W512[j] = *data++); \
- (d) += T1; \
- (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
- j++
+ #define ROUND512_0_TO_15(a, b, c, d, e, f, g, h) \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + (W512[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
-#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ #endif /* BYTE_ORDER == LITTLE_ENDIAN */
-#define ROUND512(a, b, c, d, e, f, g, h) \
- s0 = W512[(j + 1) & 0x0f]; \
- s0 = sigma0_512(s0); \
- s1 = W512[(j + 14) & 0x0f]; \
- s1 = sigma1_512(s1); \
- T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
- (W512[j & 0x0f] += s1 + W512[(j + 9) & 0x0f] + s0); \
- (d) += T1; \
- (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
- j++
+ #define ROUND512(a, b, c, d, e, f, g, h) \
+ s0 = W512[(j + 1) & 0x0f]; \
+ s0 = sigma0_512(s0); \
+ s1 = W512[(j + 14) & 0x0f]; \
+ s1 = sigma1_512(s1); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
+ (W512[j & 0x0f] += s1 + W512[(j + 9) & 0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
void sha512_Transform(SHA512_CTX* context, const sha2_word64* data)
{
@@ -659,15 +659,15 @@ void sha512_Transform(SHA512_CTX* context, const sha2_word64* data)
j = 0;
do {
-#if BYTE_ORDER == LITTLE_ENDIAN
+ #if BYTE_ORDER == LITTLE_ENDIAN
/* Convert TO host byte order */
REVERSE64(*data++, W512[j]);
/* Apply the SHA-512 compression function to update a..h */
T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j];
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ #else /* BYTE_ORDER == LITTLE_ENDIAN */
/* Apply the SHA-512 compression function to update a..h with copy */
T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
-#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ #endif /* BYTE_ORDER == LITTLE_ENDIAN */
T2 = Sigma0_512(a) + Maj(a, b, c);
h = g;
g = f;
diff --git a/test/unit-test/u2f/u2f_util_t.c b/test/unit-test/u2f/u2f_util_t.c
index a5d85378..83c2d9df 100644
--- a/test/unit-test/u2f/u2f_util_t.c
+++ b/test/unit-test/u2f/u2f_util_t.c
@@ -48,10 +48,10 @@ static void util_uint8_to_hex(const uint8_t* in_bin, const size_t in_len, char*
}
#ifdef __APPLE__
-#ifndef CLOCK_MONOTONIC
-// Implement something compatible w/ linux clock_gettime()
-#include <mach/mach_time.h>
-#define CLOCK_MONOTONIC 0
+ #ifndef CLOCK_MONOTONIC
+ // Implement something compatible w/ linux clock_gettime()
+ #include <mach/mach_time.h>
+ #define CLOCK_MONOTONIC 0
static void clock_gettime(int which, struct timespec* ts)
{
static mach_timebase_info_data_t __clock_gettime_inf;
@@ -66,7 +66,7 @@ static void clock_gettime(int which, struct timespec* ts)
ts->tv_sec = nano * 1e-9;
ts->tv_nsec = nano - (ts->tv_sec * 1e9);
}
-#endif
+ #endif
#endif // __APPLE__
float U2Fob_deltaTime(uint64_t* state)
diff --git a/test/unit-test/u2f/u2f_util_t.h b/test/unit-test/u2f/u2f_util_t.h
index 6d37c6a4..26187bf5 100644
--- a/test/unit-test/u2f/u2f_util_t.h
+++ b/test/unit-test/u2f/u2f_util_t.h
@@ -20,7 +20,7 @@
#include "usb/usb_frame.h"
#ifndef CONTINUOUS_INTEGRATION
-#include <hidapi.h>
+ #include <hidapi.h>
#else
typedef void hid_device;
#endif
diff --git a/test/unit-test/u2f/uECC.c b/test/unit-test/u2f/uECC.c
index b4a988df..ace3c1a0 100644
--- a/test/unit-test/u2f/uECC.c
+++ b/test/unit-test/u2f/uECC.c
@@ -5,13 +5,13 @@
#include <string.h>
#ifndef uECC_RNG_MAX_TRIES
-#define uECC_RNG_MAX_TRIES 64
+ #define uECC_RNG_MAX_TRIES 64
#endif
#if uECC_ENABLE_VLI_API
-#define uECC_VLI_API
+ #define uECC_VLI_API
#else
-#define uECC_VLI_API static
+ #define uECC_VLI_API static
#endif
#define CONCATX(a, ...) a##__VA_ARGS__
@@ -85,53 +85,53 @@
#include "platform-specific.inc"
#if (uECC_WORD_SIZE == 1)
-#if uECC_SUPPORTS_secp160r1
-#define uECC_MAX_WORDS 21 /* Due to the size of curve_n. */
-#endif
-#if uECC_SUPPORTS_secp192r1
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 24
-#endif
-#if uECC_SUPPORTS_secp224r1
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 28
-#endif
-#if (uECC_SUPPORTS_secp256r1 || uECC_SUPPORTS_secp256k1)
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 32
-#endif
+ #if uECC_SUPPORTS_secp160r1
+ #define uECC_MAX_WORDS 21 /* Due to the size of curve_n. */
+ #endif
+ #if uECC_SUPPORTS_secp192r1
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 24
+ #endif
+ #if uECC_SUPPORTS_secp224r1
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 28
+ #endif
+ #if (uECC_SUPPORTS_secp256r1 || uECC_SUPPORTS_secp256k1)
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 32
+ #endif
#elif (uECC_WORD_SIZE == 4)
-#if uECC_SUPPORTS_secp160r1
-#define uECC_MAX_WORDS 6 /* Due to the size of curve_n. */
-#endif
-#if uECC_SUPPORTS_secp192r1
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 6
-#endif
-#if uECC_SUPPORTS_secp224r1
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 7
-#endif
-#if (uECC_SUPPORTS_secp256r1 || uECC_SUPPORTS_secp256k1)
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 8
-#endif
+ #if uECC_SUPPORTS_secp160r1
+ #define uECC_MAX_WORDS 6 /* Due to the size of curve_n. */
+ #endif
+ #if uECC_SUPPORTS_secp192r1
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 6
+ #endif
+ #if uECC_SUPPORTS_secp224r1
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 7
+ #endif
+ #if (uECC_SUPPORTS_secp256r1 || uECC_SUPPORTS_secp256k1)
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 8
+ #endif
#elif (uECC_WORD_SIZE == 8)
-#if uECC_SUPPORTS_secp160r1
-#define uECC_MAX_WORDS 3
-#endif
-#if uECC_SUPPORTS_secp192r1
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 3
-#endif
-#if uECC_SUPPORTS_secp224r1
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 4
-#endif
-#if (uECC_SUPPORTS_secp256r1 || uECC_SUPPORTS_secp256k1)
-#undef uECC_MAX_WORDS
-#define uECC_MAX_WORDS 4
-#endif
+ #if uECC_SUPPORTS_secp160r1
+ #define uECC_MAX_WORDS 3
+ #endif
+ #if uECC_SUPPORTS_secp192r1
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 3
+ #endif
+ #if uECC_SUPPORTS_secp224r1
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 4
+ #endif
+ #if (uECC_SUPPORTS_secp256r1 || uECC_SUPPORTS_secp256k1)
+ #undef uECC_MAX_WORDS
+ #define uECC_MAX_WORDS 4
+ #endif
#endif /* uECC_WORD_SIZE */
#define BITS_TO_WORDS(num_bits) ((num_bits + ((uECC_WORD_SIZE * 8) - 1)) / (uECC_WORD_SIZE * 8))
@@ -174,11 +174,11 @@ static cmpresult_t uECC_vli_cmp_unsafe(
#if ( \
uECC_PLATFORM == uECC_arm || uECC_PLATFORM == uECC_arm_thumb || \
uECC_PLATFORM == uECC_arm_thumb2)
-#include "asm_arm.inc"
+ #include "asm_arm.inc"
#endif
#if (uECC_PLATFORM == uECC_avr)
-#include "asm_avr.inc"
+ #include "asm_avr.inc"
#endif
#if defined(default_RNG_defined) && default_RNG_defined
@@ -388,7 +388,7 @@ uECC_VLI_API uECC_word_t uECC_vli_sub(
((uECC_WORD_SIZE == 1) || (uECC_WORD_SIZE == 8)))
static void muladd(uECC_word_t a, uECC_word_t b, uECC_word_t* r0, uECC_word_t* r1, uECC_word_t* r2)
{
-#if uECC_WORD_SIZE == 8 && !SUPPORTS_INT128
+ #if uECC_WORD_SIZE == 8 && !SUPPORTS_INT128
uint64_t a0 = a & 0xffffffffull;
uint64_t a1 = a >> 32;
uint64_t b0 = b & 0xffffffffull;
@@ -413,14 +413,14 @@ static void muladd(uECC_word_t a, uECC_word_t b, uECC_word_t* r0, uECC_word_t* r
*r0 += p0;
*r1 += (p1 + (*r0 < p0));
*r2 += ((*r1 < p1) || (*r1 == p1 && *r0 < p0));
-#else
+ #else
uECC_dword_t p = (uECC_dword_t)a * b;
uECC_dword_t r01 = ((uECC_dword_t)(*r1) << uECC_WORD_BITS) | *r0;
r01 += p;
*r2 += (r01 < p);
*r1 = r01 >> uECC_WORD_BITS;
*r0 = (uECC_word_t)r01;
-#endif
+ #endif
}
#endif /* muladd needed */
@@ -461,10 +461,10 @@ uECC_VLI_API void uECC_vli_mult(
#if uECC_SQUARE_FUNC
-#if !defined(asm_square) || !asm_square
+ #if !defined(asm_square) || !asm_square
static void mul2add(uECC_word_t a, uECC_word_t b, uECC_word_t* r0, uECC_word_t* r1, uECC_word_t* r2)
{
-#if uECC_WORD_SIZE == 8 && !SUPPORTS_INT128
+ #if uECC_WORD_SIZE == 8 && !SUPPORTS_INT128
uint64_t a0 = a & 0xffffffffull;
uint64_t a1 = a >> 32;
uint64_t b0 = b & 0xffffffffull;
@@ -494,7 +494,7 @@ static void mul2add(uECC_word_t a, uECC_word_t b, uECC_word_t* r0, uECC_word_t*
*r0 += p0;
*r1 += (p1 + (*r0 < p0));
*r2 += ((*r1 < p1) || (*r1 == p1 && *r0 < p0));
-#else
+ #else
uECC_dword_t p = (uECC_dword_t)a * b;
uECC_dword_t r01 = ((uECC_dword_t)(*r1) << uECC_WORD_BITS) | *r0;
*r2 += (p >> (uECC_WORD_BITS * 2 - 1));
@@ -503,7 +503,7 @@ static void mul2add(uECC_word_t a, uECC_word_t b, uECC_word_t* r0, uECC_word_t*
*r2 += (r01 < p);
*r1 = r01 >> uECC_WORD_BITS;
*r0 = (uECC_word_t)r01;
-#endif
+ #endif
}
uECC_VLI_API void uECC_vli_square(
@@ -534,11 +534,11 @@ uECC_VLI_API void uECC_vli_square(
result[num_words * 2 - 1] = r0;
}
-#endif /* !asm_square */
+ #endif /* !asm_square */
#else /* uECC_SQUARE_FUNC */
-#if uECC_ENABLE_VLI_API
+ #if uECC_ENABLE_VLI_API
uECC_VLI_API void uECC_vli_square(
uECC_word_t* result,
const uECC_word_t* left,
@@ -546,7 +546,7 @@ uECC_VLI_API void uECC_vli_square(
{
uECC_vli_mult(result, left, left, num_words);
}
-#endif /* uECC_ENABLE_VLI_API */
+ #endif /* uECC_ENABLE_VLI_API */
#endif /* uECC_SQUARE_FUNC */
@@ -659,7 +659,7 @@ uECC_VLI_API void uECC_vli_modMult_fast(
#if uECC_SQUARE_FUNC
-#if uECC_ENABLE_VLI_API
+ #if uECC_ENABLE_VLI_API
/* Computes result = left^2 % mod. */
uECC_VLI_API void uECC_vli_modSquare(
uECC_word_t* result,
@@ -671,7 +671,7 @@ uECC_VLI_API void uECC_vli_modSquare(
uECC_vli_square(product, left, num_words);
uECC_vli_mmod(result, product, mod, num_words);
}
-#endif /* uECC_ENABLE_VLI_API */
+ #endif /* uECC_ENABLE_VLI_API */
uECC_VLI_API void uECC_vli_modSquare_fast(
uECC_word_t* result,
@@ -680,16 +680,16 @@ uECC_VLI_API void uECC_vli_modSquare_fast(
{
uECC_word_t product[2 * uECC_MAX_WORDS];
uECC_vli_square(product, left, curve->num_words);
-#if (uECC_OPTIMIZATION_LEVEL > 0)
+ #if (uECC_OPTIMIZATION_LEVEL > 0)
curve->mmod_fast(result, product);
-#else
+ #else
uECC_vli_mmod(result, product, curve->p, curve->num_words);
-#endif
+ #endif
}
#else /* uECC_SQUARE_FUNC */
-#if uECC_ENABLE_VLI_API
+ #if uECC_ENABLE_VLI_API
uECC_VLI_API void uECC_vli_modSquare(
uECC_word_t* result,
const uECC_word_t* left,
@@ -698,7 +698,7 @@ uECC_VLI_API void uECC_vli_modSquare(
{
uECC_vli_modMult(result, left, left, mod, num_words);
}
-#endif /* uECC_ENABLE_VLI_API */
+ #endif /* uECC_ENABLE_VLI_API */
uECC_VLI_API void uECC_vli_modSquare_fast(
uECC_word_t* result,
@@ -1129,26 +1129,26 @@ void uECC_compress(const uint8_t* public_key, uint8_t* compressed, uECC_Curve cu
for (i = 0; i < curve->num_bytes; ++i) {
compressed[i + 1] = public_key[i];
}
-#if uECC_VLI_NATIVE_LITTLE_ENDIAN
+ #if uECC_VLI_NATIVE_LITTLE_ENDIAN
compressed[0] = 2 + (public_key[curve->num_bytes] & 0x01);
-#else
+ #else
compressed[0] = 2 + (public_key[curve->num_bytes * 2 - 1] & 0x01);
-#endif
+ #endif
}
void uECC_decompress(const uint8_t* compressed, uint8_t* public_key, uECC_Curve curve)
{
-#if uECC_VLI_NATIVE_LITTLE_ENDIAN
+ #if uECC_VLI_NATIVE_LITTLE_ENDIAN
uECC_word_t* point = (uECC_word_t*)public_key;
-#else
+ #else
uECC_word_t point[uECC_MAX_WORDS * 2];
-#endif
+ #endif
uECC_word_t* y = point + curve->num_words;
-#if uECC_VLI_NATIVE_LITTLE_ENDIAN
+ #if uECC_VLI_NATIVE_LITTLE_ENDIAN
bcopy(public_key, compressed + 1, curve->num_bytes);
-#else
+ #else
uECC_vli_bytesToNative(point, compressed + 1, curve->num_bytes);
-#endif
+ #endif
curve->x_side(y, point, curve);
curve->mod_sqrt(y, curve);
@@ -1156,10 +1156,10 @@ void uECC_decompress(const uint8_t* compressed, uint8_t* public_key, uECC_Curve
uECC_vli_sub(y, curve->p, y, curve->num_words);
}
-#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0
+ #if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0
uECC_vli_nativeToBytes(public_key, curve->num_bytes, point);
uECC_vli_nativeToBytes(public_key + curve->num_bytes, curve->num_bytes, y);
-#endif
+ #endif
}
#endif /* uECC_SUPPORT_COMPRESSED_POINT */
@@ -1724,20 +1724,20 @@ const uECC_word_t* uECC_curve_b(uECC_Curve curve)
return curve->b;
}
-#if uECC_SUPPORT_COMPRESSED_POINT
+ #if uECC_SUPPORT_COMPRESSED_POINT
void uECC_vli_mod_sqrt(uECC_word_t* a, uECC_Curve curve)
{
curve->mod_sqrt(a, curve);
}
-#endif
+ #endif
void uECC_vli_mmod_fast(uECC_word_t* result, uECC_word_t* product, uECC_Curve curve)
{
-#if (uECC_OPTIMIZATION_LEVEL > 0)
+ #if (uECC_OPTIMIZATION_LEVEL > 0)
curve->mmod_fast(result, product);
-#else
+ #else
uECC_vli_mmod(result, product, curve->p, curve->num_words);
-#endif
+ #endif
}
void uECC_point_mult(
diff --git a/test/unit-test/u2f/uECC.h b/test/unit-test/u2f/uECC.h
index bef38ede..ba26c193 100644
--- a/test/unit-test/u2f/uECC.h
+++ b/test/unit-test/u2f/uECC.h
@@ -28,14 +28,14 @@ platform. */
Optimization level 4 currently only has an effect ARM platforms where more than one
curve is enabled. */
#ifndef uECC_OPTIMIZATION_LEVEL
-#define uECC_OPTIMIZATION_LEVEL 2
+ #define uECC_OPTIMIZATION_LEVEL 2
#endif
/* uECC_SQUARE_FUNC - If enabled (defined as nonzero), this will cause a specific function to be
used for (scalar) squaring instead of the generic multiplication function. This can make things
faster somewhat faster, but increases the code size. */
#ifndef uECC_SQUARE_FUNC
-#define uECC_SQUARE_FUNC 0
+ #define uECC_SQUARE_FUNC 0
#endif
/* uECC_VLI_NATIVE_LITTLE_ENDIAN - If enabled (defined as nonzero), this will switch to native
@@ -47,32 +47,32 @@ Note that this will *only* work on native little-endian processors and it will t
arrays passed into the public API as word arrays, therefore requiring the provided byte arrays
to be word aligned on architectures that do not support unaligned accesses. */
#ifndef uECC_VLI_NATIVE_LITTLE_ENDIAN
-#define uECC_VLI_NATIVE_LITTLE_ENDIAN 0
+ #define uECC_VLI_NATIVE_LITTLE_ENDIAN 0
#endif
/* Curve support selection. Set to 0 to remove that curve.
If enable another curve, must add `half_n` (half the order n) constant to curve-specific.inc file.
`half_n` is used for normalizing the signature (lower-S) according to bitcoin best practices. */
#ifndef uECC_SUPPORTS_secp160r1
-#define uECC_SUPPORTS_secp160r1 0
+ #define uECC_SUPPORTS_secp160r1 0
#endif
#ifndef uECC_SUPPORTS_secp192r1
-#define uECC_SUPPORTS_secp192r1 0
+ #define uECC_SUPPORTS_secp192r1 0
#endif
#ifndef uECC_SUPPORTS_secp224r1
-#define uECC_SUPPORTS_secp224r1 0
+ #define uECC_SUPPORTS_secp224r1 0
#endif
#ifndef uECC_SUPPORTS_secp256r1
-#define uECC_SUPPORTS_secp256r1 1
+ #define uECC_SUPPORTS_secp256r1 1
#endif
#ifndef uECC_SUPPORTS_secp256k1
-#define uECC_SUPPORTS_secp256k1 1
+ #define uECC_SUPPORTS_secp256k1 1
#endif
/* Specifies whether compressed point format is supported.
Set to 0 to disable point compression/decompression functions. */
#ifndef uECC_SUPPORT_COMPRESSED_POINT
-#define uECC_SUPPORT_COMPRESSED_POINT 1
+ #define uECC_SUPPORT_COMPRESSED_POINT 1
#endif
struct uECC_Curve_t;
diff --git a/test/unit-test/u2f/uECC_types.h b/test/unit-test/u2f/uECC_types.h
index e8befde1..0137530a 100644
--- a/test/unit-test/u2f/uECC_types.h
+++ b/test/unit-test/u2f/uECC_types.h
@@ -4,63 +4,63 @@
#define _UECC_TYPES_H_
#ifndef uECC_PLATFORM
-#if defined(__AVR__)
-#define uECC_PLATFORM uECC_avr
-#elif defined(__thumb2__) || defined(_M_ARMT) /* I think MSVC only supports Thumb-2 targets */
-#define uECC_PLATFORM uECC_arm_thumb2
-#elif defined(__thumb__)
-#define uECC_PLATFORM uECC_arm_thumb
-#elif defined(__arm__) || defined(_M_ARM)
-#define uECC_PLATFORM uECC_arm
-#elif defined(__aarch64__)
-#define uECC_PLATFORM uECC_arm64
-#elif defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__I86__)
-#define uECC_PLATFORM uECC_x86
-#elif defined(__amd64__) || defined(_M_X64)
-#define uECC_PLATFORM uECC_x86_64
-#else
-#define uECC_PLATFORM uECC_arch_other
-#endif
+ #if defined(__AVR__)
+ #define uECC_PLATFORM uECC_avr
+ #elif defined(__thumb2__) || defined(_M_ARMT) /* I think MSVC only supports Thumb-2 targets */
+ #define uECC_PLATFORM uECC_arm_thumb2
+ #elif defined(__thumb__)
+ #define uECC_PLATFORM uECC_arm_thumb
+ #elif defined(__arm__) || defined(_M_ARM)
+ #define uECC_PLATFORM uECC_arm
+ #elif defined(__aarch64__)
+ #define uECC_PLATFORM uECC_arm64
+ #elif defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__I86__)
+ #define uECC_PLATFORM uECC_x86
+ #elif defined(__amd64__) || defined(_M_X64)
+ #define uECC_PLATFORM uECC_x86_64
+ #else
+ #define uECC_PLATFORM uECC_arch_other
+ #endif
#endif
#ifndef uECC_ARM_USE_UMAAL
-#if (uECC_PLATFORM == uECC_arm) && (__ARM_ARCH >= 6)
-#define uECC_ARM_USE_UMAAL 1
-#elif (uECC_PLATFORM == uECC_arm_thumb2) && (__ARM_ARCH >= 6) && \
- (!defined(__ARM_ARCH_7M__) || !__ARM_ARCH_7M__)
-#define uECC_ARM_USE_UMAAL 1
-#else
-#define uECC_ARM_USE_UMAAL 0
-#endif
+ #if (uECC_PLATFORM == uECC_arm) && (__ARM_ARCH >= 6)
+ #define uECC_ARM_USE_UMAAL 1
+ #elif (uECC_PLATFORM == uECC_arm_thumb2) && (__ARM_ARCH >= 6) && \
+ (!defined(__ARM_ARCH_7M__) || !__ARM_ARCH_7M__)
+ #define uECC_ARM_USE_UMAAL 1
+ #else
+ #define uECC_ARM_USE_UMAAL 0
+ #endif
#endif
#ifndef uECC_WORD_SIZE
-#if uECC_PLATFORM == uECC_avr
-#define uECC_WORD_SIZE 1
-#elif (uECC_PLATFORM == uECC_x86_64 || uECC_PLATFORM == uECC_arm64)
-#define uECC_WORD_SIZE 8
-#else
-#define uECC_WORD_SIZE 4
-#endif
+ #if uECC_PLATFORM == uECC_avr
+ #define uECC_WORD_SIZE 1
+ #elif (uECC_PLATFORM == uECC_x86_64 || uECC_PLATFORM == uECC_arm64)
+ #define uECC_WORD_SIZE 8
+ #else
+ #define uECC_WORD_SIZE 4
+ #endif
#endif
#if (uECC_WORD_SIZE != 1) && (uECC_WORD_SIZE != 4) && (uECC_WORD_SIZE != 8)
-#error "Unsupported value for uECC_WORD_SIZE"
+ #error "Unsupported value for uECC_WORD_SIZE"
#endif
#if ((uECC_PLATFORM == uECC_avr) && (uECC_WORD_SIZE != 1))
-#pragma message("uECC_WORD_SIZE must be 1 for AVR")
-#undef uECC_WORD_SIZE
-#define uECC_WORD_SIZE 1
+ #pragma message("uECC_WORD_SIZE must be 1 for AVR")
+ #undef uECC_WORD_SIZE
+ #define uECC_WORD_SIZE 1
#endif
#if ( \
(uECC_PLATFORM == uECC_arm || uECC_PLATFORM == uECC_arm_thumb || \
uECC_PLATFORM == uECC_arm_thumb2) && \
(uECC_WORD_SIZE != 4))
-#pragma message("uECC_WORD_SIZE must be 4 for ARM")
-#undef uECC_WORD_SIZE
-#define uECC_WORD_SIZE 4
+ #pragma message("uECC_WORD_SIZE must be 4 for ARM")
+ #undef uECC_WORD_SIZE
+ #define uECC_WORD_SIZE 4
#endif
#define SUPPORTS_INT128 0
@@ -74,32 +74,32 @@ typedef int8_t cmpresult_t;
typedef uint8_t uECC_word_t;
typedef uint16_t uECC_dword_t;
-#define HIGH_BIT_SET 0x80
-#define uECC_WORD_BITS 8
-#define uECC_WORD_BITS_SHIFT 3
-#define uECC_WORD_BITS_MASK 0x07
+ #define HIGH_BIT_SET 0x80
+ #define uECC_WORD_BITS 8
+ #define uECC_WORD_BITS_SHIFT 3
+ #define uECC_WORD_BITS_MASK 0x07
#elif (uECC_WORD_SIZE == 4)
typedef uint32_t uECC_word_t;
typedef uint64_t uECC_dword_t;
-#define HIGH_BIT_SET 0x80000000
-#define uECC_WORD_BITS 32
-#define uECC_WORD_BITS_SHIFT 5
-#define uECC_WORD_BITS_MASK 0x01F
+ #define HIGH_BIT_SET 0x80000000
+ #define uECC_WORD_BITS 32
+ #define uECC_WORD_BITS_SHIFT 5
+ #define uECC_WORD_BITS_MASK 0x01F
#elif (uECC_WORD_SIZE == 8)
typedef uint64_t uECC_word_t;
-#if SUPPORTS_INT128
+ #if SUPPORTS_INT128
typedef unsigned __int128 uECC_dword_t;
-#endif
+ #endif
-#define HIGH_BIT_SET 0x8000000000000000ull
-#define uECC_WORD_BITS 64
-#define uECC_WORD_BITS_SHIFT 6
-#define uECC_WORD_BITS_MASK 0x03F
+ #define HIGH_BIT_SET 0x8000000000000000ull
+ #define uECC_WORD_BITS 64
+ #define uECC_WORD_BITS_SHIFT 6
+ #define uECC_WORD_BITS_MASK 0x03F
#endif /* uECC_WORD_SIZE */
diff --git a/test/unit-test/u2f/uECC_vli.h b/test/unit-test/u2f/uECC_vli.h
index f3631830..dca03d70 100644
--- a/test/unit-test/u2f/uECC_vli.h
+++ b/test/unit-test/u2f/uECC_vli.h
@@ -9,7 +9,7 @@
/* Functions for raw large-integer manipulation. These are only available
if uECC.c is compiled with uECC_ENABLE_VLI_API defined to 1. */
#ifndef uECC_ENABLE_VLI_API
-#define uECC_ENABLE_VLI_API 0
+ #define uECC_ENABLE_VLI_API 0
#endif
#ifdef __cplusplus
@@ -135,10 +135,10 @@ void uECC_vli_modInv(
const uECC_word_t* mod,
wordcount_t num_words);
-#if uECC_SUPPORT_COMPRESSED_POINT
+ #if uECC_SUPPORT_COMPRESSED_POINT
/* Calculates a = sqrt(a) (mod curve->p) */
void uECC_vli_mod_sqrt(uECC_word_t* a, uECC_Curve curve);
-#endif
+ #endif
/* Converts an integer in uECC native format to big-endian bytes. */
void uECC_vli_nativeToBytes(uint8_t* bytes, int num_bytes, const uECC_word_t* native);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.