From 5f152f558e7bc8fc8d93ae250bdc61cd60ab5acd Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Thu, 11 Jun 2015 10:53:26 -0400 Subject: First cut at RSA decryption/signature using the Chinese Remainder Theorem. Not yet tested, and given the number of moving parts I would be astonished if this version actually worked, but it does compile. Added some timing code to tests/test-rsa.c so we can see whether this is doing anything useful once it does work. --- cryptech.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cryptech.h') diff --git a/cryptech.h b/cryptech.h index 1ca6a89..6f7d439 100644 --- a/cryptech.h +++ b/cryptech.h @@ -442,6 +442,10 @@ DEFINE_HAL_ERROR(HAL_ERROR_KEYWRAP_BAD_MAGIC, "Bad magic number while unwrapping key") \ DEFINE_HAL_ERROR(HAL_ERROR_KEYWRAP_BAD_LENGTH, "Length out of range while unwrapping key") \ DEFINE_HAL_ERROR(HAL_ERROR_KEYWRAP_BAD_PADDING, "Non-zero padding detected unwrapping key") \ + DEFINE_HAL_ERROR(HAL_ERROR_CRT_FAILED, "CRT calculation failed") \ + DEFINE_HAL_ERROR(HAL_ERROR_ALLOCATION_FAILURE, "Memory allocation failed") \ + DEFINE_HAL_ERROR(HAL_ERROR_UNKNOWN_TFM_FAILURE, "Unknown libtfm failure") \ + DEFINE_HAL_ERROR(HAL_ERROR_RESULT_TOO_LONG, "Result too long for buffer") \ END_OF_HAL_ERROR_LIST /* Marker to forestall silly line continuation errors */ @@ -595,6 +599,22 @@ extern hal_error_t hal_modexp(const uint8_t * const msg, const size_t msg_len, / uint8_t * result, const size_t result_len); +/* + * RSA. This is not the real API (yet), just test functions for debugging. + */ + +extern void hal_rsa_set_debug(const int onoff); + +extern hal_error_t hal_rsa_crt(const uint8_t * const m, const size_t m_len, + const uint8_t * const n, const size_t n_len, + const uint8_t * const e, const size_t e_len, + const uint8_t * const d, const size_t d_len, + const uint8_t * const p, const size_t p_len, + const uint8_t * const q, const size_t q_len, + const uint8_t * const u, const size_t u_len, + uint8_t * result, const size_t result_len); + + #endif /* _CRYPTECH_H_ */ -- cgit v1.2.3