]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/rsa.h
fdt: Update functions which write to an FDT to return -ENOSPC
[karo-tx-uboot.git] / include / rsa.h
index add4c789f335488f3ed5442365acf9a95dc49d84..325751ab7e1896c548e2c229708ad1a04670c2f5 100644 (file)
 #include <errno.h>
 #include <image.h>
 
+/**
+ * struct rsa_public_key - holder for a public key
+ *
+ * An RSA public key consists of a modulus (typically called N), the inverse
+ * and R^2, where R is 2^(# key bits).
+ */
+
+struct rsa_public_key {
+       uint len;               /* len of modulus[] in number of uint32_t */
+       uint32_t n0inv;         /* -1 / modulus[0] mod 2^32 */
+       uint32_t *modulus;      /* modulus as little endian array */
+       uint32_t *rr;           /* R^2 as little endian array */
+};
+
 #if IMAGE_ENABLE_SIGN
 /**
  * sign() - calculate and return signature for given input data
@@ -46,7 +60,8 @@ int rsa_sign(struct image_sign_info *info,
  *
  * @info:      Specifies key and FIT information
  * @keydest:   Destination FDT blob for public key data
- * @return: 0, on success, -ve on error
+ * @return: 0, on success, -ENOSPC if the keydest FDT blob ran out of space,
+               other -ve value on error
 */
 int rsa_add_verify_data(struct image_sign_info *info, void *keydest);
 #else
@@ -89,4 +104,14 @@ static inline int rsa_verify(struct image_sign_info *info,
 }
 #endif
 
+#define RSA2048_BYTES  (2048 / 8)
+#define RSA4096_BYTES  (4096 / 8)
+
+/* This is the minimum/maximum key size we support, in bits */
+#define RSA_MIN_KEY_BITS       2048
+#define RSA_MAX_KEY_BITS       4096
+
+/* This is the maximum signature length that we support, in bits */
+#define RSA_MAX_SIG_BITS       4096
+
 #endif