summaryrefslogtreecommitdiff
path: root/security/keymint/support/remote_prov_utils_test.cpp
diff options
context:
space:
mode:
authorSeth Moore <sethmo@google.com>2021-06-25 14:20:15 -0700
committerSeth Moore <sethmo@google.com>2021-07-01 10:17:28 -0700
commitf4c8ff9bef34092787e97149e38cd1bb052635c8 (patch)
tree41b201ede6ba41be80f14e14749ea88f64ef0e76 /security/keymint/support/remote_prov_utils_test.cpp
parent0ab5ef3ff712558dcf14df3a8f7df950a503b44b (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.cpp17
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 c360c06506..8697c5190f 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