]> 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 a5dd676b6b0f0dd2291c0aebef2c2f2870d73edf..325751ab7e1896c548e2c229708ad1a04670c2f5 100644 (file)
@@ -6,23 +6,7 @@
  * (C) Copyright 2000-2006
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef _RSA_H
 #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
@@ -62,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
@@ -105,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