summaryrefslogtreecommitdiff
path: root/firmware/2lib/include/2return_codes.h
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-06-05 13:32:11 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-06-07 01:37:21 +0000
commitb9be53640efdee92b1b42e60adda274563236301 (patch)
treef8f2f5ef809c7a0d163334f9e2675b016fae3ca4 /firmware/2lib/include/2return_codes.h
parentb64f097891e697eaf3b2794baae934f8b4d82d14 (diff)
downloadvboot-b9be53640efdee92b1b42e60adda274563236301.tar.gz
Error codes reported by the crypto and storage APIs are now very specific, and tests verify the proper errors are reported. More specific error codes coming to other files next, but I don't want this CL to get too long. This also changes test_common.c so TEST_EQ() reports mismatched values in both decimal and hex, and adds TEST_SUCC() to test for a successful return value. BUG=chromium:370082 BRANCH=none TEST=make clean && VBOOT2=1 COV=1 make Change-Id: I255c8e5769284fbc286b9d94631b19677a71cdd0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202778 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'firmware/2lib/include/2return_codes.h')
-rw-r--r--firmware/2lib/include/2return_codes.h98
1 files changed, 94 insertions, 4 deletions
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index 73a37b5e..28c0f91d 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -16,8 +16,93 @@ enum vb2_return_code {
/* Success - no error */
VB2_SUCCESS = 0,
+ /*
+ * All vboot2 error codes start at a large offset from zero, to reduce
+ * the risk of overlap with other error codes (TPM, etc.).
+ */
+ VB2_ERROR_BASE = 0x0100000,
+
/* Unknown / unspecified error */
- VB2_ERROR_UNKNOWN = 0x10000,
+ VB2_ERROR_UNKNOWN = VB2_ERROR_BASE + 1,
+
+ /**********************************************************************
+ * SHA errors
+ */
+ VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000,
+
+ /* Bad algorithm in vb2_digest_init() */
+ VB2_ERROR_SHA_INIT_ALGORITHM,
+
+ /* Bad algorithm in vb2_digest_extend() */
+ VB2_ERROR_SHA_EXTEND_ALGORITHM,
+
+ /* Bad algorithm in vb2_digest_finalize() */
+ VB2_ERROR_SHA_FINALIZE_ALGORITHM,
+
+ /* Digest size buffer too small in vb2_digest_finalize() */
+ VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE,
+
+ /**********************************************************************
+ * RSA errors
+ */
+ VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000,
+
+ /* Padding mismatch in vb2_check_padding() */
+ VB2_ERROR_RSA_PADDING,
+
+ /* Bad algorithm in vb2_check_padding() */
+ VB2_ERROR_RSA_PADDING_ALGORITHM,
+
+ /* Null param passed to vb2_verify_digest() */
+ VB2_ERROR_RSA_VERIFY_PARAM,
+
+ /* Bad algorithm in vb2_verify_digest() */
+ VB2_ERROR_RSA_VERIFY_ALGORITHM,
+
+ /* Bad signature length in vb2_verify_digest() */
+ VB2_ERROR_RSA_VERIFY_SIG_LEN,
+
+ /* Work buffer too small in vb2_verify_digest() */
+ VB2_ERROR_RSA_VERIFY_WORKBUF,
+
+ /* Digest mismatch in vb2_verify_digest() */
+ VB2_ERROR_RSA_VERIFY_DIGEST,
+
+ /**********************************************************************
+ * NV storage errors
+ */
+ VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000,
+
+ /* Bad header in vb2_nv_check_crc() */
+ VB2_ERROR_NV_HEADER,
+
+ /* Bad CRC in vb2_nv_check_crc() */
+ VB2_ERROR_NV_CRC,
+
+ /**********************************************************************
+ * Secure data storage errors
+ */
+ VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000,
+
+ /* Bad CRC in vb2_secdata_check_crc() */
+ VB2_ERROR_SECDATA_CRC,
+
+ /* Bad struct version in vb2_secdata_init() */
+ VB2_ERROR_SECDATA_VERSION,
+
+ /* Invalid param in vb2_secdata_get() */
+ VB2_ERROR_SECDATA_GET_PARAM,
+
+ /* Invalid param in vb2_secdata_set() */
+ VB2_ERROR_SECDATA_SET_PARAM,
+
+ /* Invalid flags passed to vb2_secdata_set() */
+ VB2_ERROR_SECDATA_SET_FLAGS,
+
+ /**********************************************************************
+ * TODO: errors which must still be made specific
+ */
+ VB2_ERROR_TODO = VB2_ERROR_BASE + 0xff0000,
/* Work buffer too small */
VB2_ERROR_WORKBUF_TOO_SMALL,
@@ -37,9 +122,6 @@ enum vb2_return_code {
/* Signature check failed */
VB2_ERROR_BAD_SIGNATURE,
- /* Bad secure data */
- VB2_ERROR_BAD_SECDATA,
-
/* Bad key */
VB2_ERROR_BAD_KEY,
@@ -57,6 +139,14 @@ enum vb2_return_code {
/* Bad hash tag */
VB2_ERROR_BAD_TAG,
+
+ /**********************************************************************
+ * 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.
+ */
+ VB2_ERROR_MAX = VB2_ERROR_BASE + 0xffffff,
+
};
#endif /* VBOOT_2_RETURN_CODES_H_ */