flashupdate: Use libhoth_error for key_rotation

libhoth commit ce5c230d64 (PR #266) and PR #276 replaced enum
key_rotation_err (KEY_ROTATION_CMD_SUCCESS) and int return codes with
libhoth_error (LIBHOTH_OK / LIBHOTH_ERR_FAIL) in protocol/key_rotation.h
and transports/libhoth_dbus.h.

Update key_rotate_helper.cpp and its unit test mocks to use
libhoth_error and LIBHOTH_OK.

Tested: Built flashupdate and obmc-phosphor-image against libhoth
5597928508.
Fusion-Link: fusion2 N/A (build fix for libhoth API update)
Google-Bug-Id: 493681862
Signed-off-by: Manan J. Mehta <mjmehta@google.com>
Change-Id: Ia8343362fdf53e7c85d8562c209d8baa01d4e4d8
diff --git a/subprojects/flashupdate/src/validator/key_rotate_helper.cpp b/subprojects/flashupdate/src/validator/key_rotate_helper.cpp
index a20ad26..2fe6c01 100644
--- a/subprojects/flashupdate/src/validator/key_rotate_helper.cpp
+++ b/subprojects/flashupdate/src/validator/key_rotate_helper.cpp
@@ -42,8 +42,8 @@
     }
 
     struct libhoth_dbus_device_init_options opts = {.hoth_id = HothId.c_str()};
-    int rv = libhoth_dbus_open(&opts, &hoth_device);
-    if (rv)
+    libhoth_error rv = libhoth_dbus_open(&opts, &hoth_device);
+    if (rv != LIBHOTH_OK)
     {
         LOG(flashupdate::LogLevel::Error, "libhoth_dbus_open failed {}", rv);
         return nullptr;
@@ -72,12 +72,12 @@
     struct libhoth_device* hoth_device, uint32_t chunk_typecode)
 {
     uint16_t chunk_count = 0;
-    enum key_rotation_err ret_code = libhoth_key_rotation_chunk_type_count(
+    libhoth_error ret_code = libhoth_key_rotation_chunk_type_count(
         hoth_device, chunk_typecode, &chunk_count);
-    if (ret_code)
+    if (ret_code != LIBHOTH_OK)
     {
         LOG(flashupdate::LogLevel::Error, "Get {} chunk count failed: {}",
-            rotConfigChunkName(chunk_typecode), std::to_underlying(ret_code));
+            rotConfigChunkName(chunk_typecode), ret_code);
         return -1;
     }
     return chunk_count;
@@ -218,15 +218,14 @@
     struct hoth_response_key_rotation_record_read* read_response,
     size_t expected_data_size, uint16_t* response_size)
 {
-    enum key_rotation_err ret_read = libhoth_key_rotation_read_chunk_type(
+    libhoth_error ret_read = libhoth_key_rotation_read_chunk_type(
         hoth_device, chunk_typecode, chunk_index,
         sizeof(key_rotation_chunk_header) /* skip the trunk header */,
         0 /* read whole chunk data */, read_response, response_size);
-    if (ret_read)
+    if (ret_read != LIBHOTH_OK)
     {
         LOG(flashupdate::LogLevel::Error, "Read {}_{} failed: ({})",
-            rotConfigChunkName(chunk_typecode), chunk_index,
-            static_cast<int>(ret_read));
+            rotConfigChunkName(chunk_typecode), chunk_index, ret_read);
         return false;
     }
     // To be backward compatible allow in the future appending new fields in
@@ -516,17 +515,16 @@
 
             uint32_t version = 0;
             struct hoth_response_key_rotation_record_version record_version;
-            enum key_rotation_err version_err =
+            libhoth_error version_err =
                 libhoth_key_rotation_get_version(hoth_device, &record_version);
-            if (version_err == KEY_ROTATION_CMD_SUCCESS)
+            if (version_err == LIBHOTH_OK)
             {
                 version = record_version.version;
             }
             else
             {
                 LOG(flashupdate::LogLevel::Error,
-                    "Get key rotation version failed: {}",
-                    static_cast<int>(version_err));
+                    "Get key rotation version failed: {}", version_err);
             }
 
             uint64_t val_key_data = 0;
