]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/emv/test/cryptotest.c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2017 Merlok
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // Crypto algorithms testing
9 //-----------------------------------------------------------------------------
11 #include "cryptotest.h"
15 #include "mbedtls/bignum.h"
16 #include "mbedtls/aes.h"
17 #include "mbedtls/cmac.h"
18 #include "mbedtls/des.h"
19 #include "mbedtls/ecp.h"
20 #include "mbedtls/rsa.h"
21 #include "mbedtls/sha1.h"
22 #include "mbedtls/md5.h"
23 #include "mbedtls/x509.h"
24 #include "mbedtls/base64.h"
25 #include "mbedtls/ctr_drbg.h"
26 #include "mbedtls/entropy.h"
27 #include "mbedtls/timing.h"
29 #include "crypto_test.h"
33 #include "crypto/libpcrypto.h"
34 #include "emv/emv_roca.h"
36 int ExecuteCryptoTests(bool verbose
) {
38 bool TestFail
= false;
40 res
= mbedtls_mpi_self_test(verbose
);
41 if (res
) TestFail
= true;
43 res
= mbedtls_aes_self_test(verbose
);
44 if (res
) TestFail
= true;
46 res
= mbedtls_des_self_test(verbose
);
47 if (res
) TestFail
= true;
49 res
= mbedtls_sha1_self_test(verbose
);
50 if (res
) TestFail
= true;
52 res
= mbedtls_md5_self_test(verbose
);
53 if (res
) TestFail
= true;
55 res
= mbedtls_rsa_self_test(verbose
);
56 if (res
) TestFail
= true;
58 res
= mbedtls_entropy_self_test(verbose
);
59 if (res
) TestFail
= true;
61 res
= mbedtls_timing_self_test(verbose
);
62 if (res
) TestFail
= true;
64 res
= mbedtls_ctr_drbg_self_test(verbose
);
65 if (res
) TestFail
= true;
67 res
= mbedtls_base64_self_test(verbose
);
68 if (res
) TestFail
= true;
70 res
= mbedtls_cmac_self_test(verbose
);
71 if (res
) TestFail
= true;
73 res
= ecdsa_nist_test(verbose
);
74 if (res
) TestFail
= true;
76 res
= mbedtls_ecp_self_test(verbose
);
77 if (res
) TestFail
= true;
79 res
= mbedtls_x509_self_test(verbose
);
80 if (res
) TestFail
= true;
82 res
= exec_sda_test(verbose
);
83 if (res
) TestFail
= true;
85 res
= exec_dda_test(verbose
);
86 if (res
) TestFail
= true;
88 res
= exec_cda_test(verbose
);
89 if (res
) TestFail
= true;
91 res
= exec_crypto_test(verbose
);
92 if (res
) TestFail
= true;
94 res
= roca_self_test();
95 if (res
) TestFail
= true;
97 PrintAndLog("\n--------------------------");
99 PrintAndLogEx(FAILED
, "\tTest(s) [ %s ]", _RED_(FAIL
) );
101 PrintAndLogEx(SUCCESS
, "\tTest(s) [ %s ]", _GREEN_(OK
) );