diff options
Diffstat (limited to 'firmware/2lib/include')
-rw-r--r-- | firmware/2lib/include/2api.h | 85 | ||||
-rw-r--r-- | firmware/2lib/include/2common.h | 19 | ||||
-rw-r--r-- | firmware/2lib/include/2gbb.h | 14 | ||||
-rw-r--r-- | firmware/2lib/include/2misc.h | 27 | ||||
-rw-r--r-- | firmware/2lib/include/2nvstorage.h | 2 | ||||
-rw-r--r-- | firmware/2lib/include/2rsa.h | 8 | ||||
-rw-r--r-- | firmware/2lib/include/2secdata.h | 24 | ||||
-rw-r--r-- | firmware/2lib/include/2sha.h | 27 |
8 files changed, 95 insertions, 111 deletions
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h index 487616d4..98f9ff08 100644 --- a/firmware/2lib/include/2api.h +++ b/firmware/2lib/include/2api.h @@ -404,7 +404,7 @@ enum vb2_pcr_digest { * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2api_secdata_check(const struct vb2_context *ctx); +vb2_error_t vb2api_secdata_check(const struct vb2_context *ctx); /** * Create fresh data in the secure storage context. @@ -420,7 +420,7 @@ int vb2api_secdata_check(const struct vb2_context *ctx); * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2api_secdata_create(struct vb2_context *ctx); +vb2_error_t vb2api_secdata_create(struct vb2_context *ctx); /** * Check the CRC of the kernel version secure storage context. @@ -434,7 +434,7 @@ int vb2api_secdata_create(struct vb2_context *ctx); * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2api_secdatak_check(const struct vb2_context *ctx); +vb2_error_t vb2api_secdatak_check(const struct vb2_context *ctx); /** * Create fresh data in the kernel version secure storage context. @@ -450,7 +450,7 @@ int vb2api_secdatak_check(const struct vb2_context *ctx); * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2api_secdatak_create(struct vb2_context *ctx); +vb2_error_t vb2api_secdatak_create(struct vb2_context *ctx); /** * Report firmware failure to vboot. @@ -478,7 +478,7 @@ void vb2api_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2api_fw_phase1(struct vb2_context *ctx); +vb2_error_t vb2api_fw_phase1(struct vb2_context *ctx); /** * Firmware selection, phase 2. @@ -489,7 +489,7 @@ int vb2api_fw_phase1(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2api_fw_phase2(struct vb2_context *ctx); +vb2_error_t vb2api_fw_phase2(struct vb2_context *ctx); /** * Firmware selection, phase 3. @@ -503,12 +503,12 @@ int vb2api_fw_phase2(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2api_fw_phase3(struct vb2_context *ctx); +vb2_error_t vb2api_fw_phase3(struct vb2_context *ctx); /** * Same, but for new-style structs. */ -int vb21api_fw_phase3(struct vb2_context *ctx); +vb2_error_t vb21api_fw_phase3(struct vb2_context *ctx); /** * Initialize hashing data for the specified tag. @@ -519,14 +519,14 @@ int vb21api_fw_phase3(struct vb2_context *ctx); * stored here on output. * @return VB2_SUCCESS, or error code on error. */ -int vb2api_init_hash(struct vb2_context *ctx, uint32_t tag, uint32_t *size); +vb2_error_t vb2api_init_hash(struct vb2_context *ctx, uint32_t tag, + uint32_t *size); /** * Same, but for new-style structs. */ -int vb21api_init_hash(struct vb2_context *ctx, - const struct vb2_id *id, - uint32_t *size); +vb2_error_t vb21api_init_hash(struct vb2_context *ctx, const struct vb2_id *id, + uint32_t *size); /** * Extend the hash started by vb2api_init_hash() with additional data. @@ -538,9 +538,8 @@ int vb21api_init_hash(struct vb2_context *ctx, * @param size Size of data in bytes * @return VB2_SUCCESS, or error code on error. */ -int vb2api_extend_hash(struct vb2_context *ctx, - const void *buf, - uint32_t size); +vb2_error_t vb2api_extend_hash(struct vb2_context *ctx, const void *buf, + uint32_t size); /** * Check the hash value started by vb2api_init_hash(). @@ -553,7 +552,7 @@ int vb2api_check_hash(struct vb2_context *ctx); /** * Same, but for new-style structs. */ -int vb21api_check_hash(struct vb2_context *ctx); +vb2_error_t vb21api_check_hash(struct vb2_context *ctx); /** * Check the hash value started by vb2api_init_hash() while retrieving @@ -564,8 +563,9 @@ int vb21api_check_hash(struct vb2_context *ctx); * @param digest_out_size optional size of buffer to store digest * @return VB2_SUCCESS, or error code on error. */ -int vb2api_check_hash_get_digest(struct vb2_context *ctx, void *digest_out, - uint32_t digest_out_size); +vb2_error_t vb2api_check_hash_get_digest(struct vb2_context *ctx, + void *digest_out, + uint32_t digest_out_size); /** * Get a PCR digest @@ -578,10 +578,9 @@ int vb2api_check_hash_get_digest(struct vb2_context *ctx, void *digest_out, * OUT: size of the copied digest * @return VB2_SUCCESS, or error code on error */ -int vb2api_get_pcr_digest(struct vb2_context *ctx, - enum vb2_pcr_digest which_digest, - uint8_t *dest, - uint32_t *dest_size); +vb2_error_t vb2api_get_pcr_digest(struct vb2_context *ctx, + enum vb2_pcr_digest which_digest, + uint8_t *dest, uint32_t *dest_size); /** * Prepare for kernel verification stage. @@ -591,7 +590,7 @@ int vb2api_get_pcr_digest(struct vb2_context *ctx, * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2api_kernel_phase1(struct vb2_context *ctx); +vb2_error_t vb2api_kernel_phase1(struct vb2_context *ctx); /** * Load the verified boot block (vblock) for a kernel. @@ -603,7 +602,7 @@ int vb2api_kernel_phase1(struct vb2_context *ctx); * @param stream Kernel stream * @return VB2_SUCCESS, or error code on error. */ -int vb2api_load_kernel_vblock(struct vb2_context *ctx); +vb2_error_t vb2api_load_kernel_vblock(struct vb2_context *ctx); /** * Get the size and offset of the kernel data for the most recent vblock. @@ -616,9 +615,8 @@ int vb2api_load_kernel_vblock(struct vb2_context *ctx); * @param size_ptr Destination for size of kernel data in bytes. * @return VB2_SUCCESS, or error code on error. */ -int vb2api_get_kernel_size(struct vb2_context *ctx, - uint32_t *offset_ptr, - uint32_t *size_ptr); +vb2_error_t vb2api_get_kernel_size(struct vb2_context *ctx, + uint32_t *offset_ptr, uint32_t *size_ptr); /** * Verify kernel data using the previously loaded kernel vblock. @@ -632,9 +630,8 @@ int vb2api_get_kernel_size(struct vb2_context *ctx, * @param size Size of kernel data in bytes * @return VB2_SUCCESS, or error code on error. */ -int vb2api_verify_kernel_data(struct vb2_context *ctx, - const void *buf, - uint32_t size); +vb2_error_t vb2api_verify_kernel_data(struct vb2_context *ctx, const void *buf, + uint32_t size); /** * Clean up after kernel verification. @@ -645,7 +642,7 @@ int vb2api_verify_kernel_data(struct vb2_context *ctx, * This cleans up intermediate data structures in the vboot context, and * updates the version in the secure data if necessary. */ -int vb2api_kernel_phase3(struct vb2_context *ctx); +vb2_error_t vb2api_kernel_phase3(struct vb2_context *ctx); /** * Read the hardware ID from the GBB, and store it onto the given buffer. @@ -660,9 +657,8 @@ int vb2api_kernel_phase3(struct vb2_context *ctx); * also including null terminator. * @return VB2_SUCCESS, or error code on error. */ -int vb2api_gbb_read_hwid(struct vb2_context *ctx, - char *hwid, - uint32_t *size); +vb2_error_t vb2api_gbb_read_hwid(struct vb2_context *ctx, char *hwid, + uint32_t *size); /** * Retrieve current GBB flags. @@ -684,7 +680,7 @@ vb2_gbb_flags_t vb2api_gbb_get_flags(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2ex_tpm_clear_owner(struct vb2_context *ctx); +vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx); /** * Read a verified boot resource. @@ -696,11 +692,9 @@ int vb2ex_tpm_clear_owner(struct vb2_context *ctx); * @param size Amount of data to read * @return VB2_SUCCESS, or error code on error. */ -int vb2ex_read_resource(struct vb2_context *ctx, - enum vb2_resource_index index, - uint32_t offset, - void *buf, - uint32_t size); +vb2_error_t vb2ex_read_resource(struct vb2_context *ctx, + enum vb2_resource_index index, uint32_t offset, + void *buf, uint32_t size); /** * Print debug output @@ -723,8 +717,8 @@ void vb2ex_printf(const char *func, const char *fmt, ...); * @param data_size Expected total size of data to hash * @return VB2_SUCCESS, or non-zero error code (HWCRYPTO_UNSUPPORTED not fatal). */ -int vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg, - uint32_t data_size); +vb2_error_t vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg, + uint32_t data_size); /** * Extend the hash in the hardware crypto engine with another block of data. @@ -733,7 +727,7 @@ int vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg, * @param size Length of data block in bytes * @return VB2_SUCCESS, or non-zero error code. */ -int vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size); +vb2_error_t vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size); /** * Finalize the digest in the hardware crypto engine and extract the result. @@ -742,7 +736,8 @@ int vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size); * @param digest_size Length of digest buffer in bytes * @return VB2_SUCCESS, or non-zero error code. */ -int vb2ex_hwcrypto_digest_finalize(uint8_t *digest, uint32_t digest_size); +vb2_error_t vb2ex_hwcrypto_digest_finalize(uint8_t *digest, + uint32_t digest_size); /* * Set the current TPM mode value, and validate that it was changed. If one @@ -757,6 +752,6 @@ int vb2ex_hwcrypto_digest_finalize(uint8_t *digest, uint32_t digest_size); * or DISABLED from vb2_tpm_mode enum. * @returns VB2_SUCCESS, or non-zero error code. */ -int vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val); +vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val); #endif /* VBOOT_2_API_H_ */ diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h index 7cd8c041..f0df9c0b 100644 --- a/firmware/2lib/include/2common.h +++ b/firmware/2lib/include/2common.h @@ -111,8 +111,7 @@ void *vb2_workbuf_alloc(struct vb2_workbuf *wb, uint32_t size); * @param newsize Requested size in bytes * @return A pointer to the allocated space, or NULL if error. */ -void *vb2_workbuf_realloc(struct vb2_workbuf *wb, - uint32_t oldsize, +void *vb2_workbuf_realloc(struct vb2_workbuf *wb, uint32_t oldsize, uint32_t newsize); /** @@ -143,7 +142,7 @@ void vb2_workbuf_free(struct vb2_workbuf *wb, uint32_t size); * @param size Number of bytes to compare * @return 0 if match or size=0, non-zero if at least one byte mismatched. */ -int vb2_safe_memcmp(const void *s1, const void *s2, size_t size); +vb2_error_t vb2_safe_memcmp(const void *s1, const void *s2, size_t size); /** * Align a buffer and check its size. @@ -154,10 +153,8 @@ int vb2_safe_memcmp(const void *s1, const void *s2, size_t size); * @param want_size Required size * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_align(uint8_t **ptr, - uint32_t *size, - uint32_t align, - uint32_t want_size); +vb2_error_t vb2_align(uint8_t **ptr, uint32_t *size, uint32_t align, + uint32_t want_size); /** * Return offset of ptr from base. @@ -233,10 +230,10 @@ const struct vb2_id *vb2_hash_id(enum vb2_hash_algorithm hash_alg); * @param member_data_size Size of member data in bytes * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_verify_member_inside(const void *parent, size_t parent_size, - const void *member, size_t member_size, - ptrdiff_t member_data_offset, - size_t member_data_size); +vb2_error_t vb2_verify_member_inside(const void *parent, size_t parent_size, + const void *member, size_t member_size, + ptrdiff_t member_data_offset, + size_t member_data_size); /* * Helper function to get data pointed to by a public key. diff --git a/firmware/2lib/include/2gbb.h b/firmware/2lib/include/2gbb.h index 6ad0eb3b..4e4bd906 100644 --- a/firmware/2lib/include/2gbb.h +++ b/firmware/2lib/include/2gbb.h @@ -24,10 +24,9 @@ struct vb2_workbuf; * @param wb Workbuf for data storage. * @return VB2_SUCCESS, or error code on error. */ -int vb2_gbb_read_root_key(struct vb2_context *ctx, - struct vb2_packed_key **keyp, - uint32_t *size, - struct vb2_workbuf *wb); +vb2_error_t vb2_gbb_read_root_key(struct vb2_context *ctx, + struct vb2_packed_key **keyp, uint32_t *size, + struct vb2_workbuf *wb); /** * Read the recovery key from the GBB, and store it onto the given workbuf. @@ -40,9 +39,8 @@ int vb2_gbb_read_root_key(struct vb2_context *ctx, * @param wb Workbuf for data storage. * @return VB2_SUCCESS, or error code on error. */ -int vb2_gbb_read_recovery_key(struct vb2_context *ctx, - struct vb2_packed_key **keyp, - uint32_t *size, - struct vb2_workbuf *wb); +vb2_error_t vb2_gbb_read_recovery_key(struct vb2_context *ctx, + struct vb2_packed_key **keyp, + uint32_t *size, struct vb2_workbuf *wb); #endif /* VBOOT_REFERENCE_VBOOT_2GBB_H_ */ diff --git a/firmware/2lib/include/2misc.h b/firmware/2lib/include/2misc.h index 3e1f1000..3b61bda4 100644 --- a/firmware/2lib/include/2misc.h +++ b/firmware/2lib/include/2misc.h @@ -39,7 +39,7 @@ struct vb2_gbb_header *vb2_get_gbb(struct vb2_context *ctx); * @param sig Pointer to the signature bytes to validate * @return VB2_SUCCESS if valid or non-zero if error. */ -int vb2_validate_gbb_signature(uint8_t *sig); +vb2_error_t vb2_validate_gbb_signature(uint8_t *sig); /** * Initialize a work buffer from the vboot context. @@ -69,7 +69,8 @@ void vb2_set_workbuf_used(struct vb2_context *ctx, uint32_t used); * @param gbb Destination for header * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_read_gbb_header(struct vb2_context *ctx, struct vb2_gbb_header *gbb); +vb2_error_t vb2_read_gbb_header(struct vb2_context *ctx, + struct vb2_gbb_header *gbb); /** * Handle vboot failure. @@ -95,7 +96,7 @@ void vb2_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode); * @param ctx Vboot context to initialize * @return VB2_SUCCESS, or error code on error. */ -int vb2_init_context(struct vb2_context *ctx); +vb2_error_t vb2_init_context(struct vb2_context *ctx); /** * Check for recovery reasons we can determine early in the boot process. @@ -116,7 +117,7 @@ void vb2_check_recovery(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_fw_parse_gbb(struct vb2_context *ctx); +vb2_error_t vb2_fw_parse_gbb(struct vb2_context *ctx); /** * Check developer switch position. @@ -124,7 +125,7 @@ int vb2_fw_parse_gbb(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_check_dev_switch(struct vb2_context *ctx); +vb2_error_t vb2_check_dev_switch(struct vb2_context *ctx); /** * Check if we need to clear the TPM owner. @@ -132,7 +133,7 @@ int vb2_check_dev_switch(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_check_tpm_clear(struct vb2_context *ctx); +vb2_error_t vb2_check_tpm_clear(struct vb2_context *ctx); /** * Decide which firmware slot to try this boot. @@ -140,7 +141,7 @@ int vb2_check_tpm_clear(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_select_fw_slot(struct vb2_context *ctx); +vb2_error_t vb2_select_fw_slot(struct vb2_context *ctx); /** * Verify the firmware keyblock using the root key. @@ -150,8 +151,8 @@ int vb2_select_fw_slot(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_load_fw_keyblock(struct vb2_context *ctx); -int vb21_load_fw_keyblock(struct vb2_context *ctx); +vb2_error_t vb2_load_fw_keyblock(struct vb2_context *ctx); +vb2_error_t vb21_load_fw_keyblock(struct vb2_context *ctx); /** * Verify the firmware preamble using the data subkey from the keyblock. @@ -161,8 +162,8 @@ int vb21_load_fw_keyblock(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_load_fw_preamble(struct vb2_context *ctx); -int vb21_load_fw_preamble(struct vb2_context *ctx); +vb2_error_t vb2_load_fw_preamble(struct vb2_context *ctx); +vb2_error_t vb21_load_fw_preamble(struct vb2_context *ctx); /** * Verify the kernel keyblock using the previously-loaded kernel key. @@ -172,7 +173,7 @@ int vb21_load_fw_preamble(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_load_kernel_keyblock(struct vb2_context *ctx); +vb2_error_t vb2_load_kernel_keyblock(struct vb2_context *ctx); /** * Verify the kernel preamble using the data subkey from the keyblock. @@ -182,6 +183,6 @@ int vb2_load_kernel_keyblock(struct vb2_context *ctx); * @param ctx Vboot context * @return VB2_SUCCESS, or error code on error. */ -int vb2_load_kernel_preamble(struct vb2_context *ctx); +vb2_error_t vb2_load_kernel_preamble(struct vb2_context *ctx); #endif /* VBOOT_REFERENCE_VBOOT_2MISC_H_ */ diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h index b51cb6fa..1a6ab8ad 100644 --- a/firmware/2lib/include/2nvstorage.h +++ b/firmware/2lib/include/2nvstorage.h @@ -186,7 +186,7 @@ int vb2_nv_get_size(const struct vb2_context *ctx); * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_nv_check_crc(const struct vb2_context *ctx); +vb2_error_t vb2_nv_check_crc(const struct vb2_context *ctx); /** * Initialize the non-volatile storage context and verify its CRC. diff --git a/firmware/2lib/include/2rsa.h b/firmware/2lib/include/2rsa.h index 4357029a..0ee72ca5 100644 --- a/firmware/2lib/include/2rsa.h +++ b/firmware/2lib/include/2rsa.h @@ -7,6 +7,7 @@ #define VBOOT_REFERENCE_2RSA_H_ #include "2crypto.h" +#include "2return_codes.h" #include "2struct.h" struct vb2_workbuf; @@ -63,9 +64,8 @@ uint32_t vb2_packed_key_size(enum vb2_signature_algorithm sig_alg); * @param wb Work buffer * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_rsa_verify_digest(const struct vb2_public_key *key, - uint8_t *sig, - const uint8_t *digest, - const struct vb2_workbuf *wb); +vb2_error_t vb2_rsa_verify_digest(const struct vb2_public_key *key, + uint8_t *sig, const uint8_t *digest, + const struct vb2_workbuf *wb); #endif /* VBOOT_REFERENCE_2RSA_H_ */ diff --git a/firmware/2lib/include/2secdata.h b/firmware/2lib/include/2secdata.h index 2563b3fb..90f4bf23 100644 --- a/firmware/2lib/include/2secdata.h +++ b/firmware/2lib/include/2secdata.h @@ -99,7 +99,7 @@ enum vb2_secdatak_param { * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_secdata_init(struct vb2_context *ctx); +vb2_error_t vb2_secdata_init(struct vb2_context *ctx); /** * Read a secure storage value. @@ -109,9 +109,8 @@ int vb2_secdata_init(struct vb2_context *ctx); * @param dest Destination for value * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_secdata_get(struct vb2_context *ctx, - enum vb2_secdata_param param, - uint32_t *dest); +vb2_error_t vb2_secdata_get(struct vb2_context *ctx, + enum vb2_secdata_param param, uint32_t *dest); /** * Write a secure storage value. @@ -121,9 +120,8 @@ int vb2_secdata_get(struct vb2_context *ctx, * @param value New value * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_secdata_set(struct vb2_context *ctx, - enum vb2_secdata_param param, - uint32_t value); +vb2_error_t vb2_secdata_set(struct vb2_context *ctx, + enum vb2_secdata_param param, uint32_t value); /*****************************************************************************/ /* Kernel version space functions. @@ -140,7 +138,7 @@ int vb2_secdata_set(struct vb2_context *ctx, * @param ctx Context pointer * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_secdatak_init(struct vb2_context *ctx); +vb2_error_t vb2_secdatak_init(struct vb2_context *ctx); /** * Read a secure storage value. @@ -150,9 +148,8 @@ int vb2_secdatak_init(struct vb2_context *ctx); * @param dest Destination for value * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_secdatak_get(struct vb2_context *ctx, - enum vb2_secdatak_param param, - uint32_t *dest); +vb2_error_t vb2_secdatak_get(struct vb2_context *ctx, + enum vb2_secdatak_param param, uint32_t *dest); /** * Write a secure storage value. @@ -162,8 +159,7 @@ int vb2_secdatak_get(struct vb2_context *ctx, * @param value New value * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_secdatak_set(struct vb2_context *ctx, - enum vb2_secdatak_param param, - uint32_t value); +vb2_error_t vb2_secdatak_set(struct vb2_context *ctx, + enum vb2_secdatak_param param, uint32_t value); #endif /* VBOOT_REFERENCE_VBOOT_2SECDATA_H_ */ diff --git a/firmware/2lib/include/2sha.h b/firmware/2lib/include/2sha.h index f41d8e15..646c7c17 100644 --- a/firmware/2lib/include/2sha.h +++ b/firmware/2lib/include/2sha.h @@ -12,6 +12,7 @@ #define VBOOT_REFERENCE_2SHA_H_ #include "2crypto.h" +#include "2return_codes.h" /* Hash algorithms may be disabled individually to save code space */ @@ -158,7 +159,7 @@ enum vb2_hash_algorithm vb2_crypto_to_hash(uint32_t algorithm); * @param hash_alg Hash algorithm * @return The size of the digest, or 0 if error. */ -int vb2_digest_size(enum vb2_hash_algorithm hash_alg); +vb2_error_t vb2_digest_size(enum vb2_hash_algorithm hash_alg); /** * Return the block size of a hash algorithm. @@ -166,7 +167,7 @@ int vb2_digest_size(enum vb2_hash_algorithm hash_alg); * @param hash_alg Hash algorithm * @return The block size of the algorithm, or 0 if error. */ -int vb2_hash_block_size(enum vb2_hash_algorithm alg); +vb2_error_t vb2_hash_block_size(enum vb2_hash_algorithm alg); /** * Return the name of a hash algorithm @@ -184,8 +185,8 @@ const char *vb2_get_hash_algorithm_name(enum vb2_hash_algorithm alg); * @param hash_alg Hash algorithm * @return VB2_SUCCESS, or non-zero on error. */ -int vb2_digest_init(struct vb2_digest_context *dc, - enum vb2_hash_algorithm hash_alg); +vb2_error_t vb2_digest_init(struct vb2_digest_context *dc, + enum vb2_hash_algorithm hash_alg); /** * Extend a digest's hash with another block of data. @@ -195,9 +196,8 @@ int vb2_digest_init(struct vb2_digest_context *dc, * @param size Length of data in bytes * @return VB2_SUCCESS, or non-zero on error. */ -int vb2_digest_extend(struct vb2_digest_context *dc, - const uint8_t *buf, - uint32_t size); +vb2_error_t vb2_digest_extend(struct vb2_digest_context *dc, const uint8_t *buf, + uint32_t size); /** * Finalize a digest and store the result. @@ -209,9 +209,8 @@ int vb2_digest_extend(struct vb2_digest_context *dc, * @param digest_size Length of digest buffer in bytes. * @return VB2_SUCCESS, or non-zero on error. */ -int vb2_digest_finalize(struct vb2_digest_context *dc, - uint8_t *digest, - uint32_t digest_size); +vb2_error_t vb2_digest_finalize(struct vb2_digest_context *dc, + uint8_t *digest, uint32_t digest_size); /** * Calculate the digest of a buffer and store the result. @@ -223,10 +222,8 @@ int vb2_digest_finalize(struct vb2_digest_context *dc, * @param digest_size Length of digest buffer in bytes. * @return VB2_SUCCESS, or non-zero on error. */ -int vb2_digest_buffer(const uint8_t *buf, - uint32_t size, - enum vb2_hash_algorithm hash_alg, - uint8_t *digest, - uint32_t digest_size); +vb2_error_t vb2_digest_buffer(const uint8_t *buf, uint32_t size, + enum vb2_hash_algorithm hash_alg, uint8_t *digest, + uint32_t digest_size); #endif /* VBOOT_REFERENCE_2SHA_H_ */ |