diff --git a/subprojects/flashupdate/test/validator/key_rotate_helper.cpp b/subprojects/flashupdate/test/validator/key_rotate_helper.cpp
index 0f21131..c93fc72 100644
--- a/subprojects/flashupdate/test/validator/key_rotate_helper.cpp
+++ b/subprojects/flashupdate/test/validator/key_rotate_helper.cpp
@@ -37,19 +37,19 @@
 {
   public:
     virtual ~MockApi() = default;
-    MOCK_METHOD(int, libhoth_dbus_open,
+    MOCK_METHOD(libhoth_error, libhoth_dbus_open,
                 (const struct libhoth_dbus_device_init_options* opts,
                  struct libhoth_device** hoth_device));
-    MOCK_METHOD(enum key_rotation_err, libhoth_key_rotation_chunk_type_count,
+    MOCK_METHOD(libhoth_error, libhoth_key_rotation_chunk_type_count,
                 (struct libhoth_device * hoth_device, uint32_t chunk_typecode,
                  uint16_t* chunk_count));
-    MOCK_METHOD(enum key_rotation_err, libhoth_key_rotation_read_chunk_type,
+    MOCK_METHOD(libhoth_error, libhoth_key_rotation_read_chunk_type,
                 (struct libhoth_device * dev, uint32_t chunk_typecode,
                  uint32_t chunk_index, uint16_t offset, uint16_t size,
                  struct hoth_response_key_rotation_record_read* read_response,
                  uint16_t* response_size));
     MOCK_METHOD(
-        enum key_rotation_err, libhoth_key_rotation_get_version,
+        libhoth_error, libhoth_key_rotation_get_version,
         (struct libhoth_device * dev,
          struct hoth_response_key_rotation_record_version* record_version));
     MOCK_METHOD(int, hash_init, (void* ctx, enum hash_type type));
@@ -63,17 +63,18 @@
 // C function trampolines to the mock object
 extern "C"
 {
-int libhoth_dbus_open(const struct libhoth_dbus_device_init_options* opts,
+libhoth_error
+    libhoth_dbus_open(const struct libhoth_dbus_device_init_options* opts,
                       struct libhoth_device** hoth_device)
 {
     if (mock_api)
     {
         return mock_api->libhoth_dbus_open(opts, hoth_device);
     }
-    return -1; // Should not happen in tests
+    return LIBHOTH_ERR_FAIL; // Should not happen in tests
 }
 
-enum key_rotation_err libhoth_key_rotation_chunk_type_count(
+libhoth_error libhoth_key_rotation_chunk_type_count(
     struct libhoth_device* hoth_device, uint32_t chunk_typecode,
     uint16_t* chunk_count)
 {
@@ -82,10 +83,10 @@
         return mock_api->libhoth_key_rotation_chunk_type_count(
             hoth_device, chunk_typecode, chunk_count);
     }
-    return KEY_ROTATION_ERR;
+    return LIBHOTH_ERR_FAIL;
 }
 
-enum key_rotation_err libhoth_key_rotation_read_chunk_type(
+libhoth_error libhoth_key_rotation_read_chunk_type(
     struct libhoth_device* dev, uint32_t chunk_typecode, uint32_t chunk_index,
     uint16_t offset, uint16_t size,
     struct hoth_response_key_rotation_record_read* read_response,
@@ -97,10 +98,10 @@
             dev, chunk_typecode, chunk_index, offset, size, read_response,
             response_size);
     }
-    return KEY_ROTATION_ERR;
+    return LIBHOTH_ERR_FAIL;
 }
 
-enum key_rotation_err libhoth_key_rotation_get_version(
+libhoth_error libhoth_key_rotation_get_version(
     struct libhoth_device* dev,
     struct hoth_response_key_rotation_record_version* record_version)
 {
@@ -108,7 +109,7 @@
     {
         return mock_api->libhoth_key_rotation_get_version(dev, record_version);
     }
-    return KEY_ROTATION_ERR;
+    return LIBHOTH_ERR_FAIL;
 }
 
 int hash_init(void* ctx, enum hash_type type)
@@ -181,7 +182,8 @@
                     return strcmp(opts->hoth_id, id.c_str()) == 0;
                 }),
             _))
-        .WillOnce(Return(-1)); // Return error to not cache the device.
+        .WillOnce(
+            Return(LIBHOTH_ERR_FAIL)); // Return error to not cache the device.
     sha256 hash{};
     trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                         sizeof(hash));
@@ -197,7 +199,8 @@
 TEST_F(KeyRotateHelperTest, TrustDescriptorHashHothOpenFails)
 {
     sha256 hash{};
-    EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _)).WillOnce(Return(-1));
+    EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _))
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
     EXPECT_FALSE(trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                                      sizeof(hash)));
 }
