diff options
author | Paul Selkirk <paul@psgd.org> | 2016-06-14 17:25:29 -0400 |
---|---|---|
committer | Paul Selkirk <paul@psgd.org> | 2016-06-14 17:25:29 -0400 |
commit | 97c3a85d32893ec5f17ecd807a45bac935e42dd5 (patch) | |
tree | cb90ffcc07e09faf4b37ca0759fda2f65aa36714 | |
parent | a20af9980516d516f0403bb80551db8d283aa383 (diff) |
Add support for ModExpA7
-rw-r--r-- | core.c | 1 | ||||
-rw-r--r-- | hal.h | 10 | ||||
-rw-r--r-- | rsa.c | 3 | ||||
-rw-r--r-- | tests/test-rsa.c | 2 | ||||
-rw-r--r-- | verilog_constants.h | 17 |
5 files changed, 30 insertions, 3 deletions
@@ -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) @@ -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" @@ -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. */ |