[Cryptech-Commits] [sw/libhal] branch master updated: Add support for ModExpA7
git at cryptech.is
git at cryptech.is
Tue Jun 14 21:25:58 UTC 2016
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch master
in repository sw/libhal.
The following commit(s) were added to refs/heads/master by this push:
new 97c3a85 Add support for ModExpA7
97c3a85 is described below
commit 97c3a85d32893ec5f17ecd807a45bac935e42dd5
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Tue Jun 14 17:25:29 2016 -0400
Add support for ModExpA7
---
core.c | 1 +
hal.h | 10 ++++++++--
rsa.c | 3 ++-
tests/test-rsa.c | 2 ++
verilog_constants.h | 17 +++++++++++++++++
5 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/core.c b/core.c
index b7bf3b0..ffe61e6 100644
--- a/core.c
+++ b/core.c
@@ -108,6 +108,7 @@ static int name_matches(const hal_core_t *const core, const char * const name)
static const struct { const char *name; hal_addr_t extra; } gaps[] = {
{ "csprng", 11 * CORE_SIZE }, /* empty slots after csprng */
{ "modexps6", 3 * CORE_SIZE }, /* ModexpS6 uses four slots */
+ { "modexpa7", 3 * CORE_SIZE }, /* ModexpA7 uses four slots */
};
static hal_core_t *probe_cores(void)
diff --git a/hal.h b/hal.h
index 12ed579..776acac 100644
--- a/hal.h
+++ b/hal.h
@@ -90,8 +90,14 @@
#define CHACHA_NAME "chacha "
#define CHACHA_VERSION "0.80"
-#define MODEXPS6_NAME "modexps6"
-#define MODEXPS6_VERSION "0.10"
+#define MODEXP_NAME "modexp"
+#define MODEXP_VERSION "0.10"
+
+#define MODEXPS6_NAME "modexps6"
+#define MODEXPS6_VERSION "0.10"
+
+#define MODEXPA7_NAME "modexpa7"
+#define MODEXPA7_VERSION "0.10"
#define MKMIF_NAME "mkmif "
#define MKMIF_VERSION "0.10"
diff --git a/rsa.c b/rsa.c
index 8438bea..c8a1479 100644
--- a/rsa.c
+++ b/rsa.c
@@ -197,7 +197,8 @@ static hal_error_t modexp(const hal_core_t *core,
{
hal_error_t err = HAL_OK;
- if ((err = hal_core_check_name(&core, MODEXPS6_NAME)) != HAL_OK)
+ if (((err = hal_core_check_name(&core, MODEXPS6_NAME)) != HAL_OK) &&
+ ((err = hal_core_check_name(&core, MODEXPA7_NAME)) != HAL_OK))
return err;
assert(msg != NULL && exp != NULL && mod != NULL && res != NULL);
diff --git a/tests/test-rsa.c b/tests/test-rsa.c
index 1fc516b..60fe2a5 100644
--- a/tests/test-rsa.c
+++ b/tests/test-rsa.c
@@ -299,6 +299,8 @@ static int test_rsa(const hal_core_t *core, const rsa_tc_t * const tc)
int main(int argc, char *argv[])
{
const hal_core_t *core = hal_core_find(MODEXPS6_NAME, NULL);
+ if (core == NULL)
+ core = hal_core_find(MODEXPA7_NAME, NULL);
const hal_core_info_t *core_info = hal_core_info(core);
if (core_info != NULL)
diff --git a/verilog_constants.h b/verilog_constants.h
index 085b973..f0ae070 100644
--- a/verilog_constants.h
+++ b/verilog_constants.h
@@ -224,6 +224,23 @@
#define MODEXPS6_ADDR_RESULT (MODEXPS6_ADDR_OPERANDS + 3 * MODEXPS6_OPERAND_WORDS)
/*
+ * ModExpA7 core. MODEXPA7_OPERAND_BITS is size in bits of largest
+ * supported modulus.
+ */
+
+#define MODEXPA7_OPERAND_BITS (4096)
+#define MODEXPA7_OPERAND_WORDS (MODEXPA7_OPERAND_BITS / 32)
+#define MODEXPA7_ADDR_REGISTERS (0 * MODEXPA7_OPERAND_WORDS)
+#define MODEXPA7_ADDR_OPERANDS (4 * MODEXPA7_OPERAND_WORDS)
+#define MODEXPA7_ADDR_MODE (MODEXPA7_ADDR_REGISTERS + 0x10)
+#define MODEXPA7_ADDR_MODULUS_WIDTH (MODEXPA7_ADDR_REGISTERS + 0x11)
+#define MODEXPA7_ADDR_EXPONENT_WIDTH (MODEXPA7_ADDR_REGISTERS + 0x12)
+#define MODEXPA7_ADDR_MODULUS (MODEXPA7_ADDR_OPERANDS + 0 * MODEXPA7_OPERAND_WORDS)
+#define MODEXPA7_ADDR_MESSAGE (MODEXPA7_ADDR_OPERANDS + 1 * MODEXPA7_OPERAND_WORDS)
+#define MODEXPA7_ADDR_EXPONENT (MODEXPA7_ADDR_OPERANDS + 2 * MODEXPA7_OPERAND_WORDS)
+#define MODEXPA7_ADDR_RESULT (MODEXPA7_ADDR_OPERANDS + 3 * MODEXPA7_OPERAND_WORDS)
+
+/*
* Utility cores.
*/
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list