rkp_factory_extraction_tool now validates DeviceInfo

This way, partners doing testing can see if they are getting bad device
info before they try to upload it to the backend.

This also acts as a check on the factory line, in case a device is
misprovisioned or defective, it can be discoverd earlier in the
manufacturing process (as CSRs tend to be uploaded at the very end).

Test: atest VtsHalRemotelyProvisionedComponentTargetTest
Test: rkp_factory_extraction_tool
Bug: 239838563
Change-Id: I8da97a9740cccb3263d21b07ba9d678513a337c8
diff --git a/provisioner/rkp_factory_extraction_lib.h b/provisioner/rkp_factory_extraction_lib.h
index fe15402..808ce7c 100644
--- a/provisioner/rkp_factory_extraction_lib.h
+++ b/provisioner/rkp_factory_extraction_lib.h
@@ -21,17 +21,17 @@
 
 #include <cstdint>
 #include <memory>
-#include <optional>
 #include <string>
+#include <string_view>
 #include <vector>
 
 constexpr size_t kChallengeSize = 16;
 
-// Contains the result of CSR generation, bundling up the result (on success)
-// with an error message (on failure).
-struct CsrResult {
-    std::unique_ptr<cppbor::Array> csr;
-    std::optional<std::string> errMsg;
+// Contains a the result of an operation that should return cborData on success.
+// Returns an an error message and null cborData on error.
+template <typename T> struct CborResult {
+    std::unique_ptr<T> cborData;
+    std::string errMsg;
 };
 
 // Return `buffer` encoded as a base64 string.
@@ -43,5 +43,6 @@
 // Get a certificate signing request for the given IRemotelyProvisionedComponent.
 // On error, the csr Array is null, and the string field contains a description of
 // what went wrong.
-CsrResult getCsr(std::string_view componentName,
-                 aidl::android::hardware::security::keymint::IRemotelyProvisionedComponent* irpc);
\ No newline at end of file
+CborResult<cppbor::Array>
+getCsr(std::string_view componentName,
+       aidl::android::hardware::security::keymint::IRemotelyProvisionedComponent* irpc);
\ No newline at end of file