From patchwork Wed Nov 11 11:18:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 322921 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp300119ils; Wed, 11 Nov 2020 03:19:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+CinGW2LK3Wt13f1tQNNvxppfVQTEVHtZReR4IDsFpfasNcpKkHiLIz94D7nH5B5Rrpvl X-Received: by 2002:a17:906:284b:: with SMTP id s11mr25754136ejc.326.1605093580971; Wed, 11 Nov 2020 03:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605093580; cv=none; d=google.com; s=arc-20160816; b=gWFPpXTrazs2ljWymF4jsjEZ6EV0htRfAXqUcXW3cjkkbLHfwfLUtfKcB6vRRwWKSa E7bct0yx5pp+yR2qUZIf7cuIqTBeYspMmIx+NOUK8X3YLzlnzGKJtsscqLBWwVSNaCYC iECu4KwqFQ5lIYwu5kbjd4Wwvj3rcwtsPRaUBCv+3qoj3KQL/+U4RwYZJnW8kz3Ac/Vl 8cvtw73oehCGalYNHVn2uIzkKlce7LrJZY6b6ZK14tGZYMezFCL4Mjj/jiSHdrdOWfID YoF926tE/ySPWdl1ohk01DC9bvGdGXIZr/0MS0WMCU5JSVPYYAJlS+coAiCWjydxkOZ6 jiZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HKopjynCciycEsmJEZnP6LywxeVLtwH3Nx1mNOKEvFQ=; b=aIyWIQIigy1iLm4E6R3ZjD5tdhvWD2FJ+eJLKITIWokLs/7+CSbtjRq+/UeUl1ZokJ ytdpE7+a0jS/IUkJkdgJ9T4BZ1CRw5TcWcNFMKQNS/d+uAyVkoCI8tFDFct3f/ZpWTiF ltfLmPcB20Tf7YbYpASbZQkUrVdWAAVFrqiu8mx0AHTAaRCDeZ45yZfFDcEXBRC20eK6 tdKYU83rHrao4JERFIQz2IzXD0jaRbmo9Iu70K+OOlkgKpSnBPCW3dlhWAgotVuW5QBo mgQCkY5xsq/fQ+ngpQHkdzpDfUThtQw24vZd1ejejR9Pt60AkvgkesAdiTozZMCLcE/7 EB0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mApM7p2v; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id e16si1150095ejz.457.2020.11.11.03.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 03:19:40 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mApM7p2v; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A3AB8254F; Wed, 11 Nov 2020 12:19:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mApM7p2v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D39982543; Wed, 11 Nov 2020 12:19:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 65DD382538 for ; Wed, 11 Nov 2020 12:19:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=joel.stan@gmail.com Received: by mail-pj1-x1043.google.com with SMTP id g21so550425pjv.2 for ; Wed, 11 Nov 2020 03:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HKopjynCciycEsmJEZnP6LywxeVLtwH3Nx1mNOKEvFQ=; b=mApM7p2vSkFmSFFQMyuO61rOk6zPWefRJo8GUPQGGd36k/aD2WrSLcDR2c/AICAsLj wTfUdiov2s/7QjXzF8qQZ2nC6UwkwX7tF9eSAR6zc0zYlMhf6j6cePEOmh6G1ijzb7KO vYb3M0yBx31XSxs0dimA4CJRpTO4HGjQmAciAxiFUsw87po+CHgCZb7MdqGT3nyM3Tyj COQHy61cBhIOSCuvBd8OUOOp1oOU4eNKgoTYIiXf4fk5Z7NyanqxMJdfja1+aq9oS1bj uoFlOhKNvD4A33BkTuMpYGwf9AIM+0l4V5GEAGxrN9AzxGzpfa/BA56f/NDNyKHHjYIO fOSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HKopjynCciycEsmJEZnP6LywxeVLtwH3Nx1mNOKEvFQ=; b=ZYIO42TrQikdN2n4ie4Qeyi1+oD+IbxUHAksrfvutpnMAmDx+f/VVXQOoIoUzKheew wcfv31bfmr/ZbDgIT+y6gYOHbD6dQaTV7t2JWNwSKgVBs15uGSb60AhvcH6cZu6bDNGG tUflhRvs+9LqKFIvV9NyVZETG4/um7gfZ2yq+ukPiBwODK2Fhh5DkQ++cM3x/WF+0eUI byhrpGArlg+JMUD4tqbshA+yDG5cuSTuC3gy5I/9ZRgFNW9/k8ORoX+Y9cfLB2d+wWdD JXWHsC4tD6brGbUdp0ocbaE3u/cvIQbpywlvRQRg50cYu2PJimp6EvHl+pUaSLBg40mA fmQw== X-Gm-Message-State: AOAM531d1ocrH8au1HmHlD8/A5sZOR8Tt4/NSQu5yxxMNF8DB9HZnULq g+N7MWDcKiBYuhz6LESw3WI= X-Received: by 2002:a17:90a:6b04:: with SMTP id v4mr3472388pjj.101.1605093544718; Wed, 11 Nov 2020 03:19:04 -0800 (PST) Received: from voyager.lan ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id l62sm2339495pga.63.2020.11.11.03.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 03:19:03 -0800 (PST) From: Joel Stanley To: Simon Glass , Philippe Reynes Cc: Andrew Jeffery , u-boot@lists.denx.de Subject: [PATCH 3/3] mkimge: Reject signing-related flags without FIT_SIGNATURE Date: Wed, 11 Nov 2020 21:48:33 +1030 Message-Id: <20201111111833.741937-4-joel@jms.id.au> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201111111833.741937-1-joel@jms.id.au> References: <20201111111833.741937-1-joel@jms.id.au> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean When CONFIG_FIT_SIGNATURE=n the signing options are not available. If a user is careful they will notice this when looking at the help output. If they are not careful they will waste several hours wondering what they got wrong, as mkimage will silently ignore the signing related options. Make it obvious that the commands don't work by removing them from the getopt opt_string. The tool will now behave as follows: $ mkimage -f machine.its -k keys -K u-boot-pubkey.dtb -r image.fit mkimage: invalid option -- 'k' Error: Invalid option Signed-off-by: Joel Stanley --- tools/mkimage.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.28.0 diff --git a/tools/mkimage.c b/tools/mkimage.c index e78608293e72..10a1b3dc8c18 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -142,6 +142,12 @@ static int add_content(int type, const char *fname) return 0; } +#ifdef CONFIG_FIT_SIGNATURE +#define OPT_STRING "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qstT:vVx" +#else +#define OPT_STRING "a:A:b:C:d:D:e:f:i:ln:O:R:qstT:vVx" +#endif + static void process_args(int argc, char **argv) { char *ptr; @@ -149,8 +155,7 @@ static void process_args(int argc, char **argv) char *datafile = NULL; int opt; - while ((opt = getopt(argc, argv, - "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qstT:vVx")) != -1) { + while ((opt = getopt(argc, argv, OPT_STRING)) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16);