Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi
[platform/kernel/u-boot.git] / lib / rsa / rsa-verify.c
index 0ab0f62..3840764 100644 (file)
@@ -95,7 +95,7 @@ int padding_pkcs_15_verify(struct image_sign_info *info,
        return 0;
 }
 
-#ifdef CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT
+#ifdef CONFIG_FIT_RSASSA_PSS
 static void u32_i2osp(uint32_t val, uint8_t *buf)
 {
        buf[0] = (uint8_t)((val >> 24) & 0xff);
@@ -447,8 +447,11 @@ static int rsa_verify_with_keynode(struct image_sign_info *info,
        }
 
        algo = fdt_getprop(blob, node, "algo", NULL);
-       if (strcmp(info->name, algo))
+       if (strcmp(info->name, algo)) {
+               debug("%s: Wrong algo: have %s, expected %s", __func__,
+                     info->name, algo);
                return -EFAULT;
+       }
 
        prop.num_bits = fdtdec_get_int(blob, node, "rsa,num-bits", 0);
 
@@ -522,10 +525,10 @@ int rsa_verify_hash(struct image_sign_info *info,
                        return ret;
 
                /* No luck, so try each of the keys in turn */
-               for (ndepth = 0, noffset = fdt_next_node(info->fit, sig_node,
+               for (ndepth = 0, noffset = fdt_next_node(blob, sig_node,
                                                         &ndepth);
                     (noffset >= 0) && (ndepth > 0);
-                    noffset = fdt_next_node(info->fit, noffset, &ndepth)) {
+                    noffset = fdt_next_node(blob, noffset, &ndepth)) {
                        if (ndepth == 1 && noffset != node) {
                                ret = rsa_verify_with_keynode(info, hash,
                                                              sig, sig_len,
@@ -553,7 +556,7 @@ int rsa_verify(struct image_sign_info *info,
         */
        if (info->checksum->checksum_len >
            info->crypto->key_len) {
-               debug("%s: invlaid checksum-algorithm %s for %s\n",
+               debug("%s: invalid checksum-algorithm %s for %s\n",
                      __func__, info->checksum->name, info->crypto->name);
                return -EINVAL;
        }
@@ -568,3 +571,19 @@ int rsa_verify(struct image_sign_info *info,
 
        return rsa_verify_hash(info, hash, sig, sig_len);
 }
+
+#ifndef USE_HOSTCC
+
+U_BOOT_CRYPTO_ALGO(rsa2048) = {
+       .name = "rsa2048",
+       .key_len = RSA2048_BYTES,
+       .verify = rsa_verify,
+};
+
+U_BOOT_CRYPTO_ALGO(rsa4096) = {
+       .name = "rsa4096",
+       .key_len = RSA4096_BYTES,
+       .verify = rsa_verify,
+};
+
+#endif