Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40f1230a authored by Seth Moore's avatar Seth Moore Committed by Gerrit Code Review
Browse files

Merge "Change the way rkp tool obtains serial number" into main

parents f3531c57 18a9fa99
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ struct JsonOutput {
 *   }
 */
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name,
                                  const cppbor::Array& csr);
                                  const cppbor::Array& csr, const std::string serialno_prop);

/**
 * Parses a DeviceInfo structure from the given CBOR data. The parsed data is then validated to
+3 −3
Original line number Diff line number Diff line
@@ -337,9 +337,9 @@ ErrMsgOr<std::vector<BccEntryData>> validateBcc(const cppbor::Array* bcc,
    return result;
}

JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor::Array& csr) {
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor::Array& csr,
                                  const std::string serialno_prop) {
    const std::string kFingerprintProp = "ro.build.fingerprint";
    const std::string kSerialNoProp = "ro.serialno";

    if (!::android::base::WaitForPropertyCreation(kFingerprintProp)) {
        return JsonOutput::Error("Unable to read build fingerprint");
@@ -364,7 +364,7 @@ JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor:
    Json::Value json(Json::objectValue);
    json["name"] = instance_name;
    json["build_fingerprint"] = ::android::base::GetProperty(kFingerprintProp, /*default=*/"");
    json["serialno"] = ::android::base::GetProperty(kSerialNoProp, /*default=*/"");
    json["serialno"] = ::android::base::GetProperty(serialno_prop, /*default=*/"");
    json["csr"] = base64.data();  // Boring writes a NUL-terminated c-string

    Json::StreamWriterBuilder factory;
+2 −1
Original line number Diff line number Diff line
@@ -182,10 +182,11 @@ TEST(RemoteProvUtilsTest, GetProdEekChain) {
}

TEST(RemoteProvUtilsTest, JsonEncodeCsr) {
    const std::string kSerialNoProp = "ro.serialno";
    cppbor::Array array;
    array.add(1);

    auto [json, error] = jsonEncodeCsrWithBuild(std::string("test"), array);
    auto [json, error] = jsonEncodeCsrWithBuild(std::string("test"), array, kSerialNoProp);

    ASSERT_TRUE(error.empty()) << error;