{"id":3441,"url":"https://patchwork.libcamera.org/api/1.1/patches/3441/?format=json","web_url":"https://patchwork.libcamera.org/patch/3441/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200413133047.11913-8-laurent.pinchart@ideasonboard.com>","date":"2020-04-13T13:30:43","name":"[libcamera-devel,v2,07/11] libcamera: ipa_module: Load IPA module signature","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"72c5eb0c4f39a180d54a2e5f80887dcf6d960d3b","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3441/mbox/","series":[{"id":804,"url":"https://patchwork.libcamera.org/api/1.1/series/804/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=804","date":"2020-04-13T13:30:37","name":"Sign IPA modules instead of checking their advertised license","version":2,"mbox":"https://patchwork.libcamera.org/series/804/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3441/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3441/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2146E62E17\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Apr 2020 15:31:07 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BEA0924B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Apr 2020 15:31:06 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"aqj9vA1o\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1586784666;\n\tbh=TJnWAwIRmr63ZViJXOO5IvICSVVIB+uo4PmF/VOexgw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=aqj9vA1oSYdZq5Vi4RA/7irWgQs7cuJjPocjMKBe3Typ6+YGcZdJaP64sV5TF0B7Z\n\tYI2hwsUlgQHe/vcryaHo6v5ZK4GjYQ5p7tCDQ2Ou7Wp+IpWMDQepiFbOUBUMR+BSEU\n\t1mcCAdH74dP8LyeP2lW1obLdLTmUzXg649PiG7t0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 13 Apr 2020 16:30:43 +0300","Message-Id":"<20200413133047.11913-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200413133047.11913-1-laurent.pinchart@ideasonboard.com>","References":"<20200413133047.11913-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 07/11] libcamera: ipa_module: Load IPA\n\tmodule signature","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 13 Apr 2020 13:31:09 -0000"},"content":"Load the signature from the .sign file, if available, when loading the\nIPA module information and store it in the IPAModule class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/ipa_module.h |  4 ++++\n src/libcamera/ipa_module.cpp       | 29 +++++++++++++++++++++++++++++\n 2 files changed, 33 insertions(+)","diff":"diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h\nindex 2028b76a1913..ec3671857a61 100644\n--- a/src/libcamera/include/ipa_module.h\n+++ b/src/libcamera/include/ipa_module.h\n@@ -7,7 +7,9 @@\n #ifndef __LIBCAMERA_IPA_MODULE_H__\n #define __LIBCAMERA_IPA_MODULE_H__\n \n+#include <stdint.h>\n #include <string>\n+#include <vector>\n \n #include <ipa/ipa_interface.h>\n #include <ipa/ipa_module_info.h>\n@@ -25,6 +27,7 @@ public:\n \tbool isValid() const;\n \n \tconst struct IPAModuleInfo &info() const;\n+\tconst std::vector<uint8_t> signature() const;\n \tconst std::string &path() const;\n \n \tbool load();\n@@ -38,6 +41,7 @@ public:\n \n private:\n \tstruct IPAModuleInfo info_;\n+\tstd::vector<uint8_t> signature_;\n \n \tstd::string libPath_;\n \tbool valid_;\ndiff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp\nindex 5b6af15f2593..51b238a698f2 100644\n--- a/src/libcamera/ipa_module.cpp\n+++ b/src/libcamera/ipa_module.cpp\n@@ -308,6 +308,20 @@ int IPAModule::loadIPAModuleInfo()\n \t\treturn -EINVAL;\n \t}\n \n+\t/* Load the signature. Failures are not fatal. */\n+\tFile sign{ libPath_ + \".sign\" };\n+\tif (!sign.open(File::ReadOnly)) {\n+\t\tLOG(IPAModule, Debug)\n+\t\t\t<< \"IPA module \" << libPath_ << \" is not signed\";\n+\t\treturn 0;\n+\t}\n+\n+\tdata = sign.map(0, -1, File::MapPrivate);\n+\tsignature_.resize(data.size());\n+\tmemcpy(signature_.data(), data.data(), data.size());\n+\n+\tLOG(IPAModule, Debug) << \"IPA module \" << libPath_ << \" is signed\";\n+\n \treturn 0;\n }\n \n@@ -339,6 +353,21 @@ const struct IPAModuleInfo &IPAModule::info() const\n \treturn info_;\n }\n \n+/**\n+ * \\brief Retrieve the IPA module signature\n+ *\n+ * The IPA module signature is stored alongside the IPA module in a file with a\n+ * '.sign' suffix, and is loaded when the IPAModule instance is created. This\n+ * function returns the signature without verifying it. If the signature is\n+ * missing, the returned vector will be empty.\n+ *\n+ * \\return The IPA module signature\n+ */\n+const std::vector<uint8_t> IPAModule::signature() const\n+{\n+\treturn signature_;\n+}\n+\n /**\n  * \\brief Retrieve the IPA module path\n  *\n","prefixes":["libcamera-devel","v2","07/11"]}