@@ -220,7 +223,7 @@
         // triggered by the first test that calls hothDevice().
         EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _))
             .WillOnce(DoAll(SetArgPointee<1>(dummy_hoth_device_for_suite),
-                            Return(0)));
+                            Return(LIBHOTH_OK)));
     }
 
     // TearDownTestSuite is called once after all tests in this suite are run.
@@ -247,7 +250,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BASH, _))
-        .WillOnce(Return(KEY_ROTATION_ERR));
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
 
     EXPECT_FALSE(trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                                      sizeof(hash)));
@@ -259,7 +262,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BASH, _))
-        .WillOnce(DoAll(SetArgPointee<2>(0), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(0), Return(LIBHOTH_OK)));
 
     EXPECT_FALSE(trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                                      sizeof(hash)));
@@ -280,14 +283,13 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BASH, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
     EXPECT_CALL(*mock_api,
                 libhoth_key_rotation_read_chunk_type(
                     dummy_hoth_device_for_suite,
                     KEY_ROTATION_CHUNK_TYPE_CODE_BASH, 0, _, _, _, _))
-        .WillOnce(
-            DoAll(SetArgPointee<5>(response), SetArgPointee<6>(response_size),
-                  Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<5>(response),
+                        SetArgPointee<6>(response_size), Return(LIBHOTH_OK)));
     EXPECT_TRUE(trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                                     sizeof(hash)));
 }
@@ -300,7 +302,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BASH, _))
-        .WillOnce(DoAll(SetArgPointee<2>(3), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(3), Return(LIBHOTH_OK)));
 
     // Setup for first chunk (non-matching)
     struct hoth_response_key_rotation_record_read non_matching_response = {};
@@ -320,7 +322,7 @@
                                sizeof(key_rotation_chunk_header), 0, _, _))
         .WillOnce(DoAll(SetArgPointee<5>(non_matching_response),
                         SetArgPointee<6>(non_matching_response_size),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+                        Return(LIBHOTH_OK)));
 
     // Setup for second chunk (matching)
     struct hoth_response_key_rotation_record_read matching_response = {};
@@ -338,7 +340,7 @@
                                sizeof(key_rotation_chunk_header), 0, _, _))
         .WillOnce(DoAll(SetArgPointee<5>(matching_response),
                         SetArgPointee<6>(matching_response_size),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+                        Return(LIBHOTH_OK)));
 
     EXPECT_TRUE(trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                                     sizeof(hash)));
@@ -352,7 +354,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BASH, _))
-        .WillOnce(DoAll(SetArgPointee<2>(3), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(3), Return(LIBHOTH_OK)));
 
     // Setup for first and second chunks (non-matching)
     for (int i = 0; i < 2; ++i)
@@ -375,7 +377,7 @@
                         KEY_ROTATION_CHUNK_TYPE_CODE_BASH, i, _, _, _, _))
             .WillOnce(DoAll(SetArgPointee<5>(non_matching_response),
                             SetArgPointee<6>(non_matching_response_size),
-                            Return(KEY_ROTATION_CMD_SUCCESS)));
+                            Return(LIBHOTH_OK)));
     }
 
     // Setup for third chunk (matching)
