diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2017-11-10 08:01:50 +0100 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2017-11-14 13:48:32 +0100 |
commit | 33790cc18342231b13f7e6791196bd7c1f41e33f (patch) | |
tree | a472e2cf502f4a4edabe6418a0b5150d105c9aec /core/crypto | |
parent | 8875ce46f413b5f5b4e6d73707672d8a3f51f92c (diff) |
Replace struct bignum_ops with function interface
Adds crypto_bignum_*() replacing struct bignum_ops in crypto_ops.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/crypto')
-rw-r--r-- | core/crypto/crypto.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/core/crypto/crypto.c b/core/crypto/crypto.c index a396e8e6..899695e9 100644 --- a/core/crypto/crypto.c +++ b/core/crypto/crypto.c @@ -6,6 +6,7 @@ */ #include <compiler.h> +#include <kernel/panic.h> #include <tee/tee_cryp_provider.h> #if !defined(_CFG_CRYPTO_WITH_HASH) @@ -161,3 +162,73 @@ void crypto_authenc_final(void *ctx __unused, uint32_t algo __unused) { } #endif /*_CFG_CRYPTO_WITH_AUTHENC*/ + +#if !defined(_CFG_CRYPTO_WITH_ACIPHER) +struct bignum *crypto_bignum_allocate(size_t size_bits __unused) +{ + return NULL; +} + +TEE_Result crypto_bignum_bin2bn(const uint8_t *from __unused, + size_t fromsize __unused, + struct bignum *to __unused) +{ + return TEE_ERROR_NOT_IMPLEMENTED; +} + +size_t crypto_bignum_num_bytes(struct bignum *a __unused) +{ + return 0; +} + +size_t crypto_bignum_num_bits(struct bignum *a __unused) +{ + return 0; +} + +/* + * crypto_bignum_allocate() and crypto_bignum_bin2bn() failing should be + * enough to guarantee that the functions calling this function aren't + * called, but just in case add a panic() here to avoid unexpected + * behavoir. + */ +static void bignum_cant_happen(void) +{ + volatile bool b = true; + + /* Avoid warning about function does not return */ + if (b) + panic(); +} + +void crypto_bignum_bn2bin(const struct bignum *from __unused, + uint8_t *to __unused) +{ + bignum_cant_happen(); +} + +void crypto_bignum_copy(struct bignum *to __unused, + const struct bignum *from __unused) +{ + bignum_cant_happen(); +} + +void crypto_bignum_free(struct bignum *a) +{ + if (a) + panic(); +} + +void crypto_bignum_clear(struct bignum *a __unused) +{ + bignum_cant_happen(); +} + +/* return -1 if a<b, 0 if a==b, +1 if a>b */ +int32_t crypto_bignum_compare(struct bignum *a __unused, + struct bignum *b __unused) +{ + bignum_cant_happen(); + return -1; +} +#endif /*!_CFG_CRYPTO_WITH_ACIPHER*/ |