summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2018-08-02 16:21:17 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-03 01:31:21 -0700
commit9ad8a41b8cedef9ac1f0513992ce6958eb86c257 (patch)
tree2a1fe0e028829dc579840dce386047ce661ac6d3
parentc239374ac3e1af342c10f4f3244bc98d76c2413a (diff)
downloadvboot-9ad8a41b8cedef9ac1f0513992ce6958eb86c257.tar.gz
vboot: bulk fix tabs and spacing inconsistency
Problem files were found with: find . -name '*.c' -o -name '*.h' | xargs grep '^ [^*]' and edited manually. Ignores utility/ and cgpt/, since they seem to globally adhere to a two-space tab convention. BUG=None TEST=make clean runtests TEST=emerge vboot_reference depthcharge Change-Id: I5a678484a119c8f1911f717e1968bdb4f1a0810f Reviewed-on: https://chromium-review.googlesource.com/1160131 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--bdb/bdb_struct.h2
-rw-r--r--bdb/rsa.c12
-rw-r--r--firmware/2lib/2rsa.c12
-rw-r--r--firmware/2lib/2sha512.c4
-rw-r--r--firmware/2lib/include/2api.h2
-rw-r--r--firmware/2lib/include/2nvstorage.h4
-rw-r--r--firmware/2lib/include/2nvstorage_fields.h2
-rw-r--r--firmware/2lib/include/2return_codes.h36
-rw-r--r--firmware/bdb/bdb_struct.h2
-rw-r--r--firmware/bdb/rsa.c14
-rw-r--r--firmware/include/bmpblk_header.h2
-rw-r--r--firmware/include/tlcl.h28
-rw-r--r--firmware/include/tpm1_tss_constants.h70
-rw-r--r--firmware/include/vboot_api.h12
-rw-r--r--firmware/lib/ec_sync.c2
-rw-r--r--firmware/lib/include/utility.h8
-rw-r--r--firmware/lib/include/vboot_common.h2
-rw-r--r--firmware/lib/tpm2_lite/marshaling.c8
-rw-r--r--firmware/lib/tpm2_lite/tlcl.c14
-rw-r--r--firmware/lib/tpm_lite/include/tlcl_internal.h40
-rw-r--r--firmware/lib/tpm_lite/include/tlcl_structures.h108
-rw-r--r--firmware/lib/tpm_lite/include/tpm_error_messages.h8
-rw-r--r--firmware/lib/tpm_lite/mocked_tlcl.c12
-rw-r--r--firmware/lib/tpm_lite/tlcl.c18
-rw-r--r--firmware/lib/vboot_api_kernel.c4
-rw-r--r--firmware/lib/vboot_common.c10
-rw-r--r--firmware/lib/vboot_display.c4
-rw-r--r--firmware/lib/vboot_ui.c4
-rw-r--r--firmware/stub/tpm_lite_stub.c14
-rw-r--r--firmware/stub/vboot_api_stub.c2
-rw-r--r--firmware/stub/vboot_api_stub_disk.c8
-rw-r--r--futility/cmd_sign.c26
-rw-r--r--host/arch/x86/lib/crossystem_arch.c10
-rw-r--r--host/include/cgpt_params.h2
-rw-r--r--host/include/crossystem.h2
-rw-r--r--host/include/vboot_host.h2
-rw-r--r--host/lib/crossystem.c39
-rw-r--r--host/lib/host_keyblock.c8
-rw-r--r--host/lib/include/host_misc.h4
-rw-r--r--host/lib/include/signature_digest.h4
-rw-r--r--host/lib/signature_digest.c4
-rw-r--r--tests/cgptlib_test.c2
-rw-r--r--tests/cgptlib_test.h22
-rw-r--r--tests/crc32_test.c62
-rw-r--r--tests/sha_test_vectors.h134
-rw-r--r--tests/sha_tests.c143
-rw-r--r--tests/test_common.c227
-rw-r--r--tests/timer_utils.c18
-rw-r--r--tests/timer_utils.h4
-rw-r--r--tests/tlcl_tests.c2
-rw-r--r--tests/tpm_lite/lock.c14
-rw-r--r--tests/tpm_lite/readonly.c134
-rw-r--r--tests/tpm_lite/startup.c36
-rw-r--r--tests/tpm_lite/tlcl_tests.c24
-rw-r--r--tests/tpm_lite/tlcl_tests.h16
-rw-r--r--tests/tpm_lite/tpmtest_earlyextend.c16
-rw-r--r--tests/tpm_lite/tpmtest_earlynvram.c16
-rw-r--r--tests/tpm_lite/tpmtest_earlynvram2.c16
-rw-r--r--tests/tpm_lite/tpmtest_enable.c32
-rw-r--r--tests/tpm_lite/tpmtest_fastenable.c42
-rw-r--r--tests/tpm_lite/tpmtest_globallock.c72
-rw-r--r--tests/tpm_lite/tpmtest_redefine_unowned.c68
-rw-r--r--tests/tpm_lite/tpmtest_spaceperm.c22
-rw-r--r--tests/tpm_lite/tpmtest_testsetup.c54
-rw-r--r--tests/tpm_lite/tpmtest_timing.c82
-rw-r--r--tests/tpm_lite/tpmtest_writelimit.c74
-rw-r--r--tests/utility_string_tests.c170
-rw-r--r--tests/vb21_host_key_tests.c2
-rw-r--r--tests/vboot_api_devmode_tests.c30
-rw-r--r--tests/vboot_api_kernel2_tests.c6
-rw-r--r--tests/vboot_api_kernel_tests.c4
-rw-r--r--tests/vboot_detach_menu_tests.c2
-rw-r--r--tests/vboot_kernel_tests.c20
73 files changed, 1081 insertions, 1054 deletions
diff --git a/bdb/bdb_struct.h b/bdb/bdb_struct.h
index f8d2b321..b4ffb50d 100644
--- a/bdb/bdb_struct.h
+++ b/bdb/bdb_struct.h
@@ -126,7 +126,7 @@ struct bdb_key {
/* Key version */
uint32_t key_version;
- /* Description; null-terminated ASCII */
+ /* Description; null-terminated ASCII */
char description[128];
/*
diff --git a/bdb/rsa.c b/bdb/rsa.c
index 932c9733..134bd512 100644
--- a/bdb/rsa.c
+++ b/bdb/rsa.c
@@ -50,9 +50,9 @@ int vb2_mont_ge(const struct public_key *key, uint32_t *a)
* Montgomery c[] += a * b[] / R % mod
*/
static void montMulAdd(const struct public_key *key,
- uint32_t *c,
- const uint32_t a,
- const uint32_t *b)
+ uint32_t *c,
+ const uint32_t a,
+ const uint32_t *b)
{
uint64_t A = (uint64_t)a * b[0] + c[0];
uint32_t d0 = (uint32_t)A * key->n0inv;
@@ -78,9 +78,9 @@ static void montMulAdd(const struct public_key *key,
* Montgomery c[] = a[] * b[] / R % mod
*/
static void montMul(const struct public_key *key,
- uint32_t *c,
- const uint32_t *a,
- const uint32_t *b)
+ uint32_t *c,
+ const uint32_t *a,
+ const uint32_t *b)
{
uint32_t i;
for (i = 0; i < key->arrsize; ++i) {
diff --git a/firmware/2lib/2rsa.c b/firmware/2lib/2rsa.c
index c349d4e2..f54e83c3 100644
--- a/firmware/2lib/2rsa.c
+++ b/firmware/2lib/2rsa.c
@@ -48,9 +48,9 @@ int vb2_mont_ge(const struct vb2_public_key *key, uint32_t *a)
* Montgomery c[] += a * b[] / R % mod
*/
static void montMulAdd(const struct vb2_public_key *key,
- uint32_t *c,
- const uint32_t a,
- const uint32_t *b)
+ uint32_t *c,
+ const uint32_t a,
+ const uint32_t *b)
{
uint64_t A = (uint64_t)a * b[0] + c[0];
uint32_t d0 = (uint32_t)A * key->n0inv;
@@ -95,9 +95,9 @@ static void montMulAdd0(const struct vb2_public_key *key,
* Montgomery c[] = a[] * b[] / R % mod
*/
static void montMul(const struct vb2_public_key *key,
- uint32_t *c,
- const uint32_t *a,
- const uint32_t *b)
+ uint32_t *c,
+ const uint32_t *a,
+ const uint32_t *b)
{
uint32_t i;
for (i = 0; i < key->arrsize; ++i) {
diff --git a/firmware/2lib/2sha512.c b/firmware/2lib/2sha512.c
index fedc8b7a..e1f2601f 100644
--- a/firmware/2lib/2sha512.c
+++ b/firmware/2lib/2sha512.c
@@ -170,8 +170,8 @@ void vb2_sha512_init(struct vb2_sha512_context *ctx)
}
static void vb2_sha512_transform(struct vb2_sha512_context *ctx,
- const uint8_t *message,
- unsigned int block_nb)
+ const uint8_t *message,
+ unsigned int block_nb)
{
/* Note that these arrays use 88*8=704 bytes of stack */
uint64_t w[80];
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index f338fa41..1a75b355 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -227,7 +227,7 @@ struct vb2_context {
/**********************************************************************
* Fields caller may examine after calling vb2api_fw_phase1(). Caller
- * must set these fields to 0 before calling any vboot functions.
+ * must set these fields to 0 before calling any vboot functions.
*/
/*
diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h
index f4f3e04c..05183d52 100644
--- a/firmware/2lib/include/2nvstorage.h
+++ b/firmware/2lib/include/2nvstorage.h
@@ -103,8 +103,8 @@ enum vb2_nv_param {
* (0=no, 1=yes).
*/
VB2_NV_TRY_RO_SYNC,
- /* Cut off battery and shutdown on next boot. */
- VB2_NV_BATTERY_CUTOFF_REQUEST,
+ /* Cut off battery and shutdown on next boot. */
+ VB2_NV_BATTERY_CUTOFF_REQUEST,
/* Maximum kernel version to roll forward to */
VB2_NV_KERNEL_MAX_ROLLFORWARD,
diff --git a/firmware/2lib/include/2nvstorage_fields.h b/firmware/2lib/include/2nvstorage_fields.h
index 16626b8d..981bbda4 100644
--- a/firmware/2lib/include/2nvstorage_fields.h
+++ b/firmware/2lib/include/2nvstorage_fields.h
@@ -52,7 +52,7 @@ enum vb2_nv_offset {
/* CRC must be last field */
VB2_NV_OFFS_CRC_V2 = 63,
- };
+};
/* Fields in VB2_NV_OFFS_HEADER (unused = 0x04) */
#define VB2_NV_HEADER_WIPEOUT 0x08
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index f754cded..b60c41a2 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -28,7 +28,7 @@ enum vb2_return_code {
/* Mock error for testing */
VB2_ERROR_MOCK,
- /**********************************************************************
+ /**********************************************************************
* SHA errors
*/
VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000,
@@ -45,7 +45,7 @@ enum vb2_return_code {
/* Digest size buffer too small in vb2_digest_finalize() */
VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE,
- /**********************************************************************
+ /**********************************************************************
* RSA errors
*/
VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000,
@@ -74,7 +74,7 @@ enum vb2_return_code {
/* Bad size calculation in vb2_check_padding() */
VB2_ERROR_RSA_PADDING_SIZE,
- /**********************************************************************
+ /**********************************************************************
* NV storage errors
*/
VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000,
@@ -85,7 +85,7 @@ enum vb2_return_code {
/* Bad CRC in vb2_nv_check_crc() */
VB2_ERROR_NV_CRC,
- /**********************************************************************
+ /**********************************************************************
* Secure data storage errors
*/
VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000,
@@ -135,7 +135,7 @@ enum vb2_return_code {
/* Called vb2_secdatak_set() with uninitialized secdatak */
VB2_ERROR_SECDATAK_SET_UNINITIALIZED,
- /**********************************************************************
+ /**********************************************************************
* Common code errors
*/
VB2_ERROR_COMMON = VB2_ERROR_BASE + 0x050000,
@@ -262,7 +262,7 @@ enum vb2_return_code {
/* Null public key buffer passed to vb2_unpack_key_buffer() */
VB2_ERROR_UNPACK_KEY_BUFFER,
- /**********************************************************************
+ /**********************************************************************
* Keyblock verification errors (all in vb2_verify_keyblock())
*/
VB2_ERROR_KEYBLOCK = VB2_ERROR_BASE + 0x060000,
@@ -303,7 +303,7 @@ enum vb2_return_code {
/* No signature matching key ID */
VB2_ERROR_KEYBLOCK_SIG_ID,
- /**********************************************************************
+ /**********************************************************************
* Preamble verification errors (all in vb2_verify_preamble())
*/
VB2_ERROR_PREAMBLE = VB2_ERROR_BASE + 0x070000,
@@ -350,7 +350,7 @@ enum vb2_return_code {
/* Vmlinuz header outside signed portion of body */
VB2_ERROR_PREAMBLE_VMLINUZ_HEADER_OUTSIDE,
- /**********************************************************************
+ /**********************************************************************
* Misc higher-level code errors
*/
VB2_ERROR_MISC = VB2_ERROR_BASE + 0x080000,
@@ -497,7 +497,7 @@ enum vb2_return_code {
/* Expected and image hashes are different size in ec_sync_phase1() */
VB2_ERROR_EC_HASH_SIZE,
- /**********************************************************************
+ /**********************************************************************
* API-level errors
*/
VB2_ERROR_API = VB2_ERROR_BASE + 0x090000,
@@ -580,7 +580,7 @@ enum vb2_return_code {
/* Digest buffer passed into vb2api_check_hash incorrect. */
VB2_ERROR_API_CHECK_DIGEST_SIZE,
- /**********************************************************************
+ /**********************************************************************
* Errors which may be generated by implementations of vb2ex functions.
* Implementation may also return its own specific errors, which should
* NOT be in the range VB2_ERROR_BASE...VB2_ERROR_MAX to avoid
@@ -607,12 +607,12 @@ enum vb2_return_code {
VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by host library (non-firmware) start here.
*/
VB2_ERROR_HOST_BASE = 0x20000000,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by host library misc functions
*/
VB2_ERROR_HOST_MISC = VB2_ERROR_HOST_BASE + 0x010000,
@@ -638,7 +638,7 @@ enum vb2_return_code {
/* Unable to convert string to struct vb_id */
VB2_ERROR_STR_TO_ID,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by host library key functions
*/
VB2_ERROR_HOST_KEY = VB2_ERROR_HOST_BASE + 0x020000,
@@ -736,7 +736,7 @@ enum vb2_return_code {
/* Unable to copy packed key */
VB2_ERROR_PACKED_KEY_COPY,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by host library signature functions
*/
VB2_ERROR_HOST_SIG = VB2_ERROR_HOST_BASE + 0x030000,
@@ -777,7 +777,7 @@ enum vb2_return_code {
/* Not enough buffer space to hold signature in vb2_sign_object() */
VB2_SIGN_OBJECT_OVERFLOW,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by host library keyblock functions
*/
VB2_ERROR_HOST_KEYBLOCK = VB2_ERROR_HOST_BASE + 0x040000,
@@ -794,7 +794,7 @@ enum vb2_return_code {
/* Unable to sign keyblock in vb2_create_keyblock() */
VB2_KEYBLOCK_CREATE_SIGN,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by host library firmware preamble functions
*/
VB2_ERROR_HOST_FW_PREAMBLE = VB2_ERROR_HOST_BASE + 0x050000,
@@ -808,7 +808,7 @@ enum vb2_return_code {
/* Unable to sign preamble in vb2_create_fw_preamble() */
VB2_FW_PREAMBLE_CREATE_SIGN,
- /**********************************************************************
+ /**********************************************************************
* Errors generated by unit test functions
*/
VB2_ERROR_UNIT_TEST = VB2_ERROR_HOST_BASE + 0x060000,
@@ -816,7 +816,7 @@ enum vb2_return_code {
/* Unable to open an input file needed for a unit test */
VB2_ERROR_TEST_INPUT_FILE,
- /**********************************************************************
+ /**********************************************************************
* Highest non-zero error generated inside vboot library. Note that
* error codes passed through vboot when it calls external APIs may
* still be outside this range.
diff --git a/firmware/bdb/bdb_struct.h b/firmware/bdb/bdb_struct.h
index fbb0c2e1..b9b4b852 100644
--- a/firmware/bdb/bdb_struct.h
+++ b/firmware/bdb/bdb_struct.h
@@ -126,7 +126,7 @@ struct bdb_key {
/* Key version */
uint32_t key_version;
- /* Description; null-terminated ASCII */
+ /* Description; null-terminated ASCII */
char description[128];
/*
diff --git a/firmware/bdb/rsa.c b/firmware/bdb/rsa.c
index 61757dac..35bfcb47 100644
--- a/firmware/bdb/rsa.c
+++ b/firmware/bdb/rsa.c
@@ -50,9 +50,9 @@ static int mont_ge(const struct public_key *key, uint32_t *a)
* Montgomery c[] += a * b[] / R % mod
*/
static void montMulAdd(const struct public_key *key,
- uint32_t *c,
- const uint32_t a,
- const uint32_t *b)
+ uint32_t *c,
+ const uint32_t a,
+ const uint32_t *b)
{
uint64_t A = (uint64_t)a * b[0] + c[0];
uint32_t d0 = (uint32_t)A * key->n0inv;
@@ -78,9 +78,9 @@ static void montMulAdd(const struct public_key *key,
* Montgomery c[] = a[] * b[] / R % mod
*/
static void montMul(const struct public_key *key,
- uint32_t *c,
- const uint32_t *a,
- const uint32_t *b)
+ uint32_t *c,
+ const uint32_t *a,
+ const uint32_t *b)
{
uint32_t i;
for (i = 0; i < key->arrsize; ++i) {
@@ -133,7 +133,7 @@ static const uint8_t sha256_tail[] = {
};
static int check_padding(const uint8_t *sig, const struct public_key *key,
- uint32_t pad_size)
+ uint32_t pad_size)
{
/* Determine padding to use depending on the signature type */
const uint32_t tail_size = sizeof(sha256_tail);
diff --git a/firmware/include/bmpblk_header.h b/firmware/include/bmpblk_header.h
index bdc118a0..a010f071 100644
--- a/firmware/include/bmpblk_header.h
+++ b/firmware/include/bmpblk_header.h
@@ -112,7 +112,7 @@ typedef struct ImageInfo {
*/
uint32_t compressed_size;
uint32_t reserved;
- /* NOTE: The actual image content (if any) follows immediately. */
+ /* NOTE: The actual image content (if any) follows immediately. */
} __attribute__((packed)) ImageInfo;
/* Constants for ImageInfo.tag */
diff --git a/firmware/include/tlcl.h b/firmware/include/tlcl.h
index 28508c3f..1e1e401d 100644
--- a/firmware/include/tlcl.h
+++ b/firmware/include/tlcl.h
@@ -38,7 +38,7 @@ uint32_t TlclLibClose(void);
* Perform a raw TPM request/response transaction.
*/
uint32_t TlclSendReceive(const uint8_t *request, uint8_t *response,
- int max_length);
+ int max_length);
/**
* Return the size of a TPM request or response packet.
@@ -91,8 +91,8 @@ uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size);
* passed via [auth_policy]. The TPM error code is returned.
*/
uint32_t TlclDefineSpaceEx(const uint8_t* owner_auth, uint32_t owner_auth_size,
- uint32_t index, uint32_t perm, uint32_t size,
- const void* auth_policy, uint32_t auth_policy_size);
+ uint32_t index, uint32_t perm, uint32_t size,
+ const void* auth_policy, uint32_t auth_policy_size);
/**
* Initializes [auth_policy] to require PCR binding of the given
@@ -104,8 +104,8 @@ uint32_t TlclDefineSpaceEx(const uint8_t* owner_auth, uint32_t owner_auth_size,
* return, also for the case of insufficient buffer size.
*/
uint32_t TlclInitNvAuthPolicy(uint32_t pcr_selection_bitmap,
- const uint8_t pcr_values[][TPM_PCR_DIGEST],
- void* auth_policy, uint32_t* auth_policy_size);
+ const uint8_t pcr_values[][TPM_PCR_DIGEST],
+ void* auth_policy, uint32_t* auth_policy_size);
/**
* Write [length] bytes of [data] to space at [index]. The TPM error code is
@@ -194,7 +194,7 @@ uint32_t TlclSetDeactivated(uint8_t flag);
* be NULL. The TPM error code is returned.
*/
uint32_t TlclGetFlags(uint8_t *disable, uint8_t *deactivated,
- uint8_t *nvlocked);
+ uint8_t *nvlocked);
/**
* Set the bGlobalLock flag, which only a reboot can clear. The TPM error
@@ -221,7 +221,7 @@ uint32_t TlclGetPermissions(uint32_t index, uint32_t *permissions);
* sufficient, the return value will be TPM_E_BUFFER_SIZE.
*/
uint32_t TlclGetSpaceInfo(uint32_t index, uint32_t *attributes, uint32_t *size,
- void* auth_policy, uint32_t* auth_policy_size);
+ void* auth_policy, uint32_t* auth_policy_size);
/**
* Get the entire set of permanent flags.
@@ -255,8 +255,8 @@ uint32_t TlclGetRandom(uint8_t *data, uint32_t length, uint32_t *size);
* *vendor_specific_buf_size to the length of the filled data.
*/
uint32_t TlclGetVersion(uint32_t* vendor, uint64_t* firmware_version,
- uint8_t* vendor_specific_buf,
- size_t* vendor_specific_buf_size);
+ uint8_t* vendor_specific_buf,
+ size_t* vendor_specific_buf_size);
/**
* Issues the IFX specific FieldUpgradeInfoRequest2 TPM_FieldUpgrade subcommand
@@ -271,8 +271,8 @@ uint32_t TlclIFXFieldUpgradeInfo(TPM_IFX_FIELDUPGRADEINFO *info);
* Read the public half of the EK.
*/
uint32_t TlclReadPubek(uint32_t* public_exponent,
- uint8_t* modulus,
- uint32_t* modulus_size);
+ uint8_t* modulus,
+ uint32_t* modulus_size);
/**
* Takes ownership of the TPM. [enc_owner_auth] and [enc_srk_auth] are the owner
@@ -280,8 +280,8 @@ uint32_t TlclReadPubek(uint32_t* public_exponent,
* text [owner_auth] needs to be passed as well for command auth.
*/
uint32_t TlclTakeOwnership(uint8_t enc_owner_auth[TPM_RSA_2048_LEN],
- uint8_t enc_srk_auth[TPM_RSA_2048_LEN],
- uint8_t owner_auth[TPM_AUTH_DATA_LEN]);
+ uint8_t enc_srk_auth[TPM_RSA_2048_LEN],
+ uint8_t owner_auth[TPM_AUTH_DATA_LEN]);
/**
* Create a delegation family with the specified [family_label].
@@ -294,7 +294,7 @@ uint32_t TlclCreateDelegationFamily(uint8_t family_label);
* updated to indicate actual number of table entries available.
*/
uint32_t TlclReadDelegationFamilyTable(TPM_FAMILY_TABLE_ENTRY *table,
- uint32_t* table_size);
+ uint32_t* table_size);
#endif /* TPM2_MODE */
#endif /* CHROMEOS_ENVIRONMENT */
diff --git a/firmware/include/tpm1_tss_constants.h b/firmware/include/tpm1_tss_constants.h
index 3deef34e..54642ba6 100644
--- a/firmware/include/tpm1_tss_constants.h
+++ b/firmware/include/tpm1_tss_constants.h
@@ -96,7 +96,7 @@ typedef uint32_t TPM_FAMILY_FLAGS;
#define TPM_LOC_ZERO (((uint32_t)1)<<0)
#define TPM_ALL_LOCALITIES (TPM_LOC_ZERO | TPM_LOC_ONE | TPM_LOC_TWO \
- | TPM_LOC_THREE | TPM_LOC_FOUR) /* 0x1f */
+ | TPM_LOC_THREE | TPM_LOC_FOUR) /* 0x1f */
#define TPM_PHYSICAL_PRESENCE_LOCK ((uint16_t) 0x0004)
#define TPM_PHYSICAL_PRESENCE_PRESENT ((uint16_t) 0x0008)
@@ -116,28 +116,28 @@ typedef uint32_t TPM_FAMILY_FLAGS;
typedef struct tdTPM_DIGEST
{
- uint8_t digest[TPM_SHA1_160_HASH_LEN];
+ uint8_t digest[TPM_SHA1_160_HASH_LEN];
} TPM_DIGEST;
typedef TPM_DIGEST TPM_COMPOSITE_HASH;
typedef struct tdTPM_PCR_SELECTION
{
- uint16_t sizeOfSelect;
- uint8_t pcrSelect[3];
+ uint16_t sizeOfSelect;
+ uint8_t pcrSelect[3];
} __attribute__((packed)) TPM_PCR_SELECTION;
typedef struct tdTPM_NV_ATTRIBUTES
{
- TPM_STRUCTURE_TAG tag;
- TPM_NV_PER_ATTRIBUTES attributes;
+ TPM_STRUCTURE_TAG tag;
+ TPM_NV_PER_ATTRIBUTES attributes;
} __attribute__((packed)) TPM_NV_ATTRIBUTES;
typedef struct tdTPM_PCR_INFO_SHORT
{
- TPM_PCR_SELECTION pcrSelection;
- TPM_LOCALITY_SELECTION localityAtRelease;
- TPM_COMPOSITE_HASH digestAtRelease;
+ TPM_PCR_SELECTION pcrSelection;
+ TPM_LOCALITY_SELECTION localityAtRelease;
+ TPM_COMPOSITE_HASH digestAtRelease;
} __attribute__((packed)) TPM_PCR_INFO_SHORT;
typedef struct tdTPM_PERMANENT_FLAGS
@@ -176,51 +176,51 @@ typedef struct tdTPM_STCLEAR_FLAGS{
typedef struct tdTPM_NV_DATA_PUBLIC
{
- TPM_STRUCTURE_TAG tag;
- TPM_NV_INDEX nvIndex;
- TPM_PCR_INFO_SHORT pcrInfoRead;
- TPM_PCR_INFO_SHORT pcrInfoWrite;
- TPM_NV_ATTRIBUTES permission;
- TPM_BOOL bReadSTClear;
- TPM_BOOL bWriteSTClear;
- TPM_BOOL bWriteDefine;
- uint32_t dataSize;
+ TPM_STRUCTURE_TAG tag;
+ TPM_NV_INDEX nvIndex;
+ TPM_PCR_INFO_SHORT pcrInfoRead;
+ TPM_PCR_INFO_SHORT pcrInfoWrite;
+ TPM_NV_ATTRIBUTES permission;
+ TPM_BOOL bReadSTClear;
+ TPM_BOOL bWriteSTClear;
+ TPM_BOOL bWriteDefine;
+ uint32_t dataSize;
} TPM_NV_DATA_PUBLIC;
typedef struct tdTPM_NONCE
{
- uint8_t nonce[TPM_SHA1BASED_NONCE_LEN];
+ uint8_t nonce[TPM_SHA1BASED_NONCE_LEN];
} TPM_NONCE;
typedef struct tdTPM_FAMILY_TABLE_ENTRY
{
- TPM_STRUCTURE_TAG tag;
- TPM_FAMILY_LABEL familyLabel;
- TPM_FAMILY_ID familyID;
- TPM_FAMILY_VERIFICATION verificationCount;
- TPM_FAMILY_FLAGS flags;
+ TPM_STRUCTURE_TAG tag;
+ TPM_FAMILY_LABEL familyLabel;
+ TPM_FAMILY_ID familyID;
+ TPM_FAMILY_VERIFICATION verificationCount;
+ TPM_FAMILY_FLAGS flags;
} TPM_FAMILY_TABLE_ENTRY;
typedef struct tdTPM_IFX_FIRMWAREPACKAGE {
- uint32_t FwPackageIdentifier;
- uint32_t Version;
- uint32_t StaleVersion;
+ uint32_t FwPackageIdentifier;
+ uint32_t Version;
+ uint32_t StaleVersion;
} TPM_IFX_FIRMWAREPACKAGE;
typedef struct tdTPM_IFX_FIELDUPGRADEINFO
{
- uint16_t wMaxDataSize;
- TPM_IFX_FIRMWAREPACKAGE sBootloaderFirmwarePackage;
- TPM_IFX_FIRMWAREPACKAGE sFirmwarePackages[2];
- uint16_t wSecurityModuleStatus;
- TPM_IFX_FIRMWAREPACKAGE sProcessFirmwarePackage;
- uint16_t wFieldUpgradeCounter;
+ uint16_t wMaxDataSize;
+ TPM_IFX_FIRMWAREPACKAGE sBootloaderFirmwarePackage;
+ TPM_IFX_FIRMWAREPACKAGE sFirmwarePackages[2];
+ uint16_t wSecurityModuleStatus;
+ TPM_IFX_FIRMWAREPACKAGE sProcessFirmwarePackage;
+ uint16_t wFieldUpgradeCounter;
} TPM_IFX_FIELDUPGRADEINFO;
typedef struct tdTPM_NV_AUTH_POLICY
{
- TPM_PCR_INFO_SHORT pcr_info_read;
- TPM_PCR_INFO_SHORT pcr_info_write;
+ TPM_PCR_INFO_SHORT pcr_info_read;
+ TPM_PCR_INFO_SHORT pcr_info_write;
} TPM_NV_AUTH_POLICY;
#define TPM_IFX_FieldUpgradeInfoRequest2 ((uint8_t) 0x11)
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index aa408cd1..73e2706d 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -306,7 +306,7 @@ typedef struct VbSelectAndLoadKernelParams {
* Returns VBERROR_SUCCESS if success, non-zero if error; on error, caller
* should reboot. */
VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
- VbSelectAndLoadKernelParams *kparams);
+ VbSelectAndLoadKernelParams *kparams);
/**
* Verify Kernel Image loaded in memory.
@@ -419,7 +419,7 @@ VbError_t VbExTpmOpen(void);
* exit, response_length is set to the actual received response length in
* bytes. */
VbError_t VbExTpmSendReceive(const uint8_t *request, uint32_t request_length,
- uint8_t *response, uint32_t *response_length);
+ uint8_t *response, uint32_t *response_length);
#ifdef CHROMEOS_ENVIRONMENT
@@ -538,7 +538,7 @@ typedef struct VbDiskInfo {
* VbExDiskFreeInfo() is called.
*/
VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
- uint32_t disk_flags);
+ uint32_t disk_flags);
/**
* Free a disk information list [infos] previously returned by
@@ -547,7 +547,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
* list need not remain valid after this call.
*/
VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
- VbExDiskHandle_t preserve_handle);
+ VbExDiskHandle_t preserve_handle);
/**
* Read lba_count LBA sectors, starting at sector lba_start, from the disk,
@@ -561,7 +561,7 @@ VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
* crash.
*/
VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, void *buffer);
+ uint64_t lba_count, void *buffer);
/**
* Write lba_count LBA sectors, starting at sector lba_start, to the disk, from
@@ -575,7 +575,7 @@ VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
* crash.
*/
VbError_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, const void *buffer);
+ uint64_t lba_count, const void *buffer);
/* Streaming read interface */
typedef void *VbExStream_t;
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c
index 3c70ae15..b72403db 100644
--- a/firmware/lib/ec_sync.c
+++ b/firmware/lib/ec_sync.c
@@ -485,7 +485,7 @@ VbError_t ec_sync_phase3(struct vb2_context *ctx)
return rv;
/* Check if we need to cut-off battery. This must be done after EC
- * firmware updating and before kernel started. */
+ * firmware updating and before kernel started. */
if (vb2_nv_get(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST)) {
VB2_DEBUG("Request to cut-off battery\n");
vb2_nv_set(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST, 0);
diff --git a/firmware/lib/include/utility.h b/firmware/lib/include/utility.h
index 590c60af..ca9bcd7e 100644
--- a/firmware/lib/include/utility.h
+++ b/firmware/lib/include/utility.h
@@ -16,8 +16,8 @@
#ifdef VBOOT_DEBUG
#define VbAssert(expr) do { if (!(expr)) { \
- VbExError("assert fail: %s at %s:%d\n", \
- #expr, __FILE__, __LINE__); }} while(0)
+ VbExError("assert fail: %s at %s:%d\n", \
+ #expr, __FILE__, __LINE__); }} while(0)
#else
#define VbAssert(expr)
#endif
@@ -34,7 +34,7 @@
* forming the most and least signficant 16-bit words.
*/
#define CombineUint16Pair(msw,lsw) (((uint32_t)(msw) << 16) | \
- (((lsw)) & 0xFFFF))
+ (((lsw)) & 0xFFFF))
/* Return the minimum of (a) or (b). */
#define Min(a, b) (((a) < (b)) ? (a) : (b))
@@ -52,7 +52,7 @@
* Returns the length of the stored string, not counting the terminating null.
*/
uint32_t Uint64ToString(char *buf, uint32_t bufsize, uint64_t value,
- uint32_t radix, uint32_t zero_pad_width);
+ uint32_t radix, uint32_t zero_pad_width);
/**
* Concatenate <src> onto <dest>, which has space for <destlen> characters
diff --git a/firmware/lib/include/vboot_common.h b/firmware/lib/include/vboot_common.h
index 44dba262..deaa8d92 100644
--- a/firmware/lib/include/vboot_common.h
+++ b/firmware/lib/include/vboot_common.h
@@ -136,7 +136,7 @@ uint64_t VbSharedDataReserve(VbSharedDataHeader *header, uint64_t size);
* Returns 0 if success, non-zero if error.
*/
int VbSharedDataSetKernelKey(VbSharedDataHeader *header,
- const VbPublicKey *src);
+ const VbPublicKey *src);
/**
* Check whether recovery is allowed or not.
diff --git a/firmware/lib/tpm2_lite/marshaling.c b/firmware/lib/tpm2_lite/marshaling.c
index ab374951..63b83937 100644
--- a/firmware/lib/tpm2_lite/marshaling.c
+++ b/firmware/lib/tpm2_lite/marshaling.c
@@ -268,10 +268,10 @@ static void unmarshal_get_capability(void **buffer, int *size,
* room in the buffer.
*/
- /*
- * Marshaling an arbitrary blob requires its size in addition to common
- * parameter set.
- */
+/*
+ * Marshaling an arbitrary blob requires its size in addition to common
+ * parameter set.
+ */
static void marshal_blob(void **buffer, void *blob,
size_t blob_size, int *buffer_space)
{
diff --git a/firmware/lib/tpm2_lite/tlcl.c b/firmware/lib/tpm2_lite/tlcl.c
index 9c0ab887..a05ef77f 100644
--- a/firmware/lib/tpm2_lite/tlcl.c
+++ b/firmware/lib/tpm2_lite/tlcl.c
@@ -51,7 +51,7 @@ static uint32_t tpm_get_response(TPM_CC command,
res = VbExTpmSendReceive(cr_buffer, out_size, cr_buffer, &in_size);
if (res != TPM_SUCCESS) {
VB2_DEBUG("tpm transaction failed for %#x with error %#x\n",
- command, res);
+ command, res);
return res;
}
@@ -127,7 +127,7 @@ uint32_t TlclLibClose(void)
}
uint32_t TlclSendReceive(const uint8_t *request, uint8_t *response,
- int max_length)
+ int max_length)
{
uint32_t rv, resp_size;
@@ -255,8 +255,8 @@ uint32_t TlclSetEnable(void)
}
uint32_t TlclGetFlags(uint8_t* disable,
- uint8_t* deactivated,
- uint8_t *nvlocked)
+ uint8_t* deactivated,
+ uint8_t *nvlocked)
{
/* For TPM2 the flags are always the same */
if (disable)
@@ -314,7 +314,7 @@ uint32_t TlclGetPermissions(uint32_t index, uint32_t *permissions)
}
uint32_t TlclGetSpaceInfo(uint32_t index, uint32_t *attributes, uint32_t *size,
- void* auth_policy, uint32_t* auth_policy_size)
+ void* auth_policy, uint32_t* auth_policy_size)
{
uint32_t rv;
struct nv_read_public_response *resp;
@@ -563,8 +563,8 @@ size_t tlcl_vendor_string_parse(uint32_t value, uint8_t* buf)
}
uint32_t TlclGetVersion(uint32_t* vendor, uint64_t* firmware_version,
- uint8_t* vendor_specific_buf,
- size_t* vendor_specific_buf_size)
+ uint8_t* vendor_specific_buf,
+ size_t* vendor_specific_buf_size)
{
uint32_t result = tlcl_get_tpm_property(TPM_PT_MANUFACTURER, vendor);
if (result != TPM_SUCCESS)
diff --git a/firmware/lib/tpm_lite/include/tlcl_internal.h b/firmware/lib/tpm_lite/include/tlcl_internal.h
index 5db556a8..28eff1d9 100644
--- a/firmware/lib/tpm_lite/include/tlcl_internal.h
+++ b/firmware/lib/tpm_lite/include/tlcl_internal.h
@@ -16,7 +16,7 @@
#define kEncAuthLength 20
#define kPcrDigestLength 20
#define kTpmRequestAuthBlockLength \
- (sizeof(uint32_t) + sizeof(TPM_NONCE) + 1 + TPM_AUTH_DATA_LEN)
+ (sizeof(uint32_t) + sizeof(TPM_NONCE) + 1 + TPM_AUTH_DATA_LEN)
#define kTpmResponseAuthBlockLength (sizeof(TPM_NONCE) + 1 + TPM_AUTH_DATA_LEN)
@@ -28,10 +28,10 @@
*/
__attribute__((unused))
static inline void ToTpmUint32(uint8_t *buffer, uint32_t x) {
- buffer[0] = (uint8_t)(x >> 24);
- buffer[1] = (uint8_t)((x >> 16) & 0xff);
- buffer[2] = (uint8_t)((x >> 8) & 0xff);
- buffer[3] = (uint8_t)(x & 0xff);
+ buffer[0] = (uint8_t)(x >> 24);
+ buffer[1] = (uint8_t)((x >> 16) & 0xff);
+ buffer[2] = (uint8_t)((x >> 8) & 0xff);
+ buffer[3] = (uint8_t)(x & 0xff);
}
/*
@@ -39,10 +39,10 @@ static inline void ToTpmUint32(uint8_t *buffer, uint32_t x) {
*/
__attribute__((unused))
static inline void FromTpmUint32(const uint8_t *buffer, uint32_t *x) {
- *x = ((buffer[0] << 24) |
- (buffer[1] << 16) |
- (buffer[2] << 8) |
- buffer[3]);
+ *x = ((buffer[0] << 24) |
+ (buffer[1] << 16) |
+ (buffer[2] << 8) |
+ buffer[3]);
}
/*
@@ -50,10 +50,10 @@ static inline void FromTpmUint32(const uint8_t *buffer, uint32_t *x) {
*/
__attribute__((unused))
static inline uint32_t ReadTpmUint32(const uint8_t **buffer) {
- uint32_t value;
- FromTpmUint32(*buffer, &value);
- *buffer += sizeof(value);
- return value;
+ uint32_t value;
+ FromTpmUint32(*buffer, &value);
+ *buffer += sizeof(value);
+ return value;
}
/*
@@ -61,8 +61,8 @@ static inline uint32_t ReadTpmUint32(const uint8_t **buffer) {
*/
__attribute__((unused))
static inline void ToTpmUint16(uint8_t *buffer, uint16_t x) {
- buffer[0] = (uint8_t)(x >> 8);
- buffer[1] = (uint8_t)(x & 0xff);
+ buffer[0] = (uint8_t)(x >> 8);
+ buffer[1] = (uint8_t)(x & 0xff);
}
/*
@@ -70,7 +70,7 @@ static inline void ToTpmUint16(uint8_t *buffer, uint16_t x) {
*/
__attribute__((unused))
static inline void FromTpmUint16(const uint8_t *buffer, uint16_t *x) {
- *x = (buffer[0] << 8) | buffer[1];
+ *x = (buffer[0] << 8) | buffer[1];
}
/*
@@ -78,10 +78,10 @@ static inline void FromTpmUint16(const uint8_t *buffer, uint16_t *x) {
*/
__attribute__((unused))
static inline uint16_t ReadTpmUint16(const uint8_t **buffer) {
- uint16_t value;
- FromTpmUint16(*buffer, &value);
- *buffer += sizeof(value);
- return value;
+ uint16_t value;
+ FromTpmUint16(*buffer, &value);
+ *buffer += sizeof(value);
+ return value;
}
#endif /* TPM_LITE_TLCL_INTERNAL_H_ */
diff --git a/firmware/lib/tpm_lite/include/tlcl_structures.h b/firmware/lib/tpm_lite/include/tlcl_structures.h
index 8a17ccc8..7356c439 100644
--- a/firmware/lib/tpm_lite/include/tlcl_structures.h
+++ b/firmware/lib/tpm_lite/include/tlcl_structures.h
@@ -1,180 +1,180 @@
/* This file is automatically generated */
const struct s_tpm_delegate_read_table_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_delegate_read_table_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xdb, },
};
const struct s_tpm_create_delegation_family_cmd{
- uint8_t buffer[23];
- uint16_t familyLabel;
+ uint8_t buffer[23];
+ uint16_t familyLabel;
} tpm_create_delegation_family_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x17, 0x0, 0x0, 0x0, 0xd2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, },
22, };
const struct s_tpm_takeownership_cmd{
- uint8_t buffer[624];
- uint16_t encOwnerAuth;
- uint16_t encSrkAuth;
+ uint8_t buffer[624];
+ uint16_t encOwnerAuth;
+ uint16_t encSrkAuth;
} tpm_takeownership_cmd = {{0x0, 0xc2, 0x0, 0x0, 0x2, 0x70, 0x0, 0x0, 0x0, 0xd, 0x0, 0x5, 0x0, 0x0, 0x1, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x0, 0x1, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x3, 0x0, 0x1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, },
16, 276, };
const struct s_tpm_osap_cmd{
- uint8_t buffer[36];
- uint16_t entityType;
- uint16_t entityValue;
- uint16_t nonceOddOSAP;
+ uint8_t buffer[36];
+ uint16_t entityType;
+ uint16_t entityValue;
+ uint16_t nonceOddOSAP;
} tpm_osap_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0xb, },
10, 12, 16, };
const struct s_tpm_oiap_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_oiap_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, },
};
const struct s_tpm_ifx_fieldupgradeinforequest2_cmd{
- uint8_t buffer[13];
+ uint8_t buffer[13];
} tpm_ifx_fieldupgradeinforequest2_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xd, 0x0, 0x0, 0x0, 0xaa, 0x11, 0x0, 0x0, },
};
const struct s_tpm_getversionval_cmd{
- uint8_t buffer[18];
+ uint8_t buffer[18];
} tpm_getversionval_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x12, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x1a, 0x0, 0x0, 0x0, 0x0, },
};
const struct s_tpm_extend_cmd{
- uint8_t buffer[34];
- uint16_t pcrNum;
- uint16_t inDigest;
+ uint8_t buffer[34];
+ uint16_t pcrNum;
+ uint16_t inDigest;
} tpm_extend_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, },
10, 14, };
const struct s_tpm_get_random_cmd{
- uint8_t buffer[14];
- uint16_t bytesRequested;
+ uint8_t buffer[14];
+ uint16_t bytesRequested;
} tpm_get_random_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x46, },
10, };
const struct s_tpm_getownership_cmd{
- uint8_t buffer[22];
+ uint8_t buffer[22];
} tpm_getownership_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x11, },
};
const struct s_tpm_getspaceinfo_cmd{
- uint8_t buffer[22];
- uint16_t index;
+ uint8_t buffer[22];
+ uint16_t index;
} tpm_getspaceinfo_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x4, },
18, };
const struct s_tpm_getstclearflags_cmd{
- uint8_t buffer[22];
+ uint8_t buffer[22];
} tpm_getstclearflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x9, },
};
const struct s_tpm_getflags_cmd{
- uint8_t buffer[22];
+ uint8_t buffer[22];
} tpm_getflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x8, },
};
const struct s_tpm_physicalsetdeactivated_cmd{
- uint8_t buffer[11];
- uint16_t deactivated;
+ uint8_t buffer[11];
+ uint16_t deactivated;
} tpm_physicalsetdeactivated_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72, },
10, };
const struct s_tpm_physicalenable_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_physicalenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f, },
};
const struct s_tpm_physicaldisable_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_physicaldisable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70, },
};
const struct s_tpm_forceclear_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_forceclear_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d, },
};
const struct s_tpm_readpubek_cmd{
- uint8_t buffer[30];
- uint16_t antiReplay;
+ uint8_t buffer[30];
+ uint16_t antiReplay;
} tpm_readpubek_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c, },
10, };
const struct s_tpm_continueselftest_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_continueselftest_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53, },
};
const struct s_tpm_selftestfull_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_selftestfull_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, },
};
const struct s_tpm_resume_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_resume_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x2, },
};
const struct s_tpm_savestate_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_savestate_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x98, },
};
const struct s_tpm_startup_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_startup_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x1, },
};
const struct s_tpm_finalizepp_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_finalizepp_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0, },
};
const struct s_tpm_pplock_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_pplock_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x4, },
};
const struct s_tpm_ppenable_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_ppenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x20, },
};
const struct s_tpm_ppassert_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_ppassert_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x8, },
};
const struct s_tpm_pcr_read_cmd{
- uint8_t buffer[14];
- uint16_t pcrNum;
+ uint8_t buffer[14];
+ uint16_t pcrNum;
} tpm_pcr_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15, },
10, };
const struct s_tpm_nv_read_cmd{
- uint8_t buffer[22];
- uint16_t index;
- uint16_t length;
+ uint8_t buffer[22];
+ uint16_t index;
+ uint16_t length;
} tpm_nv_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, },
10, 18, };
const struct s_tpm_nv_write_cmd{
- uint8_t buffer[256];
- uint16_t index;
- uint16_t length;
- uint16_t data;
+ uint8_t buffer[256];
+ uint16_t index;
+ uint16_t length;
+ uint16_t data;
} tpm_nv_write_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd, },
10, 18, 22, };
const struct s_tpm_nv_definespace_cmd{
- uint8_t buffer[101];
- uint16_t index;
- uint16_t pcr_info_read;
- uint16_t pcr_info_write;
- uint16_t perm;
- uint16_t size;
+ uint8_t buffer[101];
+ uint16_t index;
+ uint16_t pcr_info_read;
+ uint16_t pcr_info_write;
+ uint16_t perm;
+ uint16_t size;
} tpm_nv_definespace_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0xcc, 0x0, 0x18, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x17, },
12, 16, 42, 70, 77, };
diff --git a/firmware/lib/tpm_lite/include/tpm_error_messages.h b/firmware/lib/tpm_lite/include/tpm_error_messages.h
index 14cb86be..834ba2d0 100644
--- a/firmware/lib/tpm_lite/include/tpm_error_messages.h
+++ b/firmware/lib/tpm_lite/include/tpm_error_messages.h
@@ -16,9 +16,9 @@
#define TPM_E_NON_FATAL 0x800
typedef struct tpm_error_info {
- const char* name;
- uint32_t code;
- const char* description;
+ const char* name;
+ uint32_t code;
+ const char* description;
} tpm_error_info;
tpm_error_info tpm_error_table[] = {
@@ -245,6 +245,6 @@ because the ordinal required resources that have not been tested" },
{ "TPM_DEFEND_LOCK_RUNNING", TPM_E_BASE + TPM_E_NON_FATAL + 3,
"The TPM is defending against dictionary attacks and is in some\n\
time-out period" },
- };
+};
#endif /* TPM_ERROR_MESSAGES_H */
diff --git a/firmware/lib/tpm_lite/mocked_tlcl.c b/firmware/lib/tpm_lite/mocked_tlcl.c
index 0abcb7c9..917532d1 100644
--- a/firmware/lib/tpm_lite/mocked_tlcl.c
+++ b/firmware/lib/tpm_lite/mocked_tlcl.c
@@ -145,8 +145,8 @@ uint32_t TlclGetSTClearFlags(TPM_STCLEAR_FLAGS* vflags)
}
uint32_t TlclGetFlags(uint8_t* disable,
- uint8_t* deactivated,
- uint8_t *nvlocked)
+ uint8_t* deactivated,
+ uint8_t *nvlocked)
{
*disable = 0;
*deactivated = 0;
@@ -160,7 +160,7 @@ uint32_t TlclSetGlobalLock(void)
}
uint32_t TlclExtend(int pcr_num, const uint8_t* in_digest,
- uint8_t* out_digest)
+ uint8_t* out_digest)
{
memcpy(out_digest, in_digest, kPcrDigestLength);
return TPM_SUCCESS;
@@ -187,8 +187,8 @@ uint32_t TlclGetRandom(uint8_t* data, uint32_t length, uint32_t *size)
}
uint32_t TlclGetVersion(uint32_t* vendor, uint64_t* firmware_version,
- uint8_t* vendor_specific_buf,
- size_t* vendor_specific_buf_size)
+ uint8_t* vendor_specific_buf,
+ size_t* vendor_specific_buf_size)
{
*vendor = 0x4e4f4e45;
*firmware_version = 0x1;
@@ -206,7 +206,7 @@ int TlclPacketSize(const uint8_t* packet)
}
uint32_t TlclSendReceive(const uint8_t* request, uint8_t* response,
- int max_length)
+ int max_length)
{
return TPM_SUCCESS;
}
diff --git a/firmware/lib/tpm_lite/tlcl.c b/firmware/lib/tpm_lite/tlcl.c
index d7dfade9..7643ce7b 100644
--- a/firmware/lib/tpm_lite/tlcl.c
+++ b/firmware/lib/tpm_lite/tlcl.c
@@ -65,7 +65,7 @@ static inline int TpmReturnCode(const uint8_t* buffer)
* DOING_SELFTEST errors are returned.
*/
static uint32_t TlclSendReceiveNoRetry(const uint8_t* request,
- uint8_t* response, int max_length)
+ uint8_t* response, int max_length)
{
uint32_t response_length = max_length;
@@ -110,7 +110,7 @@ static uint32_t TlclSendReceiveNoRetry(const uint8_t* request,
* error code if error. In the firmware, waits for the self test to complete
* if needed. In the host, reports the first error without retries. */
uint32_t TlclSendReceive(const uint8_t* request, uint8_t* response,
- int max_length)
+ int max_length)
{
uint32_t result = TlclSendReceiveNoRetry(request, response, max_length);
/* When compiling for the firmware, hide command failures due to the
@@ -560,7 +560,7 @@ uint32_t TlclInitNvAuthPolicy(uint32_t pcr_selection_bitmap,
* the most unlikely one to be used in practice, i.e. the spec says
* locality 3 is for "Auxiliary components. Use of this is optional and,
* if used, it is implementation dependent."
- */
+ */
policy->pcr_info_read.localityAtRelease =
TPM_ALL_LOCALITIES & ~TPM_LOC_THREE;
@@ -786,8 +786,8 @@ uint32_t TlclGetSTClearFlags(TPM_STCLEAR_FLAGS* vflags)
}
uint32_t TlclGetFlags(uint8_t* disable,
- uint8_t* deactivated,
- uint8_t *nvlocked)
+ uint8_t* deactivated,
+ uint8_t *nvlocked)
{
TPM_PERMANENT_FLAGS pflags;
uint32_t result = TlclGetPermanentFlags(&pflags);
@@ -813,7 +813,7 @@ uint32_t TlclSetGlobalLock(void)
}
uint32_t TlclExtend(int pcr_num, const uint8_t* in_digest,
- uint8_t* out_digest)
+ uint8_t* out_digest)
{
struct s_tpm_extend_cmd cmd;
uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
@@ -990,8 +990,8 @@ uint32_t TlclGetRandom(uint8_t* data, uint32_t length, uint32_t *size)
}
uint32_t TlclGetVersion(uint32_t* vendor, uint64_t* firmware_version,
- uint8_t* vendor_specific_buf,
- size_t* vendor_specific_buf_size)
+ uint8_t* vendor_specific_buf,
+ size_t* vendor_specific_buf_size)
{
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
uint32_t result = TlclSendReceive(tpm_getversionval_cmd.buffer,
@@ -1313,7 +1313,7 @@ uint32_t TlclCreateDelegationFamily(uint8_t family_label)
}
uint32_t TlclReadDelegationFamilyTable(TPM_FAMILY_TABLE_ENTRY *table,
- uint32_t* table_size)
+ uint32_t* table_size)
{
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
uint32_t result = TlclSendReceive(tpm_delegate_read_table_cmd.buffer,
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 3ae3cd4d..516b1e44 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -407,7 +407,7 @@ static void vb2_kernel_cleanup(struct vb2_context *ctx, VbCommonParams *cparams)
}
VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
- VbSelectAndLoadKernelParams *kparams)
+ VbSelectAndLoadKernelParams *kparams)
{
VbError_t retval = vb2_kernel_setup(cparams, kparams);
if (retval)
@@ -606,7 +606,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
retval = VBERROR_SUCCESS;
-fail:
+ fail:
vb2_kernel_cleanup(&ctx, cparams);
if (NULL != kernel_subkey)
free(kernel_subkey);
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index f336f2c0..f0c4ea6a 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -61,9 +61,9 @@ const uint8_t *GetSignatureDataC(const VbSignature *sig)
*/
int VerifyMemberInside(const void *parent, uint64_t parent_size,
- const void *member, uint64_t member_size,
- uint64_t member_data_offset,
- uint64_t member_data_size)
+ const void *member, uint64_t member_size,
+ uint64_t member_data_offset,
+ uint64_t member_data_size)
{
uint64_t end = OffsetOf(parent, member);
@@ -90,7 +90,7 @@ int VerifyMemberInside(const void *parent, uint64_t parent_size,
}
int VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
- const VbPublicKey *key)
+ const VbPublicKey *key)
{
return VerifyMemberInside(parent, parent_size,
key, sizeof(VbPublicKey),
@@ -98,7 +98,7 @@ int VerifyPublicKeyInside(const void *parent, uint64_t parent_size,
}
int VerifySignatureInside(const void *parent, uint64_t parent_size,
- const VbSignature *sig)
+ const VbSignature *sig)
{
return VerifyMemberInside(parent, parent_size,
sig, sizeof(VbSignature),
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index 947fb42f..b34976d1 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -141,7 +141,7 @@ const char *RecoveryReasonString(uint8_t code)
case VB2_RECOVERY_RO_INVALID_RW_CHECK_MIN + VBSD_LF_CHECK_NOT_DONE:
return "RW firmware check not done";
case VB2_RECOVERY_RO_INVALID_RW_CHECK_MIN + VBSD_LF_CHECK_DEV_MISMATCH:
- return "RW firmware developer flag mismatch";
+ return "RW firmware developer flag mismatch";
case VB2_RECOVERY_RO_INVALID_RW_CHECK_MIN + VBSD_LF_CHECK_REC_MISMATCH:
return "RW firmware recovery flag mismatch";
case VB2_RECOVERY_RO_INVALID_RW_CHECK_MIN +
@@ -467,5 +467,5 @@ VbError_t VbCheckDisplayKey(struct vb2_context *ctx, uint32_t key)
(void)VbDisplayScreen(ctx, disp_current_screen, 1);
}
- return VBERROR_SUCCESS;
+ return VBERROR_SUCCESS;
}
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 5eb78f0a..640c4ff8 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -474,10 +474,10 @@ static VbError_t recovery_ui(struct vb2_context *ctx)
shared->flags & VBSD_HONOR_VIRT_DEV_SWITCH &&
!(shared->flags & VBSD_BOOT_DEV_SWITCH_ON) &&
(shared->flags & VBSD_BOOT_REC_SWITCH_ON)) {
- if (!(shared->flags &
+ if (!(shared->flags &
VBSD_BOOT_REC_SWITCH_VIRTUAL) &&
VbExGetSwitches(
- VB_INIT_FLAG_REC_BUTTON_PRESSED)) {
+ VB_INIT_FLAG_REC_BUTTON_PRESSED)) {
/*
* Is the recovery button stuck? In
* any case we don't like this. Beep
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c
index c063858f..647034e6 100644
--- a/firmware/stub/tpm_lite_stub.c
+++ b/firmware/stub/tpm_lite_stub.c
@@ -230,7 +230,7 @@ VbError_t VbExTpmOpen(void)
}
VbError_t VbExTpmSendReceive(const uint8_t* request, uint32_t request_length,
- uint8_t* response, uint32_t* response_length)
+ uint8_t* response, uint32_t* response_length)
{
/*
* In a real firmware implementation, this function should contain
@@ -280,12 +280,12 @@ VbError_t VbExTpmSendReceive(const uint8_t* request, uint32_t request_length,
tag = TpmTag(request);
response_tag = TpmTag(response);
assert(
- (tag == TPM_TAG_RQU_COMMAND &&
- response_tag == TPM_TAG_RSP_COMMAND) ||
- (tag == TPM_TAG_RQU_AUTH1_COMMAND &&
- response_tag == TPM_TAG_RSP_AUTH1_COMMAND) ||
- (tag == TPM_TAG_RQU_AUTH2_COMMAND &&
- response_tag == TPM_TAG_RSP_AUTH2_COMMAND));
+ (tag == TPM_TAG_RQU_COMMAND &&
+ response_tag == TPM_TAG_RSP_COMMAND) ||
+ (tag == TPM_TAG_RQU_AUTH1_COMMAND &&
+ response_tag == TPM_TAG_RSP_AUTH1_COMMAND) ||
+ (tag == TPM_TAG_RQU_AUTH2_COMMAND &&
+ response_tag == TPM_TAG_RSP_AUTH2_COMMAND));
assert(*response_length == TpmResponseSize(response));
#endif
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index e424e66c..1dbeca0f 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -140,7 +140,7 @@ VbError_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode)
VbError_t VbExEcVbootDone(int in_recovery)
{
- return VBERROR_SUCCESS;
+ return VBERROR_SUCCESS;
}
VbError_t VbExEcBatteryCutOff(void)
diff --git a/firmware/stub/vboot_api_stub_disk.c b/firmware/stub/vboot_api_stub_disk.c
index e23b54a8..975b42ad 100644
--- a/firmware/stub/vboot_api_stub_disk.c
+++ b/firmware/stub/vboot_api_stub_disk.c
@@ -16,7 +16,7 @@
VbError_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count,
- uint32_t disk_flags)
+ uint32_t disk_flags)
{
*infos_ptr = NULL;
*count = 0;
@@ -25,21 +25,21 @@ VbError_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count,
VbError_t VbExDiskFreeInfo(VbDiskInfo* infos_ptr,
- VbExDiskHandle_t preserve_handle)
+ VbExDiskHandle_t preserve_handle)
{
return VBERROR_SUCCESS;
}
VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, void* buffer)
+ uint64_t lba_count, void* buffer)
{
return VBERROR_SUCCESS;
}
VbError_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, const void* buffer)
+ uint64_t lba_count, const void* buffer)
{
return VBERROR_SUCCESS;
}
diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c
index 7a53887f..e084cb27 100644
--- a/futility/cmd_sign.c
+++ b/futility/cmd_sign.c
@@ -84,7 +84,7 @@ int ft_sign_pubkey(const char *name, uint8_t *buf, uint32_t len, void *data)
sign_option.pem_algo);
if (!sign_option.signprivate) {
fprintf(stderr,
- "Unable to read PEM signing key: %s\n",
+ "Unable to read PEM signing key: %s\n",
strerror(errno));
return 1;
}
@@ -1024,18 +1024,18 @@ static int do_sign(int argc, char *argv[])
}
} else {
/* We'll read-modify-write the output file */
- mapping = MAP_RW;
- if (sign_option.inout_file_count > 1)
- futil_copy_file_or_die(infile, sign_option.outfile);
- Debug("open RW %s\n", sign_option.outfile);
- infile = sign_option.outfile;
- ifd = open(sign_option.outfile, O_RDWR);
- if (ifd < 0) {
- errorcnt++;
- fprintf(stderr, "Can't open %s for writing: %s\n",
- sign_option.outfile, strerror(errno));
- goto done;
- }
+ mapping = MAP_RW;
+ if (sign_option.inout_file_count > 1)
+ futil_copy_file_or_die(infile, sign_option.outfile);
+ Debug("open RW %s\n", sign_option.outfile);
+ infile = sign_option.outfile;
+ ifd = open(sign_option.outfile, O_RDWR);
+ if (ifd < 0) {
+ errorcnt++;
+ fprintf(stderr, "Can't open %s for writing: %s\n",
+ sign_option.outfile, strerror(errno));
+ goto done;
+ }
}
if (0 != futil_map_file(ifd, mapping, &buf, &buf_len)) {
diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c
index 284b75d2..81cc281d 100644
--- a/host/arch/x86/lib/crossystem_arch.c
+++ b/host/arch/x86/lib/crossystem_arch.c
@@ -481,7 +481,7 @@ static int VbGetRecoveryReason(void)
* exactly one match for that, we're SOL.
*/
static int FindGpioChipOffset(unsigned *gpio_num, unsigned *offset,
- const char *name)
+ const char *name)
{
DIR *dir;
struct dirent *ent;
@@ -508,7 +508,7 @@ static int FindGpioChipOffset(unsigned *gpio_num, unsigned *offset,
* a 'label' file inside of it to find the expected the controller name.
*/
static int FindGpioChipOffsetByLabel(unsigned *gpio_num, unsigned *offset,
- const char *name)
+ const char *name)
{
DIR *dir;
struct dirent *ent;
@@ -618,7 +618,7 @@ static int FindGpioChipOffsetByNumber(unsigned *gpio_num, unsigned *offset,
* 4 | 0x18000
*/
static int BraswellFindGpioChipOffset(unsigned *gpio_num, unsigned *offset,
- const char *name)
+ const char *name)
{
static Basemapping data[]={
{0x20000, 0},
@@ -641,7 +641,7 @@ static int BraswellFindGpioChipOffset(unsigned *gpio_num, unsigned *offset,
* 3 | 0x2000
*/
static int BayTrailFindGpioChipOffset(unsigned *gpio_num, unsigned *offset,
- const char *name)
+ const char *name)
{
static Basemapping data[]={
{0x3000, 0},
@@ -860,7 +860,7 @@ int VbGetArchPropertyInt(const char* name)
const char* VbGetArchPropertyString(const char* name, char* dest,
- size_t size)
+ size_t size)
{
unsigned value;
diff --git a/host/include/cgpt_params.h b/host/include/cgpt_params.h
index 431443b9..7c4a4b29 100644
--- a/host/include/cgpt_params.h
+++ b/host/include/cgpt_params.h
@@ -85,7 +85,7 @@ typedef struct CgptPrioritizeParams {
struct CgptFindParams;
typedef void (*CgptFindShowFn)(struct CgptFindParams *params, char *filename,
- int partnum, GptEntry *entry);
+ int partnum, GptEntry *entry);
typedef struct CgptFindParams {
char *drive_name;
uint64_t drive_size;
diff --git a/host/include/crossystem.h b/host/include/crossystem.h
index 25b9cc0b..42b1b040 100644
--- a/host/include/crossystem.h
+++ b/host/include/crossystem.h
@@ -30,7 +30,7 @@ int VbGetSystemPropertyInt(const char* name);
*
* Returns the passed buffer, or NULL if error. */
const char* VbGetSystemPropertyString(const char* name, char* dest,
- size_t size);
+ size_t size);
/* Sets a system property integer.
*
diff --git a/host/include/vboot_host.h b/host/include/vboot_host.h
index 4b5db67e..9ebe4040 100644
--- a/host/include/vboot_host.h
+++ b/host/include/vboot_host.h
@@ -55,7 +55,7 @@ int GuidIsZero(const Guid *guid);
/* Returns a new copy of the kernel cmdline. The caller must free it. */
char *FindKernelConfig(const char *filename,
- uint64_t kernel_body_load_address);
+ uint64_t kernel_body_load_address);
/****************************************************************************/
/* Kernel partition */
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 0df67629..e41815ec 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -213,7 +213,7 @@ int VbGetCrosDebug(void)
}
char *GetVdatLoadFirmwareDebug(char *dest, int size,
- const VbSharedDataHeader *sh)
+ const VbSharedDataHeader *sh)
{
snprintf(dest, size,
"Check A result=%d\n"
@@ -232,7 +232,7 @@ char *GetVdatLoadFirmwareDebug(char *dest, int size,
#define TRUNCATED "\n(truncated)\n"
char *GetVdatLoadKernelDebug(char *dest, int size,
- const VbSharedDataHeader *sh)
+ const VbSharedDataHeader *sh)
{
int used = 0;
int first_call_tracked = 0;
@@ -566,7 +566,7 @@ int VbGetSystemPropertyInt(const char *name)
if (!VbGetSystemPropertyString("hwid", hwid, sizeof(hwid))) {
char fwtype_buf[VB_MAX_STRING_PROPERTY];
const char *fwtype = VbGetSystemPropertyString(
- "mainfw_type", fwtype_buf, sizeof(fwtype_buf));
+ "mainfw_type", fwtype_buf, sizeof(fwtype_buf));
if (fwtype && !strcasecmp(fwtype, "nonchrome")) {
value = 1;
}
@@ -579,7 +579,7 @@ int VbGetSystemPropertyInt(const char *name)
}
const char *VbGetSystemPropertyString(const char *name, char *dest,
- size_t size)
+ size_t size)
{
/* Check architecture-dependent properties first */
if (VbGetArchPropertyString(name, dest, size))
@@ -676,8 +676,8 @@ int VbSetSystemPropertyInt(const char *name, int value)
return -1;
kern_nv &= ~KERN_NV_FWUPDATE_TRIES_MASK;
kern_nv |= (value & KERN_NV_FWUPDATE_TRIES_MASK);
- return vb2_set_nv_storage_with_backup(VB2_NV_KERNEL_FIELD,
- kern_nv);
+ return vb2_set_nv_storage_with_backup(
+ VB2_NV_KERNEL_FIELD, kern_nv);
} else if (!strcasecmp(name,"block_devmode")) {
int kern_nv = vb2_get_nv_storage(VB2_NV_KERNEL_FIELD);
if (kern_nv == -1)
@@ -685,8 +685,8 @@ int VbSetSystemPropertyInt(const char *name, int value)
kern_nv &= ~KERN_NV_BLOCK_DEVMODE_FLAG;
if (value)
kern_nv |= KERN_NV_BLOCK_DEVMODE_FLAG;
- return vb2_set_nv_storage_with_backup(VB2_NV_KERNEL_FIELD,
- kern_nv);
+ return vb2_set_nv_storage_with_backup(
+ VB2_NV_KERNEL_FIELD, kern_nv);
} else if (!strcasecmp(name,"tpm_attack")) {
/* This value should only be read and cleared, but we allow
* setting it to 1 for testing. */
@@ -697,35 +697,34 @@ int VbSetSystemPropertyInt(const char *name, int value)
if (value)
kern_nv |= KERN_NV_TPM_ATTACK_FLAG;
return vb2_set_nv_storage_with_backup(
- VB2_NV_KERNEL_FIELD, kern_nv);
+ VB2_NV_KERNEL_FIELD, kern_nv);
} else if (!strcasecmp(name,"loc_idx")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_LOCALIZATION_INDEX,
- value);
+ VB2_NV_LOCALIZATION_INDEX, value);
} else if (!strcasecmp(name,"dev_boot_usb")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_DEV_BOOT_USB, value);
+ VB2_NV_DEV_BOOT_USB, value);
} else if (!strcasecmp(name,"dev_boot_legacy")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_DEV_BOOT_LEGACY, value);
+ VB2_NV_DEV_BOOT_LEGACY, value);
} else if (!strcasecmp(name,"dev_boot_signed_only")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_DEV_BOOT_SIGNED_ONLY, value);
+ VB2_NV_DEV_BOOT_SIGNED_ONLY, value);
} else if (!strcasecmp(name,"dev_boot_fastboot_full_cap")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_DEV_BOOT_FASTBOOT_FULL_CAP, value);
+ VB2_NV_DEV_BOOT_FASTBOOT_FULL_CAP, value);
} else if (!strcasecmp(name, "fastboot_unlock_in_fw")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_FASTBOOT_UNLOCK_IN_FW, value);
+ VB2_NV_FASTBOOT_UNLOCK_IN_FW, value);
} else if (!strcasecmp(name, "dev_enable_udc")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_DEV_ENABLE_UDC, value);
+ VB2_NV_DEV_ENABLE_UDC, value);
} else if (!strcasecmp(name, "boot_on_ac_detect")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_BOOT_ON_AC_DETECT, value);
+ VB2_NV_BOOT_ON_AC_DETECT, value);
} else if (!strcasecmp(name, "try_ro_sync")) {
return vb2_set_nv_storage_with_backup(
- VB2_NV_TRY_RO_SYNC, value);
+ VB2_NV_TRY_RO_SYNC, value);
} else if (!strcasecmp(name, "battery_cutoff_request")) {
return vb2_set_nv_storage(VB2_NV_BATTERY_CUTOFF_REQUEST, value);
} else if (!strcasecmp(name,"kernel_max_rollforward")) {
@@ -763,7 +762,7 @@ int VbSetSystemPropertyString(const char* name, const char* value)
for (i = 0; i < ARRAY_SIZE(default_boot); i++) {
if (!strcasecmp(value, default_boot[i]))
return vb2_set_nv_storage(
- VB2_NV_DEV_DEFAULT_BOOT, i);
+ VB2_NV_DEV_DEFAULT_BOOT, i);
}
return -1;
}
diff --git a/host/lib/host_keyblock.c b/host/lib/host_keyblock.c
index c315aad3..b8c9af3a 100644
--- a/host/lib/host_keyblock.c
+++ b/host/lib/host_keyblock.c
@@ -86,10 +86,10 @@ struct vb2_keyblock *vb2_create_keyblock(
* the existing interface. */
struct vb2_keyblock *vb2_create_keyblock_external(
const struct vb2_packed_key *data_key,
- const char *signing_key_pem_file,
- uint32_t algorithm,
- uint32_t flags,
- const char *external_signer)
+ const char *signing_key_pem_file,
+ uint32_t algorithm,
+ uint32_t flags,
+ const char *external_signer)
{
if (!signing_key_pem_file || !data_key || !external_signer)
return NULL;
diff --git a/host/lib/include/host_misc.h b/host/lib/include/host_misc.h
index 1bcf6f06..63a38943 100644
--- a/host/lib/include/host_misc.h
+++ b/host/lib/include/host_misc.h
@@ -12,8 +12,8 @@
#include "vboot_struct.h"
/* Copy up to dest_size-1 characters from src to dest, ensuring null
- termination (which strncpy() doesn't do). Returns the destination
- string. */
+ * termination (which strncpy() doesn't do). Returns the destination
+ * string. */
char* StrCopy(char* dest, const char* src, int dest_size);
/* Read data from [filename]. Store the size of returned data in [size].
diff --git a/host/lib/include/signature_digest.h b/host/lib/include/signature_digest.h
index 936591a8..ac0cd11b 100644
--- a/host/lib/include/signature_digest.h
+++ b/host/lib/include/signature_digest.h
@@ -23,7 +23,7 @@ uint8_t* PrependDigestInfo(enum vb2_hash_algorithm hash_alg, uint8_t* digest);
* pointer and must Free() it.
*/
uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
- unsigned int algorithm);
+ unsigned int algorithm);
/* Calculates the signature on a buffer [buf] of length [len] using
* the private RSA key file from [key_file] and signature algorithm
@@ -32,5 +32,5 @@ uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
* Returns the signature. Caller owns the buffer and must Free() it.
*/
uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
- unsigned int algorithm);
+ unsigned int algorithm);
#endif /* VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ */
diff --git a/host/lib/signature_digest.c b/host/lib/signature_digest.c
index 7f309b18..a154ed4b 100644
--- a/host/lib/signature_digest.c
+++ b/host/lib/signature_digest.c
@@ -35,7 +35,7 @@ uint8_t* PrependDigestInfo(enum vb2_hash_algorithm hash_alg, uint8_t* digest)
}
uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
- unsigned int algorithm)
+ unsigned int algorithm)
{
uint8_t* info_digest = NULL;
@@ -58,7 +58,7 @@ uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
}
uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
- unsigned int algorithm)
+ unsigned int algorithm)
{
const enum vb2_hash_algorithm hash_alg = vb2_crypto_to_hash(algorithm);
FILE* key_fp = NULL;
diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c
index 0336c8e7..a886174d 100644
--- a/tests/cgptlib_test.c
+++ b/tests/cgptlib_test.c
@@ -1299,7 +1299,7 @@ static void FreeEntry(GptEntry *e)
/* Set up an entry. */
static void FillEntry(GptEntry *e, int is_kernel,
- int priority, int successful, int tries)
+ int priority, int successful, int tries)
{
memcpy(&e->type, (is_kernel ? &guid_kernel : &guid_zero), sizeof(Guid));
SetEntryPriority(e, priority);
diff --git a/tests/cgptlib_test.h b/tests/cgptlib_test.h
index 8668c9c5..90e76fc8 100644
--- a/tests/cgptlib_test.h
+++ b/tests/cgptlib_test.h
@@ -9,8 +9,8 @@
#include "sysincludes.h"
enum {
- TEST_FAIL = -1,
- TEST_OK = 0,
+ TEST_FAIL = -1,
+ TEST_OK = 0,
};
#define TEST_CASE(func) #func, func
@@ -18,13 +18,13 @@ typedef int (*test_func)();
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
-#define EXPECT(expr) \
- do { \
- if (!(expr)) { \
- printf(COL_RED " fail " COL_STOP "in expression %s in %s() line %d\n",\
- #expr, __FUNCTION__, __LINE__); \
- return TEST_FAIL; \
- } \
- } while (0)
+#define EXPECT(expr) do { \
+ if (!(expr)) { \
+ printf(COL_RED " fail " COL_STOP \
+ "in expression %s in %s() line %d\n", \
+ #expr, __FUNCTION__, __LINE__); \
+ return TEST_FAIL; \
+ } \
+} while (0)
-#endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */
+#endif /* VBOOT_REFERENCE_CGPTLIB_TEST_H_ */
diff --git a/tests/crc32_test.c b/tests/crc32_test.c
index 01eb5ac6..81bdba98 100644
--- a/tests/crc32_test.c
+++ b/tests/crc32_test.c
@@ -12,37 +12,37 @@
#define MAX_VECTOR_LEN 256
int TestCrc32TestVectors() {
- struct {
- uint8_t vector[MAX_VECTOR_LEN];
- int len;
- uint32_t crc32;
- } cases[] = {
- {{0x00}, 1, 0xD202EF8D},
- {{0x00, 0x00, 0x00, 0x00}, 4, 0x2144DF1C},
- {{0x01, 0x01, 0x01, 0x01}, 4, 0xF626D399},
- {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x28,0x86,0x4d,0x7f,0x99}, 48, 0x923D6EFD},
- {{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0x00,0x00,0x00,0x28,0xc5,0x5e,0x45,0x7a}, 48, 0x49A04D82},
- {{0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,
- 0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,
- 0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,
- 0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
- 0x00,0x00,0x00,0x28,0xbf,0x67,0x1e,0xd0}, 48, 0x688B3BFA},
- };
- int i;
+ struct {
+ uint8_t vector[MAX_VECTOR_LEN];
+ int len;
+ uint32_t crc32;
+ } cases[] = {
+ {{0x00}, 1, 0xD202EF8D},
+ {{0x00, 0x00, 0x00, 0x00}, 4, 0x2144DF1C},
+ {{0x01, 0x01, 0x01, 0x01}, 4, 0xF626D399},
+ {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x28,0x86,0x4d,0x7f,0x99}, 48, 0x923D6EFD},
+ {{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x28,0xc5,0x5e,0x45,0x7a}, 48, 0x49A04D82},
+ {{0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,
+ 0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,
+ 0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,
+ 0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
+ 0x00,0x00,0x00,0x28,0xbf,0x67,0x1e,0xd0}, 48, 0x688B3BFA},
+ };
+ int i;
- for (i = 0; i < ARRAY_SIZE(cases); ++i) {
- uint32_t crc32;
+ for (i = 0; i < ARRAY_SIZE(cases); ++i) {
+ uint32_t crc32;
- crc32 = Crc32(cases[i].vector, cases[i].len);
- EXPECT(crc32 == cases[i].crc32);
- }
- return TEST_OK;
+ crc32 = Crc32(cases[i].vector, cases[i].len);
+ EXPECT(crc32 == cases[i].crc32);
+ }
+ return TEST_OK;
}
diff --git a/tests/sha_test_vectors.h b/tests/sha_test_vectors.h
index 310f5703..9214799e 100644
--- a/tests/sha_test_vectors.h
+++ b/tests/sha_test_vectors.h
@@ -10,82 +10,82 @@
char* oneblock_msg = "abc";
char* multiblock_msg1 = "abcdbcdecdefdefgefghfghighijhijkijkl"
- "jklmklmnlmnomnopnopq";
+ "jklmklmnlmnomnopnopq";
char* multiblock_msg2= "abcdefghbcdefghicdefghijdefghijkefghi"
- "jklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnop"
- "qrsmnopqrstnopqrstu";
+ "jklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnop"
+ "qrsmnopqrstnopqrstu";
char* long_msg;
uint8_t sha1_results[][VB2_SHA1_DIGEST_SIZE] = {
- {
- 0xa9,0x99,0x3e,0x36,0x47,0x06,0x81,0x6a,
- 0xba,0x3e,0x25,0x71,0x78,0x50,0xc2,0x6c,
- 0x9c,0xd0,0xd8,0x9d
- },
- {
- 0x84,0x98,0x3e,0x44,0x1c,0x3b,0xd2,0x6e,
- 0xba,0xae,0x4a,0xa1,0xf9,0x51,0x29,0xe5,
- 0xe5,0x46,0x70,0xf1
- },
- {
- 0x34,0xaa,0x97,0x3c,0xd4,0xc4,0xda,0xa4,
- 0xf6,0x1e,0xeb,0x2b,0xdb,0xad,0x27,0x31,
- 0x65,0x34,0x01,0x6f
- }
+ {
+ 0xa9,0x99,0x3e,0x36,0x47,0x06,0x81,0x6a,
+ 0xba,0x3e,0x25,0x71,0x78,0x50,0xc2,0x6c,
+ 0x9c,0xd0,0xd8,0x9d
+ },
+ {
+ 0x84,0x98,0x3e,0x44,0x1c,0x3b,0xd2,0x6e,
+ 0xba,0xae,0x4a,0xa1,0xf9,0x51,0x29,0xe5,
+ 0xe5,0x46,0x70,0xf1
+ },
+ {
+ 0x34,0xaa,0x97,0x3c,0xd4,0xc4,0xda,0xa4,
+ 0xf6,0x1e,0xeb,0x2b,0xdb,0xad,0x27,0x31,
+ 0x65,0x34,0x01,0x6f
+ }
};
uint8_t sha256_results[][VB2_SHA256_DIGEST_SIZE] = {
- {
- 0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,
- 0x41,0x41,0x40,0xde,0x5d,0xae,0x22,0x23,
- 0xb0,0x03,0x61,0xa3,0x96,0x17,0x7a,0x9c,
- 0xb4,0x10,0xff,0x61,0xf2,0x00,0x15,0xad
- },
- {
- 0x24,0x8d,0x6a,0x61,0xd2,0x06,0x38,0xb8,
- 0xe5,0xc0,0x26,0x93,0x0c,0x3e,0x60,0x39,
- 0xa3,0x3c,0xe4,0x59,0x64,0xff,0x21,0x67,
- 0xf6,0xec,0xed,0xd4,0x19,0xdb,0x06,0xc1
- },
- {
- 0xcd,0xc7,0x6e,0x5c,0x99,0x14,0xfb,0x92,
- 0x81,0xa1,0xc7,0xe2,0x84,0xd7,0x3e,0x67,
- 0xf1,0x80,0x9a,0x48,0xa4,0x97,0x20,0x0e,
- 0x04,0x6d,0x39,0xcc,0xc7,0x11,0x2c,0xd0
- }
+ {
+ 0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,
+ 0x41,0x41,0x40,0xde,0x5d,0xae,0x22,0x23,
+ 0xb0,0x03,0x61,0xa3,0x96,0x17,0x7a,0x9c,
+ 0xb4,0x10,0xff,0x61,0xf2,0x00,0x15,0xad
+ },
+ {
+ 0x24,0x8d,0x6a,0x61,0xd2,0x06,0x38,0xb8,
+ 0xe5,0xc0,0x26,0x93,0x0c,0x3e,0x60,0x39,
+ 0xa3,0x3c,0xe4,0x59,0x64,0xff,0x21,0x67,
+ 0xf6,0xec,0xed,0xd4,0x19,0xdb,0x06,0xc1
+ },
+ {
+ 0xcd,0xc7,0x6e,0x5c,0x99,0x14,0xfb,0x92,
+ 0x81,0xa1,0xc7,0xe2,0x84,0xd7,0x3e,0x67,
+ 0xf1,0x80,0x9a,0x48,0xa4,0x97,0x20,0x0e,
+ 0x04,0x6d,0x39,0xcc,0xc7,0x11,0x2c,0xd0
+ }
};
uint8_t sha512_results[][VB2_SHA512_DIGEST_SIZE] = {
- {
- 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,
- 0xcc,0x41,0x73,0x49,0xae,0x20,0x41,0x31,
- 0x12,0xe6,0xfa,0x4e,0x89,0xa9,0x7e,0xa2,
- 0x0a,0x9e,0xee,0xe6,0x4b,0x55,0xd3,0x9a,
- 0x21,0x92,0x99,0x2a,0x27,0x4f,0xc1,0xa8,
- 0x36,0xba,0x3c,0x23,0xa3,0xfe,0xeb,0xbd,
- 0x45,0x4d,0x44,0x23,0x64,0x3c,0xe8,0x0e,
- 0x2a,0x9a,0xc9,0x4f,0xa5,0x4c,0xa4,0x9f
- },
- {
- 0x8e,0x95,0x9b,0x75,0xda,0xe3,0x13,0xda,
- 0x8c,0xf4,0xf7,0x28,0x14,0xfc,0x14,0x3f,
- 0x8f,0x77,0x79,0xc6,0xeb,0x9f,0x7f,0xa1,
- 0x72,0x99,0xae,0xad,0xb6,0x88,0x90,0x18,
- 0x50,0x1d,0x28,0x9e,0x49,0x00,0xf7,0xe4,
- 0x33,0x1b,0x99,0xde,0xc4,0xb5,0x43,0x3a,
- 0xc7,0xd3,0x29,0xee,0xb6,0xdd,0x26,0x54,
- 0x5e,0x96,0xe5,0x5b,0x87,0x4b,0xe9,0x09
- },
- {
- 0xe7,0x18,0x48,0x3d,0x0c,0xe7,0x69,0x64,
- 0x4e,0x2e,0x42,0xc7,0xbc,0x15,0xb4,0x63,
- 0x8e,0x1f,0x98,0xb1,0x3b,0x20,0x44,0x28,
- 0x56,0x32,0xa8,0x03,0xaf,0xa9,0x73,0xeb,
- 0xde,0x0f,0xf2,0x44,0x87,0x7e,0xa6,0x0a,
- 0x4c,0xb0,0x43,0x2c,0xe5,0x77,0xc3,0x1b,
- 0xeb,0x00,0x9c,0x5c,0x2c,0x49,0xaa,0x2e,
- 0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b
- }
+ {
+ 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,
+ 0xcc,0x41,0x73,0x49,0xae,0x20,0x41,0x31,
+ 0x12,0xe6,0xfa,0x4e,0x89,0xa9,0x7e,0xa2,
+ 0x0a,0x9e,0xee,0xe6,0x4b,0x55,0xd3,0x9a,
+ 0x21,0x92,0x99,0x2a,0x27,0x4f,0xc1,0xa8,
+ 0x36,0xba,0x3c,0x23,0xa3,0xfe,0xeb,0xbd,
+ 0x45,0x4d,0x44,0x23,0x64,0x3c,0xe8,0x0e,
+ 0x2a,0x9a,0xc9,0x4f,0xa5,0x4c,0xa4,0x9f
+ },
+ {
+ 0x8e,0x95,0x9b,0x75,0xda,0xe3,0x13,0xda,
+ 0x8c,0xf4,0xf7,0x28,0x14,0xfc,0x14,0x3f,
+ 0x8f,0x77,0x79,0xc6,0xeb,0x9f,0x7f,0xa1,
+ 0x72,0x99,0xae,0xad,0xb6,0x88,0x90,0x18,
+ 0x50,0x1d,0x28,0x9e,0x49,0x00,0xf7,0xe4,
+ 0x33,0x1b,0x99,0xde,0xc4,0xb5,0x43,0x3a,
+ 0xc7,0xd3,0x29,0xee,0xb6,0xdd,0x26,0x54,
+ 0x5e,0x96,0xe5,0x5b,0x87,0x4b,0xe9,0x09
+ },
+ {
+ 0xe7,0x18,0x48,0x3d,0x0c,0xe7,0x69,0x64,
+ 0x4e,0x2e,0x42,0xc7,0xbc,0x15,0xb4,0x63,
+ 0x8e,0x1f,0x98,0xb1,0x3b,0x20,0x44,0x28,
+ 0x56,0x32,0xa8,0x03,0xaf,0xa9,0x73,0xeb,
+ 0xde,0x0f,0xf2,0x44,0x87,0x7e,0xa6,0x0a,
+ 0x4c,0xb0,0x43,0x2c,0xe5,0x77,0xc3,0x1b,
+ 0xeb,0x00,0x9c,0x5c,0x2c,0x49,0xaa,0x2e,
+ 0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b
+ }
};
-#endif /* VBOOT_REFERENCE_SHA_TEST_VECTORS_H_ */
+#endif /* VBOOT_REFERENCE_SHA_TEST_VECTORS_H_ */
diff --git a/tests/sha_tests.c b/tests/sha_tests.c
index 40d3749f..1d78204a 100644
--- a/tests/sha_tests.c
+++ b/tests/sha_tests.c
@@ -13,86 +13,95 @@
#include "sha_test_vectors.h"
int SHA1_tests(void) {
- int i, success = 1;
- uint8_t sha1_digest[SHA1_DIGEST_SIZE];
- uint8_t* test_inputs[3];
- test_inputs[0] = (uint8_t *) oneblock_msg;
- test_inputs[1] = (uint8_t *) multiblock_msg1;
- test_inputs[2] = (uint8_t *) long_msg;
+ int i, success = 1;
+ uint8_t sha1_digest[SHA1_DIGEST_SIZE];
+ uint8_t* test_inputs[3];
+ test_inputs[0] = (uint8_t *) oneblock_msg;
+ test_inputs[1] = (uint8_t *) multiblock_msg1;
+ test_inputs[2] = (uint8_t *) long_msg;
- for (i = 0; i < 3; i++) {
- internal_SHA1(test_inputs[i], strlen((char *)test_inputs[i]),
- sha1_digest);
- if (!memcmp(sha1_digest, sha1_results[i], SHA1_DIGEST_SIZE)) {
- fprintf(stderr, "Test vector %d PASSED for SHA-1\n", i+1);
- }
- else {
- fprintf(stderr, "Test vector %d FAILED for SHA-1\n", i+1);
- success = 0;
- }
- }
- return success;
+ for (i = 0; i < 3; i++) {
+ internal_SHA1(test_inputs[i], strlen((char *)test_inputs[i]),
+ sha1_digest);
+ if (!memcmp(sha1_digest, sha1_results[i],
+ SHA1_DIGEST_SIZE)) {
+ fprintf(stderr, "Test vector %d PASSED for SHA-1\n",
+ i+1);
+ }
+ else {
+ fprintf(stderr, "Test vector %d FAILED for SHA-1\n",
+ i+1);
+ success = 0;
+ }
+ }
+ return success;
}
int SHA256_tests(void) {
- int i, success = 1;
- uint8_t sha256_digest[SHA256_DIGEST_SIZE];
- uint8_t* test_inputs[3];
- test_inputs[0] = (uint8_t *) oneblock_msg;
- test_inputs[1] = (uint8_t *) multiblock_msg1;
- test_inputs[2] = (uint8_t *) long_msg;
+ int i, success = 1;
+ uint8_t sha256_digest[SHA256_DIGEST_SIZE];
+ uint8_t* test_inputs[3];
+ test_inputs[0] = (uint8_t *) oneblock_msg;
+ test_inputs[1] = (uint8_t *) multiblock_msg1;
+ test_inputs[2] = (uint8_t *) long_msg;
- for (i = 0; i < 3; i++) {
- internal_SHA256(test_inputs[i], strlen((char *)test_inputs[i]),
- sha256_digest);
- if (!memcmp(sha256_digest, sha256_results[i], SHA256_DIGEST_SIZE)) {
- fprintf(stderr, "Test vector %d PASSED for SHA-256\n", i+1);
- }
- else {
- fprintf(stderr, "Test vector %d FAILED for SHA-256\n", i+1);
- success = 0;
- }
- }
- return success;
+ for (i = 0; i < 3; i++) {
+ internal_SHA256(test_inputs[i], strlen((char *)test_inputs[i]),
+ sha256_digest);
+ if (!memcmp(sha256_digest, sha256_results[i],
+ SHA256_DIGEST_SIZE)) {
+ fprintf(stderr, "Test vector %d PASSED for SHA-256\n",
+ i+1);
+ }
+ else {
+ fprintf(stderr, "Test vector %d FAILED for SHA-256\n",
+ i+1);
+ success = 0;
+ }
+ }
+ return success;
}
int SHA512_tests(void) {
- int i, success = 1;
- uint8_t sha512_digest[SHA512_DIGEST_SIZE];
- uint8_t* test_inputs[3];
- test_inputs[0] = (uint8_t *) oneblock_msg;
- test_inputs[1] = (uint8_t *) multiblock_msg2;
- test_inputs[2] = (uint8_t *) long_msg;
+ int i, success = 1;
+ uint8_t sha512_digest[SHA512_DIGEST_SIZE];
+ uint8_t* test_inputs[3];
+ test_inputs[0] = (uint8_t *) oneblock_msg;
+ test_inputs[1] = (uint8_t *) multiblock_msg2;
+ test_inputs[2] = (uint8_t *) long_msg;
- for (i = 0; i < 3; i++) {
- internal_SHA512(test_inputs[i], strlen((char *)test_inputs[i]),
- sha512_digest);
- if (!memcmp(sha512_digest, sha512_results[i], SHA512_DIGEST_SIZE)) {
- fprintf(stderr, "Test vector %d PASSED for SHA-512\n", i+1);
- }
- else {
- fprintf(stderr, "Test vector %d FAILED for SHA-512\n", i+1);
- success = 0;
- }
- }
- return success;
+ for (i = 0; i < 3; i++) {
+ internal_SHA512(test_inputs[i], strlen((char *)test_inputs[i]),
+ sha512_digest);
+ if (!memcmp(sha512_digest, sha512_results[i],
+ SHA512_DIGEST_SIZE)) {
+ fprintf(stderr, "Test vector %d PASSED for SHA-512\n",
+ i+1);
+ }
+ else {
+ fprintf(stderr, "Test vector %d FAILED for SHA-512\n",
+ i+1);
+ success = 0;
+ }
+ }
+ return success;
}
int main(int argc, char* argv[]) {
- int success = 1;
- /* Initialize long_msg with 'a' x 1,000,000 */
- long_msg = (char *) malloc(1000001);
- memset(long_msg, 'a', 1000000);
- long_msg[1000000]=0;
+ int success = 1;
+ /* Initialize long_msg with 'a' x 1,000,000 */
+ long_msg = (char *) malloc(1000001);
+ memset(long_msg, 'a', 1000000);
+ long_msg[1000000]=0;
- if (!SHA1_tests())
- success = 0;
- if (!SHA256_tests())
- success = 0;
- if (!SHA512_tests())
- success = 0;
+ if (!SHA1_tests())
+ success = 0;
+ if (!SHA256_tests())
+ success = 0;
+ if (!SHA512_tests())
+ success = 0;
- free(long_msg);
+ free(long_msg);
- return !success;
+ return !success;
}
diff --git a/tests/test_common.c b/tests/test_common.c
index 972a3ffe..ddd81052 100644
--- a/tests/test_common.c
+++ b/tests/test_common.c
@@ -17,156 +17,159 @@ int gTestSuccess = 1;
int test_eq(int result, int expected,
const char *preamble, const char *desc, const char *comment)
{
- if (result == expected) {
- fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, comment ? comment : desc);
- return 1;
- } else {
- fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, comment ? comment : desc);
- fprintf(stderr, " Expected: 0x%x (%d), got: 0x%x (%d)\n",
- expected, expected, result, result);
- gTestSuccess = 0;
- return 0;
- }
+ if (result == expected) {
+ fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, comment ? comment : desc);
+ return 1;
+ } else {
+ fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, comment ? comment : desc);
+ fprintf(stderr, " Expected: 0x%x (%d), got: 0x%x (%d)\n",
+ expected, expected, result, result);
+ gTestSuccess = 0;
+ return 0;
+ }
}
int test_neq(int result, int not_expected,
const char *preamble, const char *desc, const char *comment)
{
- if (result != not_expected) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- return 1;
- } else {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " Didn't expect 0x%x (%d), but got it.\n",
- not_expected, not_expected);
- gTestSuccess = 0;
- return 0;
- }
+ if (result != not_expected) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ return 1;
+ } else {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " Didn't expect 0x%x (%d), but got it.\n",
+ not_expected, not_expected);
+ gTestSuccess = 0;
+ return 0;
+ }
}
int test_ptr_eq(const void* result, const void* expected,
const char *preamble, const char *desc, const char *comment)
{
- if (result == expected) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- return 1;
- } else {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " Expected: 0x%lx, got: 0x%lx\n", (long)expected,
- (long)result);
- gTestSuccess = 0;
- return 0;
- }
+ if (result == expected) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ return 1;
+ } else {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " Expected: 0x%lx, got: 0x%lx\n",
+ (long)expected, (long)result);
+ gTestSuccess = 0;
+ return 0;
+ }
}
int test_ptr_neq(const void* result, const void* not_expected,
const char *preamble, const char *desc, const char *comment)
{
- if (result != not_expected) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- return 1;
- } else {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " Didn't expect 0x%lx, but got it\n",
- (long)not_expected);
- gTestSuccess = 0;
- return 0;
- }
+ if (result != not_expected) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ return 1;
+ } else {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " Didn't expect 0x%lx, but got it\n",
+ (long)not_expected);
+ gTestSuccess = 0;
+ return 0;
+ }
}
int test_str_eq(const char* result, const char* expected,
const char *preamble, const char *desc, const char *comment)
{
- if (!result || !expected) {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " String compare with NULL\n");
- gTestSuccess = 0;
- return 0;
- } else if (!strcmp(result, expected)) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- return 1;
- } else {
- fprintf(stderr, "%s " COL_RED "FAILED\n" COL_STOP, comment);
- fprintf(stderr, " Expected: \"%s\", got: \"%s\"\n", expected,
- result);
- gTestSuccess = 0;
- return 0;
- }
+ if (!result || !expected) {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " String compare with NULL\n");
+ gTestSuccess = 0;
+ return 0;
+ } else if (!strcmp(result, expected)) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ return 1;
+ } else {
+ fprintf(stderr, "%s " COL_RED "FAILED\n" COL_STOP, comment);
+ fprintf(stderr, " Expected: \"%s\", got: \"%s\"\n",
+ expected, result);
+ gTestSuccess = 0;
+ return 0;
+ }
}
int test_str_neq(const char* result, const char* not_expected,
const char *preamble, const char *desc, const char *comment)
{
- if (!result || !not_expected) {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " String compare with NULL\n");
- gTestSuccess = 0;
- return 0;
- } else if (strcmp(result, not_expected)) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- return 1;
- } else {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " Didn't expect: \"%s\", but got it\n", not_expected);
- gTestSuccess = 0;
- return 0;
- }
+ if (!result || !not_expected) {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " String compare with NULL\n");
+ gTestSuccess = 0;
+ return 0;
+ } else if (strcmp(result, not_expected)) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ return 1;
+ } else {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " Didn't expect: \"%s\", but got it\n",
+ not_expected);
+ gTestSuccess = 0;
+ return 0;
+ }
}
int test_succ(int result,
const char *preamble, const char *desc, const char *comment)
{
- if (result == 0) {
- fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, comment ? comment : desc);
- } else {
- fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, comment ? comment : desc);
- fprintf(stderr, " Expected SUCCESS, got: 0x%x (%d)\n", result, result);
- gTestSuccess = 0;
- }
- return !result;
+ if (result == 0) {
+ fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, comment ? comment : desc);
+ } else {
+ fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, comment ? comment : desc);
+ fprintf(stderr, " Expected SUCCESS, got: 0x%x (%d)\n",
+ result, result);
+ gTestSuccess = 0;
+ }
+ return !result;
}
int test_true(int result,
const char *preamble, const char *desc, const char *comment)
{
- if (result) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- } else {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " Expected TRUE, got 0\n");
- gTestSuccess = 0;
- }
- return result;
+ if (result) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ } else {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " Expected TRUE, got 0\n");
+ gTestSuccess = 0;
+ }
+ return result;
}
int test_false(int result,
const char *preamble, const char *desc, const char *comment)
{
- if (!result) {
- fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
- preamble, desc, comment);
- } else {
- fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
- preamble, desc, comment);
- fprintf(stderr, " Expected FALSE, got: 0x%lx\n", (long)result);
- gTestSuccess = 0;
- }
- return !result;
+ if (!result) {
+ fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP,
+ preamble, desc, comment);
+ } else {
+ fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP,
+ preamble, desc, comment);
+ fprintf(stderr, " Expected FALSE, got: 0x%lx\n",
+ (long)result);
+ gTestSuccess = 0;
+ }
+ return !result;
}
diff --git a/tests/timer_utils.c b/tests/timer_utils.c
index 015f6db3..25e7503c 100644
--- a/tests/timer_utils.c
+++ b/tests/timer_utils.c
@@ -6,19 +6,19 @@
#include "timer_utils.h"
void StartTimer(ClockTimerState* ct) {
- clock_gettime(CLOCK_REALTIME, &ct->start_time);
+ clock_gettime(CLOCK_REALTIME, &ct->start_time);
}
void StopTimer(ClockTimerState* ct) {
- clock_gettime(CLOCK_REALTIME, &ct->end_time);
+ clock_gettime(CLOCK_REALTIME, &ct->end_time);
}
uint32_t GetDurationMsecs(ClockTimerState* ct) {
- uint64_t start = ((uint64_t) ct->start_time.tv_sec * 1000000000 +
- (uint64_t) ct->start_time.tv_nsec);
- uint64_t end = ((uint64_t) ct->end_time.tv_sec * 1000000000 +
- (uint64_t) ct->end_time.tv_nsec);
- uint64_t duration_msecs = (end - start) / 1000000U; /* Nanoseconds ->
- * Milliseconds. */
- return (uint32_t) duration_msecs;
+ uint64_t start = ((uint64_t) ct->start_time.tv_sec * 1000000000 +
+ (uint64_t) ct->start_time.tv_nsec);
+ uint64_t end = ((uint64_t) ct->end_time.tv_sec * 1000000000 +
+ (uint64_t) ct->end_time.tv_nsec);
+ uint64_t duration_msecs = (end - start) / 1000000U; /* Nanoseconds ->
+ * Milliseconds. */
+ return (uint32_t) duration_msecs;
}
diff --git a/tests/timer_utils.h b/tests/timer_utils.h
index 69380722..78099807 100644
--- a/tests/timer_utils.h
+++ b/tests/timer_utils.h
@@ -11,8 +11,8 @@
#include <time.h>
typedef struct ClockTimer {
- struct timespec start_time;
- struct timespec end_time;
+ struct timespec start_time;
+ struct timespec end_time;
} ClockTimerState;
/* Start timer and update [ct]. */
diff --git a/tests/tlcl_tests.c b/tests/tlcl_tests.c
index 55e897cb..9d67671e 100644
--- a/tests/tlcl_tests.c
+++ b/tests/tlcl_tests.c
@@ -77,7 +77,7 @@ VbError_t VbExTpmClose(void)
}
VbError_t VbExTpmSendReceive(const uint8_t *request, uint32_t request_length,
- uint8_t *response, uint32_t *response_length)
+ uint8_t *response, uint32_t *response_length)
{
struct srcall *c = calls + ncalls++;
diff --git a/tests/tpm_lite/lock.c b/tests/tpm_lite/lock.c
index 2fd21b7e..bfc10e2e 100644
--- a/tests/tpm_lite/lock.c
+++ b/tests/tpm_lite/lock.c
@@ -15,15 +15,15 @@
int main(int argc, char** argv) {
- TlclLibInit();
+ TlclLibInit();
- TlclStartup();
- TlclSelfTestFull();
+ TlclStartup();
+ TlclSelfTestFull();
- TlclAssertPhysicalPresence();
+ TlclAssertPhysicalPresence();
- TlclWriteLock(INDEX0);
+ TlclWriteLock(INDEX0);
- printf("Locked 0x%x\n", INDEX0);
- exit(0);
+ printf("Locked 0x%x\n", INDEX0);
+ exit(0);
}
diff --git a/tests/tpm_lite/readonly.c b/tests/tpm_lite/readonly.c
index 97b90917..c3940e12 100644
--- a/tests/tpm_lite/readonly.c
+++ b/tests/tpm_lite/readonly.c
@@ -34,76 +34,82 @@
* of making this FUBAR).
*/
void InitializeSpaces(void) {
- uint32_t zero = 0;
- uint32_t perm = TPM_NV_PER_WRITE_STCLEAR | TPM_NV_PER_PPWRITE;
-
- printf("Initializing spaces\n");
- TlclSetNvLocked(); /* useful only the first time */
-
- TlclDefineSpace(INDEX0, perm, 4);
- TlclWrite(INDEX0, (uint8_t *) &zero, 4);
- TlclDefineSpace(INDEX1, perm, 4);
- TlclWrite(INDEX1, (uint8_t *) &zero, 4);
- TlclDefineSpace(INDEX2, perm, 4);
- TlclWrite(INDEX2, (uint8_t *) &zero, 4);
- TlclDefineSpace(INDEX3, perm, 4);
- TlclWrite(INDEX3, (uint8_t *) &zero, 4);
-
- perm = TPM_NV_PER_READ_STCLEAR | TPM_NV_PER_WRITE_STCLEAR |
- TPM_NV_PER_PPWRITE;
- TlclDefineSpace(INDEX_INITIALIZED, perm, 1);
+ uint32_t zero = 0;
+ uint32_t perm = TPM_NV_PER_WRITE_STCLEAR | TPM_NV_PER_PPWRITE;
+
+ printf("Initializing spaces\n");
+ TlclSetNvLocked(); /* useful only the first time */
+
+ TlclDefineSpace(INDEX0, perm, 4);
+ TlclWrite(INDEX0, (uint8_t *) &zero, 4);
+ TlclDefineSpace(INDEX1, perm, 4);
+ TlclWrite(INDEX1, (uint8_t *) &zero, 4);
+ TlclDefineSpace(INDEX2, perm, 4);
+ TlclWrite(INDEX2, (uint8_t *) &zero, 4);
+ TlclDefineSpace(INDEX3, perm, 4);
+ TlclWrite(INDEX3, (uint8_t *) &zero, 4);
+
+ perm = (TPM_NV_PER_READ_STCLEAR | TPM_NV_PER_WRITE_STCLEAR |
+ TPM_NV_PER_PPWRITE);
+ TlclDefineSpace(INDEX_INITIALIZED, perm, 1);
}
void EnterRecoveryMode(void) {
- printf("entering recovery mode");
- exit(0);
+ printf("entering recovery mode");
+ exit(0);
}
int main(int argc, char** argv) {
- uint8_t c;
- uint32_t index_0, index_1, index_2, index_3;
-
- TlclLibInit();
-
- TlclStartup();
- TlclSelfTestFull();
-
- TlclAssertPhysicalPresence();
-
- /* Checks if initialization has completed by trying to read-lock a space
- * that's created at the end of initialization.
- */
- if (TlclRead(INDEX_INITIALIZED, &c, 0) == TPM_E_BADINDEX) {
- /* The initialization did not complete.
- */
- InitializeSpaces();
- }
-
- /* Checks if spaces are OK or messed up.
- */
- if (TlclRead(INDEX0, (uint8_t*) &index_0, sizeof(index_0)) != TPM_SUCCESS ||
- TlclRead(INDEX1, (uint8_t*) &index_1, sizeof(index_1)) != TPM_SUCCESS ||
- TlclRead(INDEX2, (uint8_t*) &index_2, sizeof(index_2)) != TPM_SUCCESS ||
- TlclRead(INDEX3, (uint8_t*) &index_3, sizeof(index_3)) != TPM_SUCCESS) {
- EnterRecoveryMode();
- }
-
- /* Writes space, and locks it. Then attempts to write again. I really wish
- * I could use the imperative.
- */
- index_0 += 1;
- if (TlclWrite(INDEX0, (uint8_t*) &index_0, sizeof(index_0) != TPM_SUCCESS)) {
- error("could not write index 0\n");
- }
- TlclWriteLock(INDEX0);
- if (TlclWrite(INDEX0, (uint8_t*) &index_0, sizeof(index_0)) == TPM_SUCCESS) {
- error("index 0 is not locked\n");
- }
-
- /* Done for now.
- */
- printf("TEST SUCCEEDED\n");
- exit(0);
+ uint8_t c;
+ uint32_t index_0, index_1, index_2, index_3;
+
+ TlclLibInit();
+
+ TlclStartup();
+ TlclSelfTestFull();
+
+ TlclAssertPhysicalPresence();
+
+ /* Checks if initialization has completed by trying to read-lock a space
+ * that's created at the end of initialization.
+ */
+ if (TlclRead(INDEX_INITIALIZED, &c, 0) == TPM_E_BADINDEX) {
+ /* The initialization did not complete.
+ */
+ InitializeSpaces();
+ }
+
+ /* Checks if spaces are OK or messed up.
+ */
+ if (TlclRead(INDEX0, (uint8_t*) &index_0,
+ sizeof(index_0)) != TPM_SUCCESS ||
+ TlclRead(INDEX1, (uint8_t*) &index_1,
+ sizeof(index_1)) != TPM_SUCCESS ||
+ TlclRead(INDEX2, (uint8_t*) &index_2,
+ sizeof(index_2)) != TPM_SUCCESS ||
+ TlclRead(INDEX3, (uint8_t*) &index_3,
+ sizeof(index_3)) != TPM_SUCCESS) {
+ EnterRecoveryMode();
+ }
+
+ /* Writes space, and locks it. Then attempts to write again. I really wish
+ * I could use the imperative.
+ */
+ index_0 += 1;
+ if (TlclWrite(INDEX0, (uint8_t*) &index_0,
+ sizeof(index_0) != TPM_SUCCESS)) {
+ error("could not write index 0\n");
+ }
+ TlclWriteLock(INDEX0);
+ if (TlclWrite(INDEX0, (uint8_t*) &index_0,
+ sizeof(index_0)) == TPM_SUCCESS) {
+ error("index 0 is not locked\n");
+ }
+
+ /* Done for now.
+ */
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/tpm_lite/startup.c b/tests/tpm_lite/startup.c
index 532ba8dd..3d901f39 100644
--- a/tests/tpm_lite/startup.c
+++ b/tests/tpm_lite/startup.c
@@ -11,22 +11,22 @@
#include "tlcl.h"
int main(int argc, char** argv) {
- uint32_t result;
- TlclLibInit();
- result = TlclStartup();
- if (result != 0) {
- printf("tpm startup failed with 0x%x\n", result);
- }
- result = TlclGetFlags(NULL, NULL, NULL);
- if (result != 0) {
- printf("tpm getflags failed with 0x%x\n", result);
- }
- printf("executing SelfTestFull\n");
- TlclSelfTestFull();
- result = TlclGetFlags(NULL, NULL, NULL);
- if (result != 0) {
- printf("tpm getflags failed with 0x%x\n", result);
- }
- printf("TEST SUCCEEDED\n");
- return 0;
+ uint32_t result;
+ TlclLibInit();
+ result = TlclStartup();
+ if (result != 0) {
+ printf("tpm startup failed with 0x%x\n", result);
+ }
+ result = TlclGetFlags(NULL, NULL, NULL);
+ if (result != 0) {
+ printf("tpm getflags failed with 0x%x\n", result);
+ }
+ printf("executing SelfTestFull\n");
+ TlclSelfTestFull();
+ result = TlclGetFlags(NULL, NULL, NULL);
+ if (result != 0) {
+ printf("tpm getflags failed with 0x%x\n", result);
+ }
+ printf("TEST SUCCEEDED\n");
+ return 0;
}
diff --git a/tests/tpm_lite/tlcl_tests.c b/tests/tpm_lite/tlcl_tests.c
index f36021f9..c164f4fe 100644
--- a/tests/tpm_lite/tlcl_tests.c
+++ b/tests/tpm_lite/tlcl_tests.c
@@ -14,16 +14,16 @@
const char* resilient_startup = NULL;
uint32_t TlclStartupIfNeeded(void) {
- static char* null_getenv = "some string"; /* just a unique address */
- uint32_t result = TlclStartup();
- if (resilient_startup == NULL) {
- resilient_startup = getenv("TLCL_RESILIENT_STARTUP");
- if (resilient_startup == NULL) {
- resilient_startup = null_getenv;
- }
- }
- if (resilient_startup == null_getenv) {
- return result;
- }
- return result == TPM_E_INVALID_POSTINIT ? TPM_SUCCESS : result;
+ static char* null_getenv = "some string"; /* just a unique address */
+ uint32_t result = TlclStartup();
+ if (resilient_startup == NULL) {
+ resilient_startup = getenv("TLCL_RESILIENT_STARTUP");
+ if (resilient_startup == NULL) {
+ resilient_startup = null_getenv;
+ }
+ }
+ if (resilient_startup == null_getenv) {
+ return result;
+ }
+ return result == TPM_E_INVALID_POSTINIT ? TPM_SUCCESS : result;
}
diff --git a/tests/tpm_lite/tlcl_tests.h b/tests/tpm_lite/tlcl_tests.h
index 5e23ee39..2b6bd6b8 100644
--- a/tests/tpm_lite/tlcl_tests.h
+++ b/tests/tpm_lite/tlcl_tests.h
@@ -16,14 +16,14 @@
/* Prints error and returns on failure */
#define TPM_CHECK(tpm_command) TPM_EXPECT(tpm_command, TPM_SUCCESS)
-#define TPM_EXPECT(tpm_command, expected_result) do { \
- uint32_t _result = (tpm_command); \
- uint32_t _exp = (expected_result); \
- if (_result != _exp) { \
- printf("TEST FAILED: line %d: " #tpm_command ": 0x%x" \
- " (expecting 0x%x)\n", __LINE__, _result, _exp); \
- return _result; \
- } \
+#define TPM_EXPECT(tpm_command, expected_result) do { \
+ uint32_t _result = (tpm_command); \
+ uint32_t _exp = (expected_result); \
+ if (_result != _exp) { \
+ printf("TEST FAILED: line %d: " #tpm_command ": 0x%x" \
+ " (expecting 0x%x)\n", __LINE__, _result, _exp); \
+ return _result; \
+ } \
} while (0)
diff --git a/tests/tpm_lite/tpmtest_earlyextend.c b/tests/tpm_lite/tpmtest_earlyextend.c
index 837960c1..8bab8afd 100644
--- a/tests/tpm_lite/tpmtest_earlyextend.c
+++ b/tests/tpm_lite/tpmtest_earlyextend.c
@@ -14,13 +14,13 @@
#include "tlcl_tests.h"
int main(int argc, char** argv) {
- uint8_t value_in[20];
- uint8_t value_out[20];
+ uint8_t value_in[20];
+ uint8_t value_out[20];
- TlclLibInit();
- TPM_CHECK(TlclStartup());
- TPM_CHECK(TlclContinueSelfTest());
- TPM_CHECK(TlclExtend(1, value_in, value_out));
- printf("TEST SUCCEEDED\n");
- exit(0);
+ TlclLibInit();
+ TPM_CHECK(TlclStartup());
+ TPM_CHECK(TlclContinueSelfTest());
+ TPM_CHECK(TlclExtend(1, value_in, value_out));
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/tpm_lite/tpmtest_earlynvram.c b/tests/tpm_lite/tpmtest_earlynvram.c
index fa458338..d5ff77f5 100644
--- a/tests/tpm_lite/tpmtest_earlynvram.c
+++ b/tests/tpm_lite/tpmtest_earlynvram.c
@@ -17,13 +17,13 @@
#define INDEX0 0xcafe
int main(int argc, char** argv) {
- uint32_t x;
+ uint32_t x;
- TlclLibInit();
- TPM_CHECK(TlclStartup());
- TPM_CHECK(TlclContinueSelfTest());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
- printf("TEST SUCCEEDED\n");
- return 0;
+ TlclLibInit();
+ TPM_CHECK(TlclStartup());
+ TPM_CHECK(TlclContinueSelfTest());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
+ printf("TEST SUCCEEDED\n");
+ return 0;
}
diff --git a/tests/tpm_lite/tpmtest_earlynvram2.c b/tests/tpm_lite/tpmtest_earlynvram2.c
index 2bd2d712..88f6a6b4 100644
--- a/tests/tpm_lite/tpmtest_earlynvram2.c
+++ b/tests/tpm_lite/tpmtest_earlynvram2.c
@@ -15,13 +15,13 @@
#include "utility.h"
int main(int argc, char** argv) {
- uint32_t x;
+ uint32_t x;
- TlclLibInit();
- TPM_CHECK(TlclStartup());
- TPM_CHECK(TlclContinueSelfTest());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)));
- printf("TEST SUCCEEDED\n");
- return 0;
+ TlclLibInit();
+ TPM_CHECK(TlclStartup());
+ TPM_CHECK(TlclContinueSelfTest());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)));
+ printf("TEST SUCCEEDED\n");
+ return 0;
}
diff --git a/tests/tpm_lite/tpmtest_enable.c b/tests/tpm_lite/tpmtest_enable.c
index 9163ca17..645cd467 100644
--- a/tests/tpm_lite/tpmtest_enable.c
+++ b/tests/tpm_lite/tpmtest_enable.c
@@ -14,21 +14,21 @@
int main(int argc, char** argv) {
- uint8_t disable, deactivated;
+ uint8_t disable, deactivated;
- TlclLibInit();
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclSelfTestFull());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
- printf("disable is %d, deactivated is %d\n", disable, deactivated);
- TPM_CHECK(TlclSetEnable());
- TPM_CHECK(TlclSetDeactivated(0));
- TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
- printf("disable is %d, deactivated is %d\n", disable, deactivated);
- if (disable == 1 || deactivated == 1) {
- VbExError("failed to enable or activate");
- }
- printf("TEST SUCCEEDED\n");
- return 0;
+ TlclLibInit();
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
+ TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
+ if (disable == 1 || deactivated == 1) {
+ VbExError("failed to enable or activate");
+ }
+ printf("TEST SUCCEEDED\n");
+ return 0;
}
diff --git a/tests/tpm_lite/tpmtest_fastenable.c b/tests/tpm_lite/tpmtest_fastenable.c
index 821658ca..72989c1d 100644
--- a/tests/tpm_lite/tpmtest_fastenable.c
+++ b/tests/tpm_lite/tpmtest_fastenable.c
@@ -19,28 +19,28 @@
#include "tlcl_tests.h"
int main(int argc, char** argv) {
- uint8_t disable, deactivated;
- int i;
+ uint8_t disable, deactivated;
+ int i;
- TlclLibInit();
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclSelfTestFull());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
- printf("disable is %d, deactivated is %d\n", disable, deactivated);
+ TlclLibInit();
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
- for (i = 0; i < 2; i++) {
- TPM_CHECK(TlclForceClear());
- TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
- printf("disable is %d, deactivated is %d\n", disable, deactivated);
- VbAssert(disable == 1 && deactivated == 1);
- TPM_CHECK(TlclSetEnable());
- TPM_CHECK(TlclSetDeactivated(0));
- TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
- printf("disable is %d, deactivated is %d\n", disable, deactivated);
- VbAssert(disable == 0 && deactivated == 0);
- }
+ for (i = 0; i < 2; i++) {
+ TPM_CHECK(TlclForceClear());
+ TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
+ VbAssert(disable == 1 && deactivated == 1);
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
+ TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
+ VbAssert(disable == 0 && deactivated == 0);
+ }
- printf("TEST SUCCEEDED\n");
- return 0;
+ printf("TEST SUCCEEDED\n");
+ return 0;
}
diff --git a/tests/tpm_lite/tpmtest_globallock.c b/tests/tpm_lite/tpmtest_globallock.c
index 96fad9df..2e728524 100644
--- a/tests/tpm_lite/tpmtest_globallock.c
+++ b/tests/tpm_lite/tpmtest_globallock.c
@@ -15,39 +15,41 @@
#include "tlcl_tests.h"
int main(int argc, char** argv) {
- uint32_t zero = 0;
- uint32_t x;
-
- TlclLibInit();
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclSelfTestFull());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
- TPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &zero, sizeof(uint32_t)));
- TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
- TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &zero, sizeof(uint32_t)));
- TPM_CHECK(TlclSetGlobalLock());
-
- // Verifies that write to index0 fails.
- x = 1;
- TPM_EXPECT(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), TPM_E_AREA_LOCKED);
- TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
- VbAssert(x == 0);
-
- // Verifies that write to index1 is still possible.
- x = 2;
- TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)));
- TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
- VbAssert(x == 2);
-
- // Turns off PP.
- TlclLockPhysicalPresence();
-
- // Verifies that write to index1 fails.
- x = 3;
- TPM_EXPECT(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)), TPM_E_BAD_PRESENCE);
- TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
- VbAssert(x == 2);
- printf("TEST SUCCEEDED\n");
- exit(0);
+ uint32_t zero = 0;
+ uint32_t x;
+
+ TlclLibInit();
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
+ TPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &zero, sizeof(uint32_t)));
+ TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
+ TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &zero, sizeof(uint32_t)));
+ TPM_CHECK(TlclSetGlobalLock());
+
+ // Verifies that write to index0 fails.
+ x = 1;
+ TPM_EXPECT(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)),
+ TPM_E_AREA_LOCKED);
+ TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
+ VbAssert(x == 0);
+
+ // Verifies that write to index1 is still possible.
+ x = 2;
+ TPM_CHECK(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)));
+ TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
+ VbAssert(x == 2);
+
+ // Turns off PP.
+ TlclLockPhysicalPresence();
+
+ // Verifies that write to index1 fails.
+ x = 3;
+ TPM_EXPECT(TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)),
+ TPM_E_BAD_PRESENCE);
+ TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
+ VbAssert(x == 2);
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/tpm_lite/tpmtest_redefine_unowned.c b/tests/tpm_lite/tpmtest_redefine_unowned.c
index c54e1178..522d999f 100644
--- a/tests/tpm_lite/tpmtest_redefine_unowned.c
+++ b/tests/tpm_lite/tpmtest_redefine_unowned.c
@@ -15,49 +15,49 @@
#include "tlcl_tests.h"
int main(int argc, char** argv) {
- uint32_t perm;
- uint32_t x;
+ uint32_t perm;
+ uint32_t x;
- TlclLibInit();
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclSelfTestFull());
- TPM_CHECK(TlclAssertPhysicalPresence());
+ TlclLibInit();
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
- VbAssert(!TlclIsOwned());
+ VbAssert(!TlclIsOwned());
- /* Ensures spaces exist. */
- TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
- TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
+ /* Ensures spaces exist. */
+ TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
+ TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
- /* Redefines spaces a couple of times. */
- perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
- TPM_CHECK(TlclDefineSpace(INDEX0, perm, 2 * sizeof(uint32_t)));
- TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
+ /* Redefines spaces a couple of times. */
+ perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
+ TPM_CHECK(TlclDefineSpace(INDEX0, perm, 2 * sizeof(uint32_t)));
+ TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
- perm = TPM_NV_PER_PPWRITE;
- TPM_CHECK(TlclDefineSpace(INDEX1, perm, 2 * sizeof(uint32_t)));
- TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
+ perm = TPM_NV_PER_PPWRITE;
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, 2 * sizeof(uint32_t)));
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
- // Sets the global lock.
- TlclSetGlobalLock();
+ // Sets the global lock.
+ TlclSetGlobalLock();
- // Verifies that index0 cannot be redefined.
- TPM_EXPECT(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)),
- TPM_E_AREA_LOCKED);
+ // Verifies that index0 cannot be redefined.
+ TPM_EXPECT(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)),
+ TPM_E_AREA_LOCKED);
- // Checks that index1 can.
- TPM_CHECK(TlclDefineSpace(INDEX1, perm, 2 * sizeof(uint32_t)));
- TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
+ // Checks that index1 can.
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, 2 * sizeof(uint32_t)));
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
- // Turns off PP.
- TlclLockPhysicalPresence();
+ // Turns off PP.
+ TlclLockPhysicalPresence();
- // Verifies that neither index0 nor index1 can be redefined.
- TPM_EXPECT(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)),
- TPM_E_BAD_PRESENCE);
- TPM_EXPECT(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)),
- TPM_E_BAD_PRESENCE);
+ // Verifies that neither index0 nor index1 can be redefined.
+ TPM_EXPECT(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)),
+ TPM_E_BAD_PRESENCE);
+ TPM_EXPECT(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)),
+ TPM_E_BAD_PRESENCE);
- printf("TEST SUCCEEDED\n");
- exit(0);
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/tpm_lite/tpmtest_spaceperm.c b/tests/tpm_lite/tpmtest_spaceperm.c
index 71a65218..c2608e4b 100644
--- a/tests/tpm_lite/tpmtest_spaceperm.c
+++ b/tests/tpm_lite/tpmtest_spaceperm.c
@@ -18,19 +18,19 @@
#define PERMPP TPM_NV_PER_PPWRITE
int main(int argc, char** argv) {
- uint32_t perm;
+ uint32_t perm;
- TlclLibInit();
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclContinueSelfTest());
- TPM_CHECK(TlclAssertPhysicalPresence());
+ TlclLibInit();
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclContinueSelfTest());
+ TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclGetPermissions(INDEX0, &perm));
- VbAssert((perm & PERMPPGL) == PERMPPGL);
+ TPM_CHECK(TlclGetPermissions(INDEX0, &perm));
+ VbAssert((perm & PERMPPGL) == PERMPPGL);
- TPM_CHECK(TlclGetPermissions(INDEX1, &perm));
- VbAssert((perm & PERMPP) == PERMPP);
+ TPM_CHECK(TlclGetPermissions(INDEX1, &perm));
+ VbAssert((perm & PERMPP) == PERMPP);
- printf("TEST SUCCEEDED\n");
- exit(0);
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/tpm_lite/tpmtest_testsetup.c b/tests/tpm_lite/tpmtest_testsetup.c
index fac1951e..ce360994 100644
--- a/tests/tpm_lite/tpmtest_testsetup.c
+++ b/tests/tpm_lite/tpmtest_testsetup.c
@@ -15,31 +15,31 @@
#include "utility.h"
int main(int argc, char** argv) {
- uint32_t perm;
- uint32_t result;
- uint32_t x;
-
- TlclLibInit();
-
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclSelfTestFull());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclForceClear());
- TPM_CHECK(TlclSetEnable());
- TPM_CHECK(TlclSetDeactivated(0));
-
- result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
- if (result == TPM_E_BADINDEX) {
- perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
- TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
- }
-
- result = TlclRead(INDEX1, (uint8_t*) &x, sizeof(x));
- if (result == TPM_E_BADINDEX) {
- perm = TPM_NV_PER_PPWRITE;
- TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
- }
-
- printf("TEST SUCCEEDED\n");
- exit(0);
+ uint32_t perm;
+ uint32_t result;
+ uint32_t x;
+
+ TlclLibInit();
+
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclForceClear());
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
+
+ result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
+ if (result == TPM_E_BADINDEX) {
+ perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
+ TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
+ }
+
+ result = TlclRead(INDEX1, (uint8_t*) &x, sizeof(x));
+ if (result == TPM_E_BADINDEX) {
+ perm = TPM_NV_PER_PPWRITE;
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
+ }
+
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/tpm_lite/tpmtest_timing.c b/tests/tpm_lite/tpmtest_timing.c
index 677b533b..d86b4eee 100644
--- a/tests/tpm_lite/tpmtest_timing.c
+++ b/tests/tpm_lite/tpmtest_timing.c
@@ -21,48 +21,48 @@
/* Runs [op] and ensures it returns success and doesn't run longer than
* [time_limit] in milliseconds.
*/
-#define TTPM_CHECK(op, time_limit) do { \
- struct timeval before, after; \
- int time; \
- uint32_t __result; \
- gettimeofday(&before, NULL); \
- __result = op; \
- if (__result != TPM_SUCCESS) { \
- printf(#op ": error 0x%x\n", __result); \
- errors++; \
- } \
- gettimeofday(&after, NULL); \
- time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \
- (after.tv_usec - before.tv_usec) / 1000); \
- printf(#op ": %d ms\n", time); \
- if (time > time_limit) { \
- printf(#op " exceeded " #time_limit " ms\n"); \
- time_limit_exceeded = 1; \
- } \
- } while (0)
+#define TTPM_CHECK(op, time_limit) do { \
+ struct timeval before, after; \
+ int time; \
+ uint32_t __result; \
+ gettimeofday(&before, NULL); \
+ __result = op; \
+ if (__result != TPM_SUCCESS) { \
+ printf(#op ": error 0x%x\n", __result); \
+ errors++; \
+ } \
+ gettimeofday(&after, NULL); \
+ time = (int) ((after.tv_sec - before.tv_sec) * 1000 + \
+ (after.tv_usec - before.tv_usec) / 1000); \
+ printf(#op ": %d ms\n", time); \
+ if (time > time_limit) { \
+ printf(#op " exceeded " #time_limit " ms\n"); \
+ time_limit_exceeded = 1; \
+ } \
+} while (0)
int main(int argc, char** argv) {
- uint32_t x;
- uint8_t in[20], out[20];
- int time_limit_exceeded = 0;
- int errors = 0;
+ uint32_t x;
+ uint8_t in[20], out[20];
+ int time_limit_exceeded = 0;
+ int errors = 0;
- TlclLibInit();
- TTPM_CHECK(0, 50);
- TTPM_CHECK(TlclStartupIfNeeded(), 50);
- TTPM_CHECK(TlclContinueSelfTest(), 100);
- TTPM_CHECK(TlclSelfTestFull(), 1000);
- TTPM_CHECK(TlclAssertPhysicalPresence(), 100);
- TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
- TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
- TTPM_CHECK(TlclExtend(0, in, out), 200);
- TTPM_CHECK(TlclSetGlobalLock(), 50);
- TTPM_CHECK(TlclLockPhysicalPresence(), 100);
- if (time_limit_exceeded || errors > 0) {
- printf("TEST FAILED\n");
- exit(1);
- } else {
- printf("TEST SUCCEEDED\n");
- return 0;
- }
+ TlclLibInit();
+ TTPM_CHECK(0, 50);
+ TTPM_CHECK(TlclStartupIfNeeded(), 50);
+ TTPM_CHECK(TlclContinueSelfTest(), 100);
+ TTPM_CHECK(TlclSelfTestFull(), 1000);
+ TTPM_CHECK(TlclAssertPhysicalPresence(), 100);
+ TTPM_CHECK(TlclWrite(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
+ TTPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)), 100);
+ TTPM_CHECK(TlclExtend(0, in, out), 200);
+ TTPM_CHECK(TlclSetGlobalLock(), 50);
+ TTPM_CHECK(TlclLockPhysicalPresence(), 100);
+ if (time_limit_exceeded || errors > 0) {
+ printf("TEST FAILED\n");
+ exit(1);
+ } else {
+ printf("TEST SUCCEEDED\n");
+ return 0;
+ }
}
diff --git a/tests/tpm_lite/tpmtest_writelimit.c b/tests/tpm_lite/tpmtest_writelimit.c
index 952033cb..66dcc036 100644
--- a/tests/tpm_lite/tpmtest_writelimit.c
+++ b/tests/tpm_lite/tpmtest_writelimit.c
@@ -17,40 +17,42 @@
#define TPM_MAX_NV_WRITES_NOOWNER 64
int main(int argc, char** argv) {
- int i;
-
- uint32_t result;
-
- TlclLibInit();
-
- TPM_CHECK(TlclStartupIfNeeded());
- TPM_CHECK(TlclSelfTestFull());
- TPM_CHECK(TlclAssertPhysicalPresence());
- TPM_CHECK(TlclForceClear());
- TPM_CHECK(TlclSetEnable());
- TPM_CHECK(TlclSetDeactivated(0));
-
- for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
- printf("writing %d\n", i);
- if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) {
- switch (result) {
- case TPM_E_MAXNVWRITES:
- VbAssert(i >= TPM_MAX_NV_WRITES_NOOWNER);
- break;
- default:
- VbExError("unexpected error code %d (0x%x)\n", result, result);
- }
- }
- }
-
- /* Reset write count */
- TPM_CHECK(TlclForceClear());
- TPM_CHECK(TlclSetEnable());
- TPM_CHECK(TlclSetDeactivated(0));
-
- /* Try writing again. */
- TPM_CHECK(TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i)));
-
- printf("TEST SUCCEEDED\n");
- exit(0);
+ int i;
+
+ uint32_t result;
+
+ TlclLibInit();
+
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+ TPM_CHECK(TlclForceClear());
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
+
+ for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
+ printf("writing %d\n", i);
+ if ((result = TlclWrite(INDEX0, (uint8_t*)&i,
+ sizeof(i))) != TPM_SUCCESS) {
+ switch (result) {
+ case TPM_E_MAXNVWRITES:
+ VbAssert(i >= TPM_MAX_NV_WRITES_NOOWNER);
+ break;
+ default:
+ VbExError("unexpected error code %d (0x%x)\n",
+ result, result);
+ }
+ }
+ }
+
+ /* Reset write count */
+ TPM_CHECK(TlclForceClear());
+ TPM_CHECK(TlclSetEnable());
+ TPM_CHECK(TlclSetDeactivated(0));
+
+ /* Try writing again. */
+ TPM_CHECK(TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i)));
+
+ printf("TEST SUCCEEDED\n");
+ exit(0);
}
diff --git a/tests/utility_string_tests.c b/tests/utility_string_tests.c
index d7601931..add1e640 100644
--- a/tests/utility_string_tests.c
+++ b/tests/utility_string_tests.c
@@ -17,103 +17,109 @@
/* Test string concatenation */
static void StrncatTest(void) {
- char dest[128];
-
- /* Null inputs */
- TEST_EQ(0, StrnAppend(dest, NULL, sizeof(dest)), "StrnAppend('', null)");
- TEST_EQ(0, StrnAppend(NULL, "Hey!", sizeof(dest)), "StrnAppend(null, '')");
-
- /* Empty <-- empty */
- *dest = 0;
- TEST_EQ(0, StrnAppend(dest, "", sizeof(dest)), "StrnAppend('', '')");
- TEST_EQ(0, strcmp(dest, ""), "StrnAppend('', '') result");
-
- /* Nonempty <-- empty */
- strcpy(dest, "Bob");
- TEST_EQ(3, StrnAppend(dest, "", sizeof(dest)), "StrnAppend(B, '')");
- TEST_EQ(0, strcmp(dest, "Bob"), "StrnAppend(B, '') result");
-
- /* Empty <-- nonempty */
- *dest = 0;
- TEST_EQ(5, StrnAppend(dest, "Alice", sizeof(dest)), "StrnAppend('', A)");
- TEST_EQ(0, strcmp(dest, "Alice"), "StrnAppend('', A) result");
-
- /* Nonempty <-- nonempty */
- strcpy(dest, "Tigre");
- TEST_EQ(10, StrnAppend(dest, "Bunny", sizeof(dest)), "StrnAppend(T, B)");
- TEST_EQ(0, strcmp(dest, "TigreBunny"), "StrnAppend(T, B) result");
-
- /* Test clipping */
- strcpy(dest, "YesI");
- TEST_EQ(7, StrnAppend(dest, "Can't", 8), "StrnAppend(Y, over)");
- TEST_EQ(0, strcmp(dest, "YesICan"), "StrnAppend(Y, over) result");
-
- /* Test clipping if dest already overflows its claimed length */
- strcpy(dest, "BudgetDeficit");
- TEST_EQ(6, StrnAppend(dest, "Spending", 7), "StrnAppend(over, over)");
- TEST_EQ(0, strcmp(dest, "Budget"), "StrnAppend(over, over) result");
+ char dest[128];
+
+ /* Null inputs */
+ TEST_EQ(0, StrnAppend(dest, NULL, sizeof(dest)),
+ "StrnAppend('', null)");
+ TEST_EQ(0, StrnAppend(NULL, "Hey!", sizeof(dest)),
+ "StrnAppend(null, '')");
+
+ /* Empty <-- empty */
+ *dest = 0;
+ TEST_EQ(0, StrnAppend(dest, "", sizeof(dest)), "StrnAppend('', '')");
+ TEST_EQ(0, strcmp(dest, ""), "StrnAppend('', '') result");
+
+ /* Nonempty <-- empty */
+ strcpy(dest, "Bob");
+ TEST_EQ(3, StrnAppend(dest, "", sizeof(dest)), "StrnAppend(B, '')");
+ TEST_EQ(0, strcmp(dest, "Bob"), "StrnAppend(B, '') result");
+
+ /* Empty <-- nonempty */
+ *dest = 0;
+ TEST_EQ(5, StrnAppend(dest, "Alice", sizeof(dest)),
+ "StrnAppend('', A)");
+ TEST_EQ(0, strcmp(dest, "Alice"), "StrnAppend('', A) result");
+
+ /* Nonempty <-- nonempty */
+ strcpy(dest, "Tigre");
+ TEST_EQ(10, StrnAppend(dest, "Bunny", sizeof(dest)),
+ "StrnAppend(T, B)");
+ TEST_EQ(0, strcmp(dest, "TigreBunny"), "StrnAppend(T, B) result");
+
+ /* Test clipping */
+ strcpy(dest, "YesI");
+ TEST_EQ(7, StrnAppend(dest, "Can't", 8), "StrnAppend(Y, over)");
+ TEST_EQ(0, strcmp(dest, "YesICan"), "StrnAppend(Y, over) result");
+
+ /* Test clipping if dest already overflows its claimed length */
+ strcpy(dest, "BudgetDeficit");
+ TEST_EQ(6, StrnAppend(dest, "Spending", 7), "StrnAppend(over, over)");
+ TEST_EQ(0, strcmp(dest, "Budget"), "StrnAppend(over, over) result");
}
static void TestU64ToS(uint64_t value, uint32_t radix, uint32_t zero_pad_width,
- const char *expect) {
- char dest[UINT64_TO_STRING_MAX];
-
- TEST_EQ(strlen(expect),
- Uint64ToString(dest, sizeof(dest), value, radix, zero_pad_width),
- "Uint64ToString");
- printf("Uint64ToString expect %s got %s\n", expect, dest);
- TEST_EQ(0, strcmp(dest, expect), "Uint64ToString result");
+ const char *expect) {
+ char dest[UINT64_TO_STRING_MAX];
+
+ TEST_EQ(strlen(expect),
+ Uint64ToString(dest, sizeof(dest), value, radix,
+ zero_pad_width),
+ "Uint64ToString");
+ printf("Uint64ToString expect %s got %s\n", expect, dest);
+ TEST_EQ(0, strcmp(dest, expect), "Uint64ToString result");
}
/* Test uint64 to string conversion */
static void Uint64ToStringTest(void) {
- char dest[UINT64_TO_STRING_MAX];
-
- /* Test invalid inputs */
- TEST_EQ(0, Uint64ToString(NULL, 8, 123, 10, 8), "Uint64ToString null dest");
- TestU64ToS(0, 1, 0, "");
- TestU64ToS(0, 37, 0, "");
-
- /* Binary */
- TestU64ToS(0, 2, 0, "0");
- TestU64ToS(0x9A, 2, 0, "10011010");
- TestU64ToS(0x71, 2, 12, "000001110001");
- TestU64ToS(
- ~0ULL, 2, 0,
- "1111111111111111111111111111111111111111111111111111111111111111");
-
- /* Decimal */
- TestU64ToS(0, 10, 0, "0");
- TestU64ToS(12345, 10, 0, "12345");
- TestU64ToS(67890, 10, 8, "00067890");
- TestU64ToS(~0ULL, 10, 0, "18446744073709551615");
-
- /* Hex */
- TestU64ToS(0, 16, 0, "0");
- TestU64ToS(0x12345678, 16, 0, "12345678");
- TestU64ToS(0x9ABCDEF, 16, 8, "09abcdef");
- TestU64ToS(~0ULL, 16, 0, "ffffffffffffffff");
-
- /* Zero pad corner cases */
- /* Don't pad if over length */
- TestU64ToS(0x1234567890ULL, 16, 8, "1234567890");
- /* Fail if padding won't fit in buffer */
- TEST_EQ(0, Uint64ToString(dest, 8, 123, 10, 8), "Uint64ToString bad pad");
- TEST_EQ(0, strcmp(dest, ""), "Uint64ToString bad pad result");
+ char dest[UINT64_TO_STRING_MAX];
+
+ /* Test invalid inputs */
+ TEST_EQ(0, Uint64ToString(NULL, 8, 123, 10, 8),
+ "Uint64ToString null dest");
+ TestU64ToS(0, 1, 0, "");
+ TestU64ToS(0, 37, 0, "");
+
+ /* Binary */
+ TestU64ToS(0, 2, 0, "0");
+ TestU64ToS(0x9A, 2, 0, "10011010");
+ TestU64ToS(0x71, 2, 12, "000001110001");
+ TestU64ToS(~0ULL, 2, 0,
+ "1111111111111111111111111111111111111111111111111111111111111111");
+
+ /* Decimal */
+ TestU64ToS(0, 10, 0, "0");
+ TestU64ToS(12345, 10, 0, "12345");
+ TestU64ToS(67890, 10, 8, "00067890");
+ TestU64ToS(~0ULL, 10, 0, "18446744073709551615");
+
+ /* Hex */
+ TestU64ToS(0, 16, 0, "0");
+ TestU64ToS(0x12345678, 16, 0, "12345678");
+ TestU64ToS(0x9ABCDEF, 16, 8, "09abcdef");
+ TestU64ToS(~0ULL, 16, 0, "ffffffffffffffff");
+
+ /* Zero pad corner cases */
+ /* Don't pad if over length */
+ TestU64ToS(0x1234567890ULL, 16, 8, "1234567890");
+ /* Fail if padding won't fit in buffer */
+ TEST_EQ(0, Uint64ToString(dest, 8, 123, 10, 8),
+ "Uint64ToString bad pad");
+ TEST_EQ(0, strcmp(dest, ""), "Uint64ToString bad pad result");
}
int main(int argc, char* argv[]) {
- int error_code = 0;
+ int error_code = 0;
- StrncatTest();
- Uint64ToStringTest();
+ StrncatTest();
+ Uint64ToStringTest();
- if (!gTestSuccess)
- error_code = 255;
+ if (!gTestSuccess)
+ error_code = 255;
- return error_code;
+ return error_code;
}
diff --git a/tests/vb21_host_key_tests.c b/tests/vb21_host_key_tests.c
index a833a003..c90fd40e 100644
--- a/tests/vb21_host_key_tests.c
+++ b/tests/vb21_host_key_tests.c
@@ -281,7 +281,7 @@ static void public_key_tests(const struct alg_combo *combo,
}
static int test_algorithm(const struct alg_combo *combo, const char *keys_dir,
- const char *temp_dir)
+ const char *temp_dir)
{
int rsa_bits = vb2_rsa_sig_size(combo->sig_alg) * 8;
char *pemfile;
diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
index 7e67e07d..31428a4b 100644
--- a/tests/vboot_api_devmode_tests.c
+++ b/tests/vboot_api_devmode_tests.c
@@ -56,7 +56,7 @@ test_case_t test[] = {
0, 0,
1,
{
- {0, 0, 2000}, // off and return at 2 seconds
+ {0, 0, 2000}, // off and return at 2 seconds
}},
{ "VbBootDeveloperSoundTest( normal )",
@@ -64,9 +64,9 @@ test_case_t test[] = {
0, 0,
3,
{
- {250, 400, 20000}, // first beep at 20 seconds
- {250, 400, 20510}, // second beep shortly after
- {0, 0, 30020}, // off and return at 30 seconds
+ {250, 400, 20000}, // first beep at 20 seconds
+ {250, 400, 20510}, // second beep shortly after
+ {0, 0, 30020}, // off and return at 30 seconds
}},
// Now with some keypresses
@@ -76,8 +76,8 @@ test_case_t test[] = {
4, 20400, // Ctrl-D between beeps
2,
{
- {250, 400, 20000}, // first beep at 20 seconds
- {0, 0, 20400}, // sees Ctrl-D, sound off, return
+ {250, 400, 20000}, // first beep at 20 seconds
+ {0, 0, 20400}, // sees Ctrl-D, sound off, return
}},
{ "VbBootDeveloperSoundTest( normal, Ctrl-U not allowed )",
@@ -85,11 +85,11 @@ test_case_t test[] = {
21, 10000, // Ctrl-U at 10 seconds
5,
{
- {120, 400, 10000}, // complains about Ctrl-U (one beep)
- {120, 400, 10240}, // complains about Ctrl-U (two beeps)
- {250, 400, 20000}, // starts first beep at 20 seconds
- {250, 400, 20510}, // starts second beep
- {0, 0, 30020}, // returns at 30 seconds + 360ms
+ {120, 400, 10000}, // complains about Ctrl-U (one beep)
+ {120, 400, 10240}, // complains about Ctrl-U (two beeps)
+ {250, 400, 20000}, // starts first beep at 20 seconds
+ {250, 400, 20510}, // starts second beep
+ {0, 0, 30020}, // returns at 30 seconds + 360ms
}},
};
@@ -156,25 +156,25 @@ VbError_t VbExNvStorageWrite(const uint8_t* buf)
}
VbError_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count,
- uint32_t disk_flags)
+ uint32_t disk_flags)
{
return VBERROR_UNKNOWN;
}
VbError_t VbExDiskFreeInfo(VbDiskInfo* infos,
- VbExDiskHandle_t preserve_handle)
+ VbExDiskHandle_t preserve_handle)
{
return VBERROR_SUCCESS;
}
VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, void* buffer)
+ uint64_t lba_count, void* buffer)
{
return VBERROR_UNKNOWN;
}
VbError_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, const void* buffer)
+ uint64_t lba_count, const void* buffer)
{
return VBERROR_UNKNOWN;
}
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index b9e05157..11c4c2f6 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -139,7 +139,7 @@ int VbExLegacy(void)
}
VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
- uint32_t disk_flags)
+ uint32_t disk_flags)
{
if (mock_num_disks_count < ARRAY_SIZE(mock_num_disks)) {
if (mock_num_disks[mock_num_disks_count] == -1)
@@ -153,7 +153,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
}
VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
- VbExDiskHandle_t preserve_handle)
+ VbExDiskHandle_t preserve_handle)
{
return VBERROR_SUCCESS;
}
@@ -218,7 +218,7 @@ static void VbUserConfirmsTest(void)
mock_keypress[0] = ' ';
shutdown_request_calls_left = 1;
TEST_EQ(VbUserConfirms(&ctx, VB_CONFIRM_SPACE_MEANS_NO), 0,
- "Space means no");
+ "Space means no");
ResetMocks();
mock_keypress[0] = ' ';
diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c
index 133a778f..06d7d695 100644
--- a/tests/vboot_api_kernel_tests.c
+++ b/tests/vboot_api_kernel_tests.c
@@ -263,7 +263,7 @@ int is_nonzero(const void *vptr, size_t count)
/* Mocked verification functions */
VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
- uint32_t disk_flags)
+ uint32_t disk_flags)
{
int i;
int num_disks = 0;
@@ -311,7 +311,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
}
VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
- VbExDiskHandle_t preserve_handle)
+ VbExDiskHandle_t preserve_handle)
{
got_load_disk = (const char *)preserve_handle;
VB2_DEBUG("%s(): got_load_disk = %s\n", __FUNCTION__,
diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c
index f494dc91..264fbf86 100644
--- a/tests/vboot_detach_menu_tests.c
+++ b/tests/vboot_detach_menu_tests.c
@@ -2003,7 +2003,7 @@ static void VbTestLanguageMenu(void)
TEST_EQ(screens_count, i, " no extra screens");
TEST_EQ(beeps_count, 0, " no beeps");
- printf("...done.\n");
+ printf("...done.\n");
}
static void VbNavigationTest(void)
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c
index c9907597..a5922eda 100644
--- a/tests/vboot_kernel_tests.c
+++ b/tests/vboot_kernel_tests.c
@@ -190,7 +190,7 @@ static void ResetMocks(void)
/* Mocks */
VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
- uint64_t lba_count, void *buffer)
+ uint64_t lba_count, void *buffer)
{
LOGCALL("VbExDiskRead(h, %d, %d)\n", (int)lba_start, (int)lba_count);
@@ -352,11 +352,11 @@ static void ReadWriteGptTest(void)
TEST_EQ(AllocAndReadGptData(handle, &g), 0,
"AllocAndRead primary invalid");
TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.streaming_drive_sectors,
- g.gpt_drive_sectors, 0, g.sector_bytes),
- 1, "Primary header is invalid");
+ g.gpt_drive_sectors, 0, g.sector_bytes),
+ 1, "Primary header is invalid");
TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 0, "Secondary header is valid");
+ 0, "Secondary header is valid");
TEST_CALLS("VbExDiskRead(h, 1, 1)\n"
"VbExDiskRead(h, 1023, 1)\n"
"VbExDiskRead(h, 991, 32)\n");
@@ -372,10 +372,10 @@ static void ReadWriteGptTest(void)
"AllocAndRead secondary invalid");
TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 0, "Primary header is valid");
+ 0, "Primary header is valid");
TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 1, "Secondary header is invalid");
+ 1, "Secondary header is invalid");
TEST_CALLS("VbExDiskRead(h, 1, 1)\n"
"VbExDiskRead(h, 2, 32)\n"
"VbExDiskRead(h, 1023, 1)\n");
@@ -392,10 +392,10 @@ static void ReadWriteGptTest(void)
"AllocAndRead primary and secondary invalid");
TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 1, "Primary header is invalid");
+ 1, "Primary header is invalid");
TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 1, "Secondary header is invalid");
+ 1, "Secondary header is invalid");
TEST_CALLS("VbExDiskRead(h, 1, 1)\n"
"VbExDiskRead(h, 1023, 1)\n");
WriteAndFreeGptData(handle, &g);
@@ -423,7 +423,7 @@ static void ReadWriteGptTest(void)
"VbExDiskWrite(h, 2, 32)\n");
TEST_EQ(CheckHeader(mock_gpt_primary, 0, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 0, "Fix Primary GPT: Primary header is valid");
+ 0, "Fix Primary GPT: Primary header is valid");
/*
* Invalidate secondary GPT header and check that it can be
@@ -448,7 +448,7 @@ static void ReadWriteGptTest(void)
"VbExDiskWrite(h, 991, 32)\n");
TEST_EQ(CheckHeader(mock_gpt_secondary, 1, g.streaming_drive_sectors,
g.gpt_drive_sectors, 0, g.sector_bytes),
- 0, "Fix Secondary GPT: Secondary header is valid");
+ 0, "Fix Secondary GPT: Secondary header is valid");
/* Data which is changed is written */
ResetMocks();