@@ -394,7 +396,7 @@
                                sizeof(key_rotation_chunk_header), 0, _, _))
         .WillOnce(DoAll(SetArgPointee<5>(matching_response),
                         SetArgPointee<6>(matching_response_size),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+                        Return(LIBHOTH_OK)));
 
     EXPECT_TRUE(trustDescriptorHash(nullptr, reinterpret_cast<uint8_t*>(&hash),
                                     sizeof(hash)));
@@ -451,7 +453,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
     struct hoth_response_key_rotation_record_read response = {};
     struct bios_verifiction_key_fingerprint* trusted_key =
         reinterpret_cast<struct bios_verifiction_key_fingerprint*>(
@@ -465,16 +467,14 @@
                 libhoth_key_rotation_read_chunk_type(
                     dummy_hoth_device_for_suite,
                     KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, 0, _, _, _, _))
-        .WillOnce(
-            DoAll(SetArgPointee<5>(response), SetArgPointee<6>(response_size),
-                  Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<5>(response),
+                        SetArgPointee<6>(response_size), Return(LIBHOTH_OK)));
 
     struct hoth_response_key_rotation_record_version record_version = {
         .version = 16};
     EXPECT_CALL(*mock_api, libhoth_key_rotation_get_version(
                                dummy_hoth_device_for_suite, _))
-        .WillOnce(DoAll(SetArgPointee<1>(record_version),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<1>(record_version), Return(LIBHOTH_OK)));
 
     // Clean up any existing files before the test
     std::error_code ec;
@@ -538,7 +538,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
     struct hoth_response_key_rotation_record_read response = {};
     struct bios_verifiction_key_fingerprint* trusted_key =
         reinterpret_cast<struct bios_verifiction_key_fingerprint*>(
@@ -553,9 +553,8 @@
                 libhoth_key_rotation_read_chunk_type(
                     dummy_hoth_device_for_suite,
                     KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, 0, _, _, _, _))
-        .WillOnce(
-            DoAll(SetArgPointee<5>(response), SetArgPointee<6>(response_size),
-                  Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<5>(response),
+                        SetArgPointee<6>(response_size), Return(LIBHOTH_OK)));
     EXPECT_FALSE(trustKeyInCr51Signature(&dummy_ctx, SIGNATURE_RSA4096_PKCS15,
                                          &sig, sizeof(sig)));
 }
@@ -578,7 +577,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(3), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(3), Return(LIBHOTH_OK)));
 
     // Setup for first chunk (non-matching)
     struct hoth_response_key_rotation_record_read non_matching_response = {};
@@ -597,7 +596,7 @@
                                sizeof(key_rotation_chunk_header), 0, _, _))
         .WillOnce(DoAll(SetArgPointee<5>(non_matching_response),
                         SetArgPointee<6>(non_matching_response_size),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+                        Return(LIBHOTH_OK)));
 
     // Setup for second chunk (matching)
     struct hoth_response_key_rotation_record_read matching_response = {};
@@ -615,12 +614,12 @@
                                sizeof(key_rotation_chunk_header), 0, _, _))
         .WillOnce(DoAll(SetArgPointee<5>(matching_response),
                         SetArgPointee<6>(matching_response_size),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+                        Return(LIBHOTH_OK)));
 
     // Mock get_version failure to cover the version fallback path
     EXPECT_CALL(*mock_api, libhoth_key_rotation_get_version(
                                dummy_hoth_device_for_suite, _))
-        .WillOnce(Return(KEY_ROTATION_ERR));
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
 
     // Clean up any existing files before the test
     std::error_code ec;
@@ -685,7 +684,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(3), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(3), Return(LIBHOTH_OK)));
 
     // Setup for first and second chunks (non-matching)
     for (int i = 0; i < 2; ++i)
@@ -707,7 +706,7 @@
                         KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, i, _, _, _, _))
             .WillOnce(DoAll(SetArgPointee<5>(non_matching_response),
                             SetArgPointee<6>(non_matching_response_size),
-                            Return(KEY_ROTATION_CMD_SUCCESS)));
+                            Return(LIBHOTH_OK)));
     }
 
     // Setup for third chunk (matching)
