summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRuchika Gupta <ruchika.gupta@freescale.com>2015-01-23 16:01:52 +0530
committerSimon Glass <sjg@chromium.org>2015-01-29 17:09:58 -0700
commit31d2b4fd90f9305aad2e79872067e6c0243267de (patch)
tree823edbcb72a6f271688a3c22edc223fa89587525 /include
parentc4beb22fcd8cf57569a8045c8e04cea0dbbfd763 (diff)
downloadblackbird-obmc-uboot-31d2b4fd90f9305aad2e79872067e6c0243267de.tar.gz
blackbird-obmc-uboot-31d2b4fd90f9305aad2e79872067e6c0243267de.zip
DM: crypto/rsa_mod_exp: Add rsa Modular Exponentiation DM driver
Add a new rsa uclass for performing modular exponentiation and implement the software driver basing on this uclass. Signed-off-by: Ruchika Gupta <ruchika.gupta@freescale.com> CC: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/dm/uclass-id.h1
-rw-r--r--include/u-boot/rsa-mod-exp.h34
2 files changed, 34 insertions, 1 deletions
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index f17c3c2b38..91bb90dcfb 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -33,6 +33,7 @@ enum uclass_id {
UCLASS_I2C, /* I2C bus */
UCLASS_I2C_GENERIC, /* Generic I2C device */
UCLASS_I2C_EEPROM, /* I2C EEPROM device */
+ UCLASS_MOD_EXP, /* RSA Mod Exp device */
UCLASS_COUNT,
UCLASS_INVALID = -1,
diff --git a/include/u-boot/rsa-mod-exp.h b/include/u-boot/rsa-mod-exp.h
index 59cd9ea2d8..fce445a082 100644
--- a/include/u-boot/rsa-mod-exp.h
+++ b/include/u-boot/rsa-mod-exp.h
@@ -35,9 +35,41 @@ struct key_prop {
* @sig: RSA PKCS1.5 signature
* @sig_len: Length of signature in number of bytes
* @node: Node with RSA key elements like modulus, exponent, R^2, n0inv
- * @out: Result in form of byte array
+ * @out: Result in form of byte array of len equal to sig_len
*/
int rsa_mod_exp_sw(const uint8_t *sig, uint32_t sig_len,
struct key_prop *node, uint8_t *out);
+int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
+ struct key_prop *node, uint8_t *out);
+
+/**
+ * struct struct mod_exp_ops - Driver model for RSA Modular Exponentiation
+ * operations
+ *
+ * The uclass interface is implemented by all crypto devices which use
+ * driver model.
+ */
+struct mod_exp_ops {
+ /**
+ * Perform Modular Exponentiation
+ *
+ * Operation: out[] = sig ^ exponent % modulus
+ *
+ * @dev: RSA Device
+ * @sig: RSA PKCS1.5 signature
+ * @sig_len: Length of signature in number of bytes
+ * @node: Node with RSA key elements like modulus, exponent,
+ * R^2, n0inv
+ * @out: Result in form of byte array of len equal to sig_len
+ *
+ * This function computes exponentiation over the signature.
+ * Returns: 0 if exponentiation is successful, or a negative value
+ * if it wasn't.
+ */
+ int (*mod_exp)(struct udevice *dev, const uint8_t *sig,
+ uint32_t sig_len, struct key_prop *node,
+ uint8_t *outp);
+};
+
#endif
OpenPOWER on IntegriCloud