[{"id":4397,"web_url":"https://patchwork.libcamera.org/comment/4397/","msgid":"<20200407203043.GM1716317@oden.dyn.berto.se>","date":"2020-04-07T20:30:43","subject":"Re: [libcamera-devel] [PATCH 07/11] libcamera: ipa_module: Load IPA\n\tmodule signature","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-04-04 04:56:20 +0300, Laurent Pinchart wrote:\n> Load the signature from the .sign file, if available, when loading the\n> IPA module information and store it in the IPAModule class.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/ipa_module.h |  4 ++++\n>  src/libcamera/ipa_module.cpp       | 29 +++++++++++++++++++++++++++++\n>  2 files changed, 33 insertions(+)\n> \n> diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h\n> index 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_;\n> diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 32CEC600F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2020 22:30:45 +0200 (CEST)","by mail-lj1-x241.google.com with SMTP id i20so5233765ljn.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Apr 2020 13:30:45 -0700 (PDT)","from localhost (h-200-138.A463.priv.bahnhof.se. [176.10.200.138])\n\tby smtp.gmail.com with ESMTPSA id\n\ti2sm131948ljb.50.2020.04.07.13.30.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Apr 2020 13:30:43 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"eDxMn8Yn\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=1Y7lSbJ0Nwbt13TWE0bl2es8AIXLPdJLQaVRa6x8XBE=;\n\tb=eDxMn8YnR9e/H6lUhOh0acMax2jlRW2tIKiJ+4whZX4izrGGQZknU+2oWNkCKzpKvI\n\tfTtrspzNAN3F2cxhQ1CHDAW4dEv56ObqZ5wzXHdSiO/Y6m2lyVvJwDfTT8wvVnC0MZD0\n\tMUsOWOpmvgQ5TAuCIYgaPQ/5Rp6TGtgLE+9jJAmYCAlgpO/Mznk9F0Kcdc8Fuv3OTZjl\n\tGh8VmCycIo1UXat9ZX+jLGbOiCFPwMW2FdO+8wUQBGU+S0MFY1Y0C/Qha3bBaX08H8br\n\tuCyEDp+UyGpUjWoDIOEOmlLNQy6mWmUN97Bo0eGVs/kKpp8rLSRui5UEn0YHBs1aZZx7\n\tQvDw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=1Y7lSbJ0Nwbt13TWE0bl2es8AIXLPdJLQaVRa6x8XBE=;\n\tb=aG2ANPUwquUhxSU+c9Yp5aZ/nzRDBNXzP/ASANAg2uvV3ZaSoqiSeimo7AamEmkY+n\n\tNPZEMdmKmPiZAXkDCw3yuLoQhwtqnJ+SHecAiYNDA6xStO63E72lsXNqzUsowrLS9sur\n\tVfIzOpsHvgWFF+6M0A07jNDv9+63vAqK0RHovpi8O1xR85+bVEmKM8RaqYwhArFXQadC\n\tK/zlVwYMuYCLo9xaK5D0bD6+6tX34Y+8PqcwG6STcoARgvn039Hr7A27SEQGGQZsGC8a\n\tdpn/0FGSf4PWBlcghav6AUTQkIY/q1viGJdYA9A9XSIOwF98ncL313MI1vpOHDAXOJV0\n\t9qXg==","X-Gm-Message-State":"AGi0PuYfJkYEdQaiCoiYXVSGhOlLSiQTptsb5oCuxylOFbFY1ubLEPQn\n\tAtffLWmveYTIOHfqhAjKgi0cyg==","X-Google-Smtp-Source":"APiQypJMLQZEYWVkvShJhFhzzioZNejWAthUu7KAiylsjCZLEPgPC13bxzVScjd4zSHG1C3jgMQ0+Q==","X-Received":"by 2002:a2e:81cc:: with SMTP id s12mr2853528ljg.90.1586291444555;\n\tTue, 07 Apr 2020 13:30:44 -0700 (PDT)","Date":"Tue, 7 Apr 2020 22:30:43 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200407203043.GM1716317@oden.dyn.berto.se>","References":"<20200404015624.30440-1-laurent.pinchart@ideasonboard.com>\n\t<20200404015624.30440-8-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200404015624.30440-8-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 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":"Tue, 07 Apr 2020 20:30:45 -0000"}}]