summaryrefslogtreecommitdiff
path: root/src/libcamera/ipa_module.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-29 05:33:04 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-14 02:03:23 +0300
commitbf4049fd903102230a9c42f0718a1c5bf1501b0a (patch)
tree36ca51c411dae5d6b983094b60f204bef7844195 /src/libcamera/ipa_module.cpp
parent9893ff92c453d891c6e7364a59a45a9a6f8fa12c (diff)
libcamera: ipa_module: Load IPA module signature
Load the signature from the .sign file, if available, when loading the IPA module information and store it in the IPAModule class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/ipa_module.cpp')
-rw-r--r--src/libcamera/ipa_module.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp
index 5b6af15f..51b238a6 100644
--- a/src/libcamera/ipa_module.cpp
+++ b/src/libcamera/ipa_module.cpp
@@ -308,6 +308,20 @@ int IPAModule::loadIPAModuleInfo()
return -EINVAL;
}
+ /* Load the signature. Failures are not fatal. */
+ File sign{ libPath_ + ".sign" };
+ if (!sign.open(File::ReadOnly)) {
+ LOG(IPAModule, Debug)
+ << "IPA module " << libPath_ << " is not signed";
+ return 0;
+ }
+
+ data = sign.map(0, -1, File::MapPrivate);
+ signature_.resize(data.size());
+ memcpy(signature_.data(), data.data(), data.size());
+
+ LOG(IPAModule, Debug) << "IPA module " << libPath_ << " is signed";
+
return 0;
}
@@ -340,6 +354,21 @@ const struct IPAModuleInfo &IPAModule::info() const
}
/**
+ * \brief Retrieve the IPA module signature
+ *
+ * The IPA module signature is stored alongside the IPA module in a file with a
+ * '.sign' suffix, and is loaded when the IPAModule instance is created. This
+ * function returns the signature without verifying it. If the signature is
+ * missing, the returned vector will be empty.
+ *
+ * \return The IPA module signature
+ */
+const std::vector<uint8_t> IPAModule::signature() const
+{
+ return signature_;
+}
+
+/**
* \brief Retrieve the IPA module path
*
* The IPA module path is the file name and path of the IPA module shared