From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Jimmy Zhang <jimmzhang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: amartin-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [cbootimage PATCH v5 1/5] Add support for update pubkey and rsa-pss signatures
Date: Mon, 12 Oct 2015 16:49:05 -0600 [thread overview]
Message-ID: <561C38E1.6000103@wwwdotorg.org> (raw)
In-Reply-To: <1444441574-17205-2-git-send-email-jimmzhang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On 10/09/2015 07:46 PM, Jimmy Zhang wrote:
> Create new configuration keywords:
> RsaKeyModulusFile: pubkey modulus
> RsaPssSigBlFile: bootloader rsa pss signature
> RsaPssSigBctFile: bct rsa pss signature
>
> Sample Configuration file update_bl_sig.cfg
> RsaKeyModulusFile = pubkey.mod;
> RsaPssSigBlFile = bl.sig;
>
> where pubkey.mod and bl.sig are files that contain the public key
> modulus and bootloader's rsa-pss signature respectively.
>
> public key modulus and signature are created through utilities
> outside cbootimage.
>
> Command line example:
> $ cbootimage -s tegra210 -u update_bl_sig.cfg image.bin image.bin-bl-signed
>
> Above three new keywords added in this CL are only implemented support
> for T210.
I'd like to see a changelog per patch so I don't have to refer back to
the cover letter each time.
> diff --git a/src/crypto.c b/src/crypto.c
> +void
> +swap_endianness(
Nit: It's more like "byte order" (serialization) rather than endianness,
although they're related concepts.
> + u_int8_t *out,
> + u_int8_t *in,
Nit: You could make "in" const to since it's not written.
> + const u_int32_t size)
... certainly that'd be more useful than making size const.
> +{
> + u_int32_t i;
> +
> + for (i = 0; i < size / 2; i++) {
> + u_int8_t b1 = in[i];
> + u_int8_t b2 = in[size - 1 - i];
> + out[i] = b2;
> + out[size - 1 - i] = b1;
Nit: It'd be nice to put "size - 1 - i" into a variable rather than
duplicate the calculation.
> diff --git a/src/set.c b/src/set.c
> +int
> +set_rsa_param(build_image_context *context, parse_token token,
> + char *filename)
> +{
> + int result;
> + u_int8_t *rsa_storage; /* Holds the rsa param after reading */
> + u_int32_t size; /* Bytes to read */
> + u_int32_t actual_size; /* In bytes */
> +
> + if (g_soc_config->get_value_size == NULL) {
> + printf("Error: get_value_size() is not supported.\n");
I think code that calls that function should be able to assume the
function pointer is non-NULL. This could be achieved by either having
each SoC-specific file provide an implementation of that function. For
the SoCs that don't support this, you could share a common dummy
implementation that always returns an error.
> diff --git a/src/parse.h b/src/parse.h
> /*
> + * Get the size of specified bct field
> + *
> + * @param id The parse token
> + * @param data Return size from bct field
> + * @param bct Bct pointer
> + * @return 0 and -ENODATA for success and failure
> + */
> + int (*get_value_size)(parse_token id,
> + void *data,
> + u_int8_t *bct);
The existing get/set functions use a void* since they can operate on
different fields with different data types. However, the result of
retrieving a field's size is always a size_t. The "bct" parameter also
doesn't seem to be used; do you think there could ever be a use for it?
I think the following prototype should be used so that we can get as
much type safety as possible:
// Returns >0 for size, -ve for error, never returns 0.
size_t (*get_value_size)(parse_token id);
next prev parent reply other threads:[~2015-10-12 22:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 1:46 [cbootimage PATCH v5 0/5] Add RSA signing support Jimmy Zhang
[not found] ` <1444441574-17205-1-git-send-email-jimmzhang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2015-10-10 1:46 ` [cbootimage PATCH v5 1/5] Add support for update pubkey and rsa-pss signatures Jimmy Zhang
[not found] ` <1444441574-17205-2-git-send-email-jimmzhang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2015-10-12 22:49 ` Stephen Warren [this message]
[not found] ` <561C38E1.6000103-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-10-13 2:02 ` Jimmy Zhang
[not found] ` <6bc0f021797c4eab93749693af343d5a-wO81nVYWzR7YuxH7O460wFaTQe2KTcn/@public.gmane.org>
2015-10-13 16:19 ` Stephen Warren
[not found] ` <561D2F00.7000306-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-10-13 17:32 ` Jimmy Zhang
2015-10-17 0:21 ` Jimmy Zhang
[not found] ` <bc8eeffeced34fb1b912850b61a161f0-wO81nVYWzR7YuxH7O460wFaTQe2KTcn/@public.gmane.org>
2015-10-19 16:28 ` Stephen Warren
2015-10-10 1:46 ` [cbootimage PATCH v5 2/5] Add support to dump rsa related fields for t210 Jimmy Zhang
[not found] ` <1444441574-17205-3-git-send-email-jimmzhang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2015-10-12 22:50 ` Stephen Warren
[not found] ` <561C393E.2050707-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-10-13 0:56 ` Jimmy Zhang
[not found] ` <ab16c6505a7e4e62b726e6433dc585b8-wO81nVYWzR7YuxH7O460wFaTQe2KTcn/@public.gmane.org>
2015-10-13 16:22 ` Stephen Warren
2015-10-10 1:46 ` [cbootimage PATCH v5 3/5] Add new configuration keyword "RehashBl" Jimmy Zhang
2015-10-10 1:46 ` [cbootimage PATCH v5 4/5] Add a sample script to do rsa signing for T210 bootimage Jimmy Zhang
2015-10-10 1:46 ` [cbootimage PATCH v5 5/5] Bump to version 1.6 Jimmy Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561C38E1.6000103@wwwdotorg.org \
--to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
--cc=amartin-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=jimmzhang-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).