@@ -726,12 +725,12 @@
                                sizeof(key_rotation_chunk_header), 0, _, _))
         .WillOnce(DoAll(SetArgPointee<5>(matching_response),
                         SetArgPointee<6>(matching_response_size),
-                        Return(KEY_ROTATION_CMD_SUCCESS)));
+                        Return(LIBHOTH_OK)));
 
     // Mock get_version failure to cover the version fallback path
     EXPECT_CALL(*mock_api, libhoth_key_rotation_get_version(
                                dummy_hoth_device_for_suite, _))
-        .WillOnce(Return(KEY_ROTATION_ERR));
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
 
     EXPECT_TRUE(trustKeyInCr51Signature(&dummy_ctx, SIGNATURE_RSA4096_PKCS15,
                                         &sig, sizeof(sig)));
@@ -741,7 +740,8 @@
 {
     sha256 hash{};
     // It should return true even if the underlying function returns false.
-    EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _)).WillOnce(Return(-1));
+    EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _))
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
     EXPECT_TRUE(alwaysTrustDescriptorHash(
         nullptr, reinterpret_cast<uint8_t*>(&hash), sizeof(hash)));
 }
@@ -771,14 +771,13 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BASH, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
     EXPECT_CALL(*mock_api,
                 libhoth_key_rotation_read_chunk_type(
                     dummy_hoth_device_for_suite,
                     KEY_ROTATION_CHUNK_TYPE_CODE_BASH, 0, _, _, _, _))
-        .WillOnce(
-            DoAll(SetArgPointee<5>(response), SetArgPointee<6>(response_size),
-                  Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<5>(response),
+                        SetArgPointee<6>(response_size), Return(LIBHOTH_OK)));
 
     EXPECT_FALSE(neverTrustDescriptorHash(
         nullptr, reinterpret_cast<uint8_t*>(&hash), sizeof(hash)));
@@ -788,7 +787,8 @@
 {
     // This test must run before any test that successfully opens a hoth device
     // due to the static hoth_device cache in the production code.
-    EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _)).WillOnce(Return(-1));
+    EXPECT_CALL(*mock_api, libhoth_dbus_open(_, _))
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
 
     EXPECT_FALSE(isBiosKeyRotationSupport());
 
@@ -807,7 +807,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(Return(KEY_ROTATION_ERR));
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
     EXPECT_FALSE(isBiosKeyRotationSupport());
 }
 
@@ -816,7 +816,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
     EXPECT_TRUE(isBiosKeyRotationSupport());
 }
 
@@ -847,7 +847,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
 
     // Call isBiosKeyRotationSupport, which should clear the files
     EXPECT_TRUE(isBiosKeyRotationSupport());
@@ -865,7 +865,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(0), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(0), Return(LIBHOTH_OK)));
 
     // Clean up any existing files before the test
     std::error_code ec;
@@ -927,7 +927,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(Return(KEY_ROTATION_ERR));
+        .WillOnce(Return(LIBHOTH_ERR_FAIL));
 
     // Clean up any existing files before the test
     std::error_code ec;
@@ -965,7 +965,7 @@
     EXPECT_CALL(*mock_api, libhoth_key_rotation_chunk_type_count(
                                dummy_hoth_device_for_suite,
                                KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, _))
-        .WillOnce(DoAll(SetArgPointee<2>(1), Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<2>(1), Return(LIBHOTH_OK)));
 
     struct hoth_response_key_rotation_record_read response = {};
     struct bios_verifiction_key_fingerprint* trusted_key =
@@ -982,9 +982,8 @@
                 libhoth_key_rotation_read_chunk_type(
                     dummy_hoth_device_for_suite,
                     KEY_ROTATION_CHUNK_TYPE_CODE_BKEY, 0, _, _, _, _))
-        .WillOnce(
-            DoAll(SetArgPointee<5>(response), SetArgPointee<6>(response_size),
-                  Return(KEY_ROTATION_CMD_SUCCESS)));
+        .WillOnce(DoAll(SetArgPointee<5>(response),
+                        SetArgPointee<6>(response_size), Return(LIBHOTH_OK)));
 
     // Clean up any existing files before the test
     std::error_code ec;