aboutsummaryrefslogtreecommitdiff
path: root/hal_internal.h
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-09-12 15:59:06 -0400
committerRob Austein <sra@hactrn.net>2016-09-12 16:03:49 -0400
commit8c3743eee739afa344139ab17d8008131555862d (patch)
treed037f9a0c6c7c5962819a06e6a0967f1bcc976b6 /hal_internal.h
parent73d62a85a904b64e259d523dadb45ad4ee8e2c2f (diff)
CRC-32 code for use in ks_flash, stm32 DFU, possibly elsewhere.
This is an open source C99 CRC-32 implementation generated by pycrc, see notes in source on copyright status and pycrc options used. crc32.c contains two different implementations of the CRC-32 algorithm with the same API, one optimized for speed, the other optimized for much smaller code space at the expense of speed. We use the fast implementation by default, but maybe the small implementation will be useful, eg, in the bootloader. Remove the extra later if this turns out to have been a waste of time.
Diffstat (limited to 'hal_internal.h')
-rw-r--r--hal_internal.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/hal_internal.h b/hal_internal.h
index 5e6b939..e92f22a 100644
--- a/hal_internal.h
+++ b/hal_internal.h
@@ -255,6 +255,7 @@ extern hal_error_t hal_rpc_pkcs1_construct_digestinfo(const hal_hash_handle_t ha
/*
* UUID stuff. All UUIDs we use (or are likely to use) are type 4 "random" UUIDs
+ * Some of this may need to move to hal.h.
*/
#define HAL_UUID_TEXT_SIZE (sizeof("00112233-4455-6677-8899-aabbccddeeff"))
@@ -271,6 +272,28 @@ extern hal_error_t hal_uuid_parse(hal_uuid_t *uuid, const char * const string);
extern hal_error_t hal_uuid_format(const hal_uuid_t * const uuid, char *buffer, const size_t buffer_len);
/*
+ * CRC-32 stuff (for flash keystore, etc). Dunno if we want a Verilog
+ * implementation of this, or if it would even be faster than doing it
+ * the main CPU taking I/O overhead and so forth into account.
+ *
+ * These prototypes were generated by pycrc.py, see notes in crc32.c.
+ */
+
+typedef uint32_t hal_crc32_t;
+
+static inline hal_crc32_t hal_crc32_init(void)
+{
+ return 0xffffffff;
+}
+
+extern hal_crc32_t hal_crc32_update(hal_crc32_t crc, const void *data, size_t data_len);
+
+static inline hal_crc32_t hal_crc32_finalize(hal_crc32_t crc)
+{
+ return crc ^ 0xffffffff;
+}
+
+/*
* Keystore API.
*/