aboutsummaryrefslogtreecommitdiff
path: root/include/u-boot/rsa-mod-exp.h
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-03-12 12:45:27 -0400
committerTom Rini <trini@konsulko.com>2020-03-12 12:45:27 -0400
commite24f0a39d0daa2d8c597650aeb3f559d44a195ae (patch)
tree650803dabb55a0669b19e6a7069273f703d78b84 /include/u-boot/rsa-mod-exp.h
parent36bdcf7f3b17ec6d8cec782e7f1d5b0b8014300a (diff)
parent2201fe70d878074a9176f352693c582d7464a8d1 (diff)
Merge branch '2020-03-12-rsa-improvements' into next
(Description from AKASHI Takahiro) extend rsa_verify() for UEFI secure boot: The current rsa_verify() requires five parameters for a RSA public key for efficiency while RSA, in theory, requires only two. In addition, those parameters are expected to come from FIT image. So this function won't fit very well when we want to use it for the purpose of implementing UEFI secure boot, in particular, image authentication as well as variable authentication, where the essential two parameters are set to be retrieved from one of X509 certificates in signature database. So, in this patch, additional three parameters will be calculated on the fly when rsa_verify() is called without fdt which should contain parameters above. This calculation heavily relies on "big-number (or multi-precision) library." Therefore some routines from BearSSL under MIT license are imported in this implementation.
Diffstat (limited to 'include/u-boot/rsa-mod-exp.h')
-rw-r--r--include/u-boot/rsa-mod-exp.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/u-boot/rsa-mod-exp.h b/include/u-boot/rsa-mod-exp.h
index 8a428c4b6a..1da8af1bb8 100644
--- a/include/u-boot/rsa-mod-exp.h
+++ b/include/u-boot/rsa-mod-exp.h
@@ -27,6 +27,29 @@ struct key_prop {
};
/**
+ * rsa_gen_key_prop() - Generate key properties of RSA public key
+ * @key: Specifies key data in DER format
+ * @keylen: Length of @key
+ * @prop: Generated key property
+ *
+ * This function takes a blob of encoded RSA public key data in DER
+ * format, parse it and generate all the relevant properties
+ * in key_prop structure.
+ * Return a pointer to struct key_prop in @prop on success.
+ *
+ * Return: 0 on success, negative on error
+ */
+int rsa_gen_key_prop(const void *key, uint32_t keylen, struct key_prop **proc);
+
+/**
+ * rsa_free_key_prop() - Free key properties
+ * @prop: Pointer to struct key_prop
+ *
+ * This function frees all the memories allocated by rsa_gen_key_prop().
+ */
+void rsa_free_key_prop(struct key_prop *prop);
+
+/**
* rsa_mod_exp_sw() - Perform RSA Modular Exponentiation in sw
*
* Operation: out[] = sig ^ exponent % modulus