diff options
| author | Seth Moore <sethmo@google.com> | 2021-06-25 14:20:15 -0700 |
|---|---|---|
| committer | Seth Moore <sethmo@google.com> | 2021-06-30 09:32:08 -0700 |
| commit | 23f624599f4f72b9e07a051104ccbfcaaaeda3d9 (patch) | |
| tree | 776c023df21ad2222062ac48211748ffef2f13dc /security/keymint/support/remote_prov_utils_test.cpp | |
| parent | ba831331399e310d53f766920f16a8da062b0f2a (diff) | |
Add a utility to JSON-format a CSR with build info
We need both the build fingerprint as well as the CSR when uploading
data to the APFE provisioning server. Add a utility function to format
the output as a JSON blob so that it may be easily collected in the
factory in a serialized data format, then later uploaded.
Test: libkeymint_remote_prov_support_test
Test: VtsAidlKeyMintTargetTest
Test: VtsHalRemotelyProvisionedComponentTargetTest
Bug: 191301285
Change-Id: I751c5461876d83251869539f1a395ba13cb5cf84
Diffstat (limited to 'security/keymint/support/remote_prov_utils_test.cpp')
| -rw-r--r-- | security/keymint/support/remote_prov_utils_test.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/security/keymint/support/remote_prov_utils_test.cpp b/security/keymint/support/remote_prov_utils_test.cpp index c360c0650..8697c5190 100644 --- a/security/keymint/support/remote_prov_utils_test.cpp +++ b/security/keymint/support/remote_prov_utils_test.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <android-base/properties.h> #include <cppbor_parse.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -23,6 +24,7 @@ #include <openssl/curve25519.h> #include <remote_prov/remote_prov_utils.h> #include <cstdint> +#include "cppbor.h" #include "keymaster/cppcose/cppcose.h" namespace aidl::android::hardware::security::keymint::remote_prov { @@ -80,5 +82,20 @@ TEST(RemoteProvUtilsTest, GetProdEekChain) { EXPECT_THAT(eekPub, ElementsAreArray(geek->getBstrValue(CoseKey::PUBKEY_X).value_or(empty))); } +TEST(RemoteProvUtilsTest, JsonEncodeCsr) { + cppbor::Array array; + array.add(1); + + auto [json, error] = jsonEncodeCsrWithBuild(array); + + ASSERT_TRUE(error.empty()) << error; + + std::string expected = R"({"build_fingerprint":")" + + ::android::base::GetProperty("ro.build.fingerprint", /*default=*/"") + + R"(","csr":"gQE="})"; + + ASSERT_EQ(json, expected); +} + } // namespace } // namespace aidl::android::hardware::security::keymint::remote_prov |
