CHG: 'emv roca' - added selftest and textual layouts'

DEL: removed unused old emv files
This commit is contained in:
Chris
2019-01-01 10:53:41 +01:00
parent 0ddda8998e
commit 75d0b0b06f
6 changed files with 22 additions and 422 deletions

View File

@@ -1456,7 +1456,6 @@ int CmdEMVScan(const char *cmd) {
return 0;
}
int CmdEMVList(const char *Cmd) {
return CmdTraceList("7816");
}
@@ -1476,10 +1475,13 @@ int CmdEMVRoca(const char *cmd) {
CLIParserInit("emv roca",
"Tries to extract public keys and run the ROCA test against them.\n",
"Usage:\n"
"\temv roca -w -> select CONTACT card and run test\n\temv roca -> select CONTACTLESS card and run test\n");
"\temv roca -w -> select --CONTACT-- card and run test\n"
"\temv roca -> select --CONTACTLESS-- card and run test\n"
);
void* argtable[] = {
arg_param_begin,
arg_lit0("tT", "selftest", "self test"),
arg_lit0("wW", "wired", "Send data via contact (iso7816) interface. Contactless interface set by default."),
arg_param_end
};
@@ -1487,6 +1489,9 @@ int CmdEMVRoca(const char *cmd) {
EMVCommandChannel channel = ECC_CONTACTLESS;
if (arg_get_lit(1))
return roca_self_test();
if (arg_get_lit(2))
channel = ECC_CONTACT;
// select card

View File

@@ -138,11 +138,10 @@ cleanup:
return ret;
}
int roca_self_test( int verbose ) {
int roca_self_test(void) {
int ret = 0;
if( verbose != 0 )
printf( "\nROCA check vulnerability tests\n" );
PrintAndLogEx(INFO, "ROCA check vulnerability tests" );
// positive
uint8_t keyp[] = "\x94\x4e\x13\x20\x8a\x28\x0c\x37\xef\xc3\x1c\x31\x14\x48\x5e\x59"\
@@ -150,16 +149,13 @@ int roca_self_test( int verbose ) {
"\x27\x83\x30\xd3\xf4\x71\xa2\x53\x8f\xa6\x67\x80\x2e\xd2\xa3\xc4"\
"\x4a\x8b\x7d\xea\x82\x6e\x88\x8d\x0a\xa3\x41\xfd\x66\x4f\x7f\xa7";
if( verbose != 0 )
printf( " ROCA positive test: " );
if (emv_rocacheck(keyp, 64, false)) {
if( verbose != 0 )
printf( "passed\n" );
} else {
ret = 1;
if( verbose != 0 )
printf( "failed\n" );
PrintAndLogEx(SUCCESS, "Weak modulus [ %s]", _GREEN_(PASS) );
}
else {
ret++;
PrintAndLogEx(FAILED, "Weak modulus [ %s]", _RED_(FAIL) );
}
// negative
@@ -168,18 +164,12 @@ int roca_self_test( int verbose ) {
"\x27\x83\x30\xd3\xf4\x71\xa2\x53\x8f\xa6\x67\x80\x2e\xd2\xa3\xc4"\
"\x4a\x8b\x7d\xea\x82\x6e\x88\x8d\x0a\xa3\x41\xfd\x66\x4f\x7f\xa7";
if( verbose != 0 )
printf( " ROCA negative test: " );
if (emv_rocacheck(keyn, 64, false)) {
ret = 1;
if( verbose != 0 )
printf( "failed\n" );
ret++;
PrintAndLogEx(FAILED, "Strong modulus [ %s]", _RED_(FAIL) );
} else {
if( verbose != 0 )
printf( "passed\n" );
PrintAndLogEx(SUCCESS, "Strong modulus [ %s]", _GREEN_(PASS) );
}
return ret;
}

View File

@@ -32,7 +32,7 @@
#define ROCA_PRINTS_LENGTH 17
extern bool emv_rocacheck( const unsigned char *buf, size_t buflen, bool verbose );
extern int roca_self_test( int verbose );
extern int roca_self_test( void );
#endif

View File

@@ -91,14 +91,15 @@ int ExecuteCryptoTests(bool verbose) {
res = exec_crypto_test(verbose);
if (res) TestFail = true;
res = roca_self_test(verbose);
res = roca_self_test();
if (res) TestFail = true;
PrintAndLog("\n--------------------------");
if (TestFail)
PrintAndLog("Test(s) [ERROR].");
PrintAndLogEx(FAILED, "\tTest(s) [ %s ]", _RED_(FAIL) );
else
PrintAndLog("Tests [OK].");
PrintAndLogEx(SUCCESS, "\tTest(s) [ %s ]", _GREEN_(OK) );
return TestFail;
}