blob: 5a8678afc5b248f4913fd88e34c81f6482c489ff [file] [log] [blame]
Jens Wiklandere9babd92018-04-20 11:20:59 +02001// SPDX-License-Identifier: BSD-2-Clause
2/* Copyright (c) 2018, Linaro Limited */
3
4#include <mbedtls_taf.h>
5#include <mbedtls/aes.h>
6#include <mbedtls/base64.h>
7#include <mbedtls/bignum.h>
8#include <mbedtls/des.h>
9#include <mbedtls/md5.h>
10#include <mbedtls/rsa.h>
11#include <mbedtls/sha1.h>
12#include <mbedtls/sha256.h>
13#include <mbedtls/x509.h>
14
15TEE_Result
16ta_entry_mbedtls_self_tests(uint32_t param_type,
17 TEE_Param params[TEE_NUM_PARAMS] __unused)
18{
19 const uint32_t exp_pt = TEE_PARAM_TYPES(TEE_PARAM_TYPE_NONE,
20 TEE_PARAM_TYPE_NONE,
21 TEE_PARAM_TYPE_NONE,
22 TEE_PARAM_TYPE_NONE);
23 if (param_type != exp_pt)
24 return TEE_ERROR_BAD_PARAMETERS;
25
26#ifdef CFG_TA_MBEDTLS_SELF_TEST
27#define DO_MBEDTLS_SELF_TEST(x) do { \
28 if (mbedtls_##x##_self_test(1)) { \
29 EMSG("mbedtls_%s_self_test: failed", #x); \
30 return TEE_ERROR_GENERIC; \
31 } \
32 } while (0)
33
34 DO_MBEDTLS_SELF_TEST(aes);
35 DO_MBEDTLS_SELF_TEST(des);
36 DO_MBEDTLS_SELF_TEST(md5);
37 DO_MBEDTLS_SELF_TEST(sha1);
38 DO_MBEDTLS_SELF_TEST(sha256);
39 DO_MBEDTLS_SELF_TEST(base64);
40 DO_MBEDTLS_SELF_TEST(mpi);
41 DO_MBEDTLS_SELF_TEST(rsa);
42 DO_MBEDTLS_SELF_TEST(x509);
43
44 return TEE_SUCCESS;
45#else
46 return TEE_ERROR_NOT_IMPLEMENTED;
47#endif
48}