aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/templates
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-11-30 11:38:07 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-11-30 11:38:07 +0000
commit5b31410098434a2aff0c0729621fee6c6f2b3519 (patch)
tree488e5c2f056eea39a9405eeb3b487e5134df288c /os/hal/templates
parentf35ebd89d421105e8449d94c2bc80d81000e8246 (diff)
downloadChibiOS-5b31410098434a2aff0c0729621fee6c6f2b3519.tar.gz
ChibiOS-5b31410098434a2aff0c0729621fee6c6f2b3519.tar.bz2
ChibiOS-5b31410098434a2aff0c0729621fee6c6f2b3519.zip
Added SHAx and TRNG to the crypto driver model.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11090 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/templates')
-rw-r--r--os/hal/templates/hal_crypto_lld.c96
-rw-r--r--os/hal/templates/hal_crypto_lld.h11
2 files changed, 107 insertions, 0 deletions
diff --git a/os/hal/templates/hal_crypto_lld.c b/os/hal/templates/hal_crypto_lld.c
index 2d8a18ef1..d58af0bc1 100644
--- a/os/hal/templates/hal_crypto_lld.c
+++ b/os/hal/templates/hal_crypto_lld.c
@@ -855,6 +855,102 @@ cryerror_t cry_lld_decrypt_DES_CBC(CRYDriver *cryp,
return CRY_ERR_INV_ALGO;
}
+/**
+ * @brief Hash using SHA1.
+ * @NOTE Use of this algorithm is not recommended because proven weak.
+ *
+ * @param[in] cryp pointer to the @p CRYDriver object
+ * @param[in] size size of input buffer
+ * @param[in] in buffer containing the input text
+ * @param[out] out 160 bits output buffer
+ * @return The operation status.
+ * @retval CRY_NOERROR if the operation succeeded.
+ * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
+ * device instance.
+ *
+ * @api
+ */
+cryerror_t cry_lld_SHA1(CRYDriver *cryp, size_t size,
+ const uint8_t *in, uint8_t *out) {
+
+ (void)cryp;
+ (void)size;
+ (void)in;
+ (void)out;
+
+ return CRY_ERR_INV_ALGO;
+}
+
+/**
+ * @brief Hash using SHA256.
+ *
+ * @param[in] cryp pointer to the @p CRYDriver object
+ * @param[in] size size of input buffer
+ * @param[in] in buffer containing the input text
+ * @param[out] out 256 bits output buffer
+ * @return The operation status.
+ * @retval CRY_NOERROR if the operation succeeded.
+ * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
+ * device instance.
+ *
+ * @api
+ */
+cryerror_t cry_lld_SHA256(CRYDriver *cryp, size_t size,
+ const uint8_t *in, uint8_t *out) {
+
+ (void)cryp;
+ (void)size;
+ (void)in;
+ (void)out;
+
+ return CRY_ERR_INV_ALGO;
+}
+
+/**
+ * @brief Hash using SHA512.
+ *
+ * @param[in] cryp pointer to the @p CRYDriver object
+ * @param[in] size size of input buffer
+ * @param[in] in buffer containing the input text
+ * @param[out] out 512 bits output buffer
+ * @return The operation status.
+ * @retval CRY_NOERROR if the operation succeeded.
+ * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
+ * device instance.
+ *
+ * @api
+ */
+cryerror_t cry_lld_SHA512(CRYDriver *cryp, size_t size,
+ const uint8_t *in, uint8_t *out) {
+
+ (void)cryp;
+ (void)size;
+ (void)in;
+ (void)out;
+
+ return CRY_ERR_INV_ALGO;
+}
+
+/**
+ * @brief True random numbers generator.
+ *
+ * @param[in] cryp pointer to the @p CRYDriver object
+ * @param[out] out 128 bits output buffer
+ * @return The operation status.
+ * @retval CRY_NOERROR if the operation succeeded.
+ * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
+ * device instance.
+ *
+ * @api
+ */
+cryerror_t cry_lld_TRNG(CRYDriver *cryp, uint8_t *out) {
+
+ (void)cryp;
+ (void)out;
+
+ return CRY_ERR_INV_ALGO;
+}
+
#endif /* HAL_USE_CRY == TRUE */
/** @} */
diff --git a/os/hal/templates/hal_crypto_lld.h b/os/hal/templates/hal_crypto_lld.h
index 3900b5b64..31d458c08 100644
--- a/os/hal/templates/hal_crypto_lld.h
+++ b/os/hal/templates/hal_crypto_lld.h
@@ -44,6 +44,10 @@
#define CRY_LLD_SUPPORTS_DES TRUE
#define CRY_LLD_SUPPORTS_DES_ECB TRUE
#define CRY_LLD_SUPPORTS_DES_CBC TRUE
+#define CRY_LLD_SUPPORTS_SHA1 TRUE
+#define CRY_LLD_SUPPORTS_SHA256 TRUE
+#define CRY_LLD_SUPPORTS_SHA512 TRUE
+#define CRY_LLD_SUPPORTS_TRNG TRUE
/** @{ */
/*===========================================================================*/
@@ -246,6 +250,13 @@ extern "C" {
const uint8_t *in,
uint8_t *out,
const uint8_t *iv);
+ cryerror_t cry_lld_SHA1(CRYDriver *cryp, size_t size,
+ const uint8_t *in, uint8_t *out);
+ cryerror_t cry_lld_SHA256(CRYDriver *cryp, size_t size,
+ const uint8_t *in, uint8_t *out);
+ cryerror_t cry_lld_SHA512(CRYDriver *cryp, size_t size,
+ const uint8_t *in, uint8_t *out);
+ cryerror_t cry_lld_TRNG(CRYDriver *cryp, uint8_t *out);
#ifdef __cplusplus
}
#endif