aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-22 09:34:37 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-22 09:34:37 +0000
commit695dbad0846781728a1c0d95343ea64a39f4eaa3 (patch)
tree2c76a1300fe1bb65d60678743d3a14fdfcab54f9 /os/hal/ports
parent39daa496e9b2a7c3825ca102fa3c7462dc6683fc (diff)
downloadChibiOS-695dbad0846781728a1c0d95343ea64a39f4eaa3.tar.gz
ChibiOS-695dbad0846781728a1c0d95343ea64a39f4eaa3.tar.bz2
ChibiOS-695dbad0846781728a1c0d95343ea64a39f4eaa3.zip
More crypto code, still unfinished.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10870 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports')
-rw-r--r--os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c29
-rw-r--r--os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h66
2 files changed, 85 insertions, 10 deletions
diff --git a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c
index 37cdb2a71..a843ddd44 100644
--- a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c
+++ b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.c
@@ -34,8 +34,8 @@
/* Driver exported variables. */
/*===========================================================================*/
-/** @brief CRYP1 driver identifier.*/
-#if STM32_CRY_USE_CRYP1 || defined(__DOXYGEN__)
+/** @brief CRY1 driver identifier.*/
+#if PLATFORM_CRY_USE_CRY1 || defined(__DOXYGEN__)
CRYDriver CRYD1;
#endif
@@ -92,6 +92,31 @@ void cry_lld_stop(CRYDriver *cryp) {
}
}
+/**
+ * @brief Initializes the transient key for a specific algorithm.
+ *
+ * @param[in] cryp pointer to the @p CRYDriver object
+ * @param[in] keyp pointer to the key data
+ * @return The operation status.
+ * @retval CRY_NOERROR if the operation succeeded.
+ * @retval CRY_ERR_INV_ALGO if the specified algorithm is unknown or
+ * unsupported.
+ * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid.
+ *
+ * @notapi
+ */
+cryerror_t cry_lld_loadkey(CRYDriver *cryp,
+ cryalgorithm_t algorithm,
+ size_t size,
+ const uint8_t *keyp) {
+
+ (void)cryp;
+ (void)algorithm;
+ (void)size;
+ (void)keyp;
+
+ return CRY_NOERROR;
+}
#endif /* HAL_USE_CRY */
/** @} */
diff --git a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h
index e7279728b..2bc94b31d 100644
--- a/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h
+++ b/os/hal/ports/STM32/LLD/CRYPv1/hal_crypto_lld.h
@@ -107,23 +107,21 @@ typedef struct {
*/
struct CRYDriver {
/**
- * @brief Driver state.
+ * @brief Driver state.
*/
crystate_t state;
/**
- * @brief Current configuration data.
+ * @brief Current configuration data.
*/
const CRYConfig *config;
/**
- * @brief Waiting thread.
+ * @brief Algorithm type of transient key.
*/
- thread_reference_t thread;
-#if (CRY_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
+ cryalgorithm_t key0_type;
/**
- * @brief Mutex protecting the peripheral.
+ * @brief Size of transient key.
*/
- mutex_t mutex;
-#endif
+ size_t key0_size;
#if defined(CRY_DRIVER_EXT_FIELDS)
CRY_DRIVER_EXT_FIELDS
#endif
@@ -148,6 +146,58 @@ extern "C" {
void cry_lld_init(void);
void cry_lld_start(CRYDriver *cryp);
void cry_lld_stop(CRYDriver *cryp);
+ cryerror_t cry_lld_loadkey(CRYDriver *cryp,
+ cryalgorithm_t algorithm,
+ size_t size,
+ const uint8_t *keyp);
+ cryerror_t cry_lld_encrypt_AES_ECB(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out);
+ cryerror_t cry_lld_decrypt_AES_ECB(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out);
+ cryerror_t cry_lld_encrypt_AES_CBC(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out,
+ const uint8_t *iv);
+ cryerror_t cry_lld_decrypt_AES_CBC(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out,
+ const uint8_t *iv);
+ cryerror_t cry_lld_encrypt_AES_CFB(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out,
+ const uint8_t *iv);
+ cryerror_t cry_lld_decrypt_AES_CFB(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out,
+ const uint8_t *iv);
+ cryerror_t cry_lld_encrypt_AES_CTR(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out,
+ const uint8_t *nonce,
+ uint8_t *cnt);
+ cryerror_t cry_lld_decrypt_AES_CTR(CRYDriver *cryp,
+ crykey_t key_id,
+ size_t size,
+ const uint8_t *in,
+ uint8_t *out,
+ const uint8_t *nonce,
+ uint8_t *cnt);
#ifdef __cplusplus
}
#endif