summaryrefslogtreecommitdiffstats
path: root/lib/rsa/rsa-verify.c
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2014-03-03 12:19:27 +0100
committerTom Rini <trini@ti.com>2014-03-21 16:39:35 -0400
commitdb1b5f3d20666ffd52d649a3bd6141989b596e3f (patch)
treed252870955d71dd8aaccc705cf5e0b1a68c5c76c /lib/rsa/rsa-verify.c
parent646257d1f4004855d486024527a4784bf57c4c4d (diff)
downloadtalos-obmc-uboot-db1b5f3d20666ffd52d649a3bd6141989b596e3f.tar.gz
talos-obmc-uboot-db1b5f3d20666ffd52d649a3bd6141989b596e3f.zip
rsa: add sha256,rsa4096 algorithm
Add support for sha256,rsa4096 signatures in u-boot. Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Simon Glass <sjg@chromium.org> Cc: andreas@oetken.name
Diffstat (limited to 'lib/rsa/rsa-verify.c')
-rw-r--r--lib/rsa/rsa-verify.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index b3573a8769..09268ca293 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -15,15 +15,6 @@
#define UINT64_MULT32(v, multby) (((uint64_t)(v)) * ((uint32_t)(multby)))
-#define RSA2048_BYTES (2048 / 8)
-
-/* This is the minimum/maximum key size we support, in bits */
-#define RSA_MIN_KEY_BITS 2048
-#define RSA_MAX_KEY_BITS 2048
-
-/* This is the maximum signature length that we support, in bits */
-#define RSA_MAX_SIG_BITS 2048
-
/**
* subtract_modulus() - subtract modulus from the given value
*
@@ -197,7 +188,7 @@ static int rsa_verify_key(const struct rsa_public_key *key, const uint8_t *sig,
return ret;
padding = algo->rsa_padding;
- pad_len = RSA2048_BYTES - algo->checksum_len;
+ pad_len = algo->pad_len - algo->checksum_len;
/* Check pkcs1.5 padding bytes. */
if (memcmp(buf, padding, pad_len)) {
@@ -281,7 +272,7 @@ int rsa_verify(struct image_sign_info *info,
{
const void *blob = info->fdt_blob;
/* Reserve memory for maximum checksum-length */
- uint8_t hash[RSA2048_BYTES];
+ uint8_t hash[info->algo->checksum->pad_len];
int ndepth, noffset;
int sig_node, node;
char name[100];
@@ -291,9 +282,10 @@ int rsa_verify(struct image_sign_info *info,
* Verify that the checksum-length does not exceed the
* rsa-signature-length
*/
- if (info->algo->checksum->checksum_len > RSA2048_BYTES) {
- debug("%s: invlaid checksum-algorithm %s for RSA2048\n",
- __func__, info->algo->checksum->name);
+ if (info->algo->checksum->checksum_len >
+ info->algo->checksum->pad_len) {
+ debug("%s: invlaid checksum-algorithm %s for %s\n",
+ __func__, info->algo->checksum->name, info->algo->name);
return -EINVAL;
}
OpenPOWER on IntegriCloud