aboutsummaryrefslogtreecommitdiff
path: root/hal.h
diff options
context:
space:
mode:
Diffstat (limited to 'hal.h')
-rw-r--r--hal.h60
1 files changed, 29 insertions, 31 deletions
diff --git a/hal.h b/hal.h
index 547894e..4a5e239 100644
--- a/hal.h
+++ b/hal.h
@@ -390,39 +390,33 @@
* MATH segment.
*/
-/* Modexp core */
-#define MODEXP_ADDR_BASE (SEGMENT_OFFSET_MATH + (0x00 * CORE_SIZE))
-#define MODEXP_ADDR_NAME0 (MODEXP_ADDR_BASE + ADDR_NAME0)
-#define MODEXP_ADDR_NAME1 (MODEXP_ADDR_BASE + ADDR_NAME1)
-#define MODEXP_ADDR_VERSION (MODEXP_ADDR_BASE + ADDR_VERSION)
-#define MODEXP_ADDR_CTRL (MODEXP_ADDR_BASE + ADDR_CTRL)
-#define MODEXP_CTRL_INIT_BIT (1)
-#define MODEXP_CTRL_NEXT_BIT (2)
-#define MODEXP_ADDR_STATUS (MODEXP_ADDR_BASE + ADDR_STATUS)
+#define MATH_CORE_SIZE (0x400)
-#define MODEXP_ADDR_DELAY (MODEXP_ADDR_BASE + 0x13)
-#define MODEXP_STATUS_READY (1)
-
-#define MODEXP_MODULUS_LENGTH (MODEXP_ADDR_BASE + 0x20)
-#define MODEXP_EXPONENT_LENGTH (MODEXP_ADDR_BASE + 0x21)
-#define MODEXP_LENGTH (MODEXP_ADDR_BASE + 0x22)
-
-#define MODEXP_MODULUS_PTR_RST (MODEXP_ADDR_BASE + 0x30)
-#define MODEXP_MODULUS_DATA (MODEXP_ADDR_BASE + 0x31)
-
-#define MODEXP_EXPONENT_PTR_RST (MODEXP_ADDR_BASE + 0x40)
-#define MODEXP_EXPONENT_DATA (MODEXP_ADDR_BASE + 0x41)
-
-#define MODEXP_MESSAGE_PTR_RST (MODEXP_ADDR_BASE + 0x50)
-#define MODEXP_MESSAGE_DATA (MODEXP_ADDR_BASE + 0x51)
-
-#define MODEXP_RESULT_PTR_RST (MODEXP_ADDR_BASE + 0x60)
-#define MODEXP_RESULT_DATA (MODEXP_ADDR_BASE + 0x61)
-
-#define MODEXP_NAME0 "mode"
-#define MODEXP_NAME1 "xp "
-#define MODEXP_VERSION "0.51"
+/*
+ * ModExpS6 core. MODEXPS6_OPERAND_BITS is size in bits of largest
+ * supported modulus.
+ */
+#define MODEXPS6_ADDR_BASE (SEGMENT_OFFSET_MATH + (0x00 * MATH_CORE_SIZE))
+#define MODEXPS6_OPERAND_BITS (4096)
+#define MODEXPS6_OPERAND_WORDS (MODEXPS6_OPERAND_BITS/32)
+#define MODEXPS6_ADDR_REGISTERS (MODEXPS6_ADDR_BASE + 0*MODEXPS6_OPERAND_WORDS)
+#define MODEXPS6_ADDR_OPERANDS (MODEXPS6_ADDR_BASE + 4*MODEXPS6_OPERAND_WORDS)
+#define MODEXPS6_ADDR_NAME0 (MODEXPS6_ADDR_REGISTERS + ADDR_NAME0)
+#define MODEXPS6_ADDR_NAME1 (MODEXPS6_ADDR_REGISTERS + ADDR_NAME1)
+#define MODEXPS6_ADDR_VERSION (MODEXPS6_ADDR_REGISTERS + ADDR_VERSION)
+#define MODEXPS6_ADDR_CTRL (MODEXPS6_ADDR_REGISTERS + ADDR_CTRL)
+#define MODEXPS6_ADDR_STATUS (MODEXPS6_ADDR_REGISTERS + ADDR_STATUS)
+#define MODEXPS6_ADDR_MODE (MODEXPS6_ADDR_REGISTERS + 0x10)
+#define MODEXPS6_ADDR_MODULUS_WIDTH (MODEXPS6_ADDR_REGISTERS + 0x11)
+#define MODEXPS6_ADDR_EXPONENT_WIDTH (MODEXPS6_ADDR_REGISTERS + 0x12)
+#define MODEXPS6_ADDR_MODULUS (MODEXPS6_ADDR_OPERANDS + 0*MODEXPS6_OPERAND_WORDS)
+#define MODEXPS6_ADDR_MESSAGE (MODEXPS6_ADDR_OPERANDS + 1*MODEXPS6_OPERAND_WORDS)
+#define MODEXPS6_ADDR_EXPONENT (MODEXPS6_ADDR_OPERANDS + 2*MODEXPS6_OPERAND_WORDS)
+#define MODEXPS6_ADDR_RESULT (MODEXPS6_ADDR_OPERANDS + 3*MODEXPS6_OPERAND_WORDS)
+#define MODEXPS6_NAME0 "mode"
+#define MODEXPS6_NAME1 "xps6"
+#define MODEXPS6_VERSION "0.10"
/*
* C API error codes. Defined in this form so we can keep the tokens
@@ -525,6 +519,7 @@ typedef struct {
const uint8_t * const digest_algorithm_id;
size_t digest_algorithm_id_length;
const hal_hash_driver_t *driver;
+ unsigned can_restore_state : 1;
} hal_hash_descriptor_t;
/*
@@ -574,6 +569,9 @@ extern hal_error_t hal_hmac_update(hal_hmac_state_t *state,
extern hal_error_t hal_hmac_finalize(hal_hmac_state_t *state,
uint8_t *hmac, const size_t length);
+extern void hal_hash_cleanup(hal_hash_state_t **state);
+
+extern void hal_hmac_cleanup(hal_hmac_state_t **state);
/*
* AES key wrap functions.