Show a patch.

GET /api/patches/3397/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3397,
    "url": "https://patchwork.libcamera.org/api/patches/3397/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3397/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200404015624.30440-8-laurent.pinchart@ideasonboard.com>",
    "date": "2020-04-04T01:56:20",
    "name": "[libcamera-devel,07/11] libcamera: ipa_module: Load IPA module signature",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "72c5eb0c4f39a180d54a2e5f80887dcf6d960d3b",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3397/mbox/",
    "series": [
        {
            "id": 797,
            "url": "https://patchwork.libcamera.org/api/series/797/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=797",
            "date": "2020-04-04T01:56:13",
            "name": "Sign IPA modules instead of checking their advertised license",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/797/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3397/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3397/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 BE43D62D75\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Apr 2020 03:56:40 +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 53C5972E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Apr 2020 03:56:40 +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=\"plxhs3b4\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1585965400;\n\tbh=Tjf4ysA5abCtPCGqTHgiPAFLJPzsHsoVi+vX8ZWT5r4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=plxhs3b4oWHNDxDYBoWxcMrL6Q4iH6RpXf97jyPHJhUW1BjZUZCGsiY49feWc/L86\n\tQd9uy7x2Eu/UkiNUjP43cIW0nQHr7DC9eY8ZgIyncKyrKgcqXxL7shW+3AzCe5qzG4\n\tlgEPRjKEeB30ldSlUDJp6HvVLaJ8V4s1Yqvm5hl0=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat,  4 Apr 2020 04:56:20 +0300",
        "Message-Id": "<20200404015624.30440-8-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200404015624.30440-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200404015624.30440-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[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": "Sat, 04 Apr 2020 01:56:43 -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>\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",
        "07/11"
    ]
}