]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib: rsa: bring exp_len in line when generating a key_prop
authorHeiko Stuebner <heiko.stuebner@theobroma-systems.com>
Thu, 18 Jun 2020 14:23:23 +0000 (16:23 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 8 Jul 2020 21:21:46 +0000 (17:21 -0400)
The exponent field of struct key_prop gets allocated an uint64_t,
and the contents are positioned from the back, so an exponent of
"0x01 0x00 0x01" becomes 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x1"

Right now rsa_gen_key_prop() allocates a uint64_t but sets exp_len
to the size returned from the parser, while on the other hand the
when getting the key from the devicetree exp_len always gets set to
sizeof(uint64_t).

So bring that in line with the established code.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
lib/rsa/rsa-keyprop.c

index 9464df009343973adc4725fd12d6ae64dbb6dfe2..4b54db44c438507f44f5d88f4ff86cf0ff0b2daf 100644 (file)
@@ -691,7 +691,7 @@ int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **prop)
        memcpy((void *)(*prop)->public_exponent + sizeof(uint64_t)
                                                - rsa_key.e_sz,
               rsa_key.e, rsa_key.e_sz);
-       (*prop)->exp_len = rsa_key.e_sz;
+       (*prop)->exp_len = sizeof(uint64_t);
 
        /* n0 inverse */
        br_i32_decode(n, &rsa_key.n[i], rsa_key.n_sz - i);