Add test cases to test personal type passwords as well.

[ADDED]     Support for personal type passwords in the standard test cases.
This commit is contained in:
Maarten Billemont 2021-05-16 15:56:57 -04:00
parent 5c1924eb6f
commit c47d6074c1
2 changed files with 50 additions and 8 deletions

View file

@ -73,6 +73,16 @@
<resultType>Phrase</resultType> <resultType>Phrase</resultType>
<result>re monnu mit jededda</result> <result>re monnu mit jededda</result>
</case> </case>
<case id="v3_type_personal" parent="v3">
<resultType>Personal</resultType>
<resultParam>IfzlLN4J7XNazwSa17xB7A==</resultParam>
<result>password</result>
</case>
<case id="v3_type_personal_mb" parent="v3">
<resultType>Personal</resultType>
<resultParam>det+TQ+yVcDxLZ30EE7hMw==</resultParam>
<result></result>
</case>
<case id="v3_counter_ceiling" parent="v3"> <case id="v3_counter_ceiling" parent="v3">
<keyCounter>4294967295</keyCounter> <keyCounter>4294967295</keyCounter>
<result>ZurdYoda6:Jogs</result> <result>ZurdYoda6:Jogs</result>
@ -139,6 +149,16 @@
<resultType>Phrase</resultType> <resultType>Phrase</resultType>
<result>re monnu mit jededda</result> <result>re monnu mit jededda</result>
</case> </case>
<case id="v2_type_personal" parent="v2">
<resultType>Personal</resultType>
<resultParam>IfzlLN4J7XNazwSa17xB7A==</resultParam>
<result>password</result>
</case>
<case id="v2_type_personal_mb" parent="v2">
<resultType>Personal</resultType>
<resultParam>det+TQ+yVcDxLZ30EE7hMw==</resultParam>
<result></result>
</case>
<case id="v2_counter_ceiling" parent="v2"> <case id="v2_counter_ceiling" parent="v2">
<keyCounter>4294967295</keyCounter> <keyCounter>4294967295</keyCounter>
<result>ZurdYoda6:Jogs</result> <result>ZurdYoda6:Jogs</result>
@ -205,6 +225,16 @@
<resultType>Phrase</resultType> <resultType>Phrase</resultType>
<result>re monnu mit jededda</result> <result>re monnu mit jededda</result>
</case> </case>
<case id="v1_type_personal" parent="v1">
<resultType>Personal</resultType>
<resultParam>IfzlLN4J7XNazwSa17xB7A==</resultParam>
<result>password</result>
</case>
<case id="v1_type_personal_mb" parent="v1">
<resultType>Personal</resultType>
<resultParam>det+TQ+yVcDxLZ30EE7hMw==</resultParam>
<result></result>
</case>
<case id="v1_counter_ceiling" parent="v1"> <case id="v1_counter_ceiling" parent="v1">
<keyCounter>4294967295</keyCounter> <keyCounter>4294967295</keyCounter>
<result>ZurdYoda6:Jogs</result> <result>ZurdYoda6:Jogs</result>
@ -271,6 +301,16 @@
<resultType>Phrase</resultType> <resultType>Phrase</resultType>
<result>ne xoccu tix fepepla</result> <result>ne xoccu tix fepepla</result>
</case> </case>
<case id="v0_type_personal" parent="v0">
<resultType>Personal</resultType>
<resultParam>IfzlLN4J7XNazwSa17xB7A==</resultParam>
<result>password</result>
</case>
<case id="v0_type_personal_mb" parent="v0">
<resultType>Personal</resultType>
<resultParam>det+TQ+yVcDxLZ30EE7hMw==</resultParam>
<result></result>
</case>
<case id="v0_counter_ceiling" parent="v0"> <case id="v0_counter_ceiling" parent="v0">
<keyCounter>4294967295</keyCounter> <keyCounter>4294967295</keyCounter>
<result>WunoRopz1!Fovw</result> <result>WunoRopz1!Fovw</result>

View file

@ -100,6 +100,7 @@ int main(int argc, char *const argv[]) {
xmlChar *siteName = spectre_xmlTestCaseString( testCase, "siteName" ); xmlChar *siteName = spectre_xmlTestCaseString( testCase, "siteName" );
SpectreCounter keyCounter = (SpectreCounter)spectre_xmlTestCaseInteger( testCase, "keyCounter" ); SpectreCounter keyCounter = (SpectreCounter)spectre_xmlTestCaseInteger( testCase, "keyCounter" );
xmlChar *resultTypeString = spectre_xmlTestCaseString( testCase, "resultType" ); xmlChar *resultTypeString = spectre_xmlTestCaseString( testCase, "resultType" );
xmlChar *resultParam = spectre_xmlTestCaseString( testCase, "resultParam" );
xmlChar *keyPurposeString = spectre_xmlTestCaseString( testCase, "keyPurpose" ); xmlChar *keyPurposeString = spectre_xmlTestCaseString( testCase, "keyPurpose" );
xmlChar *keyContext = spectre_xmlTestCaseString( testCase, "keyContext" ); xmlChar *keyContext = spectre_xmlTestCaseString( testCase, "keyContext" );
xmlChar *result = spectre_xmlTestCaseString( testCase, "result" ); xmlChar *result = spectre_xmlTestCaseString( testCase, "result" );
@ -115,13 +116,13 @@ int main(int argc, char *const argv[]) {
if (strstr((char *)id, argv[optind]) == (char *)id) if (strstr((char *)id, argv[optind]) == (char *)id)
selected = true; selected = true;
if (!selected) if (!selected)
continue; break;
} }
fprintf( stdout, "test case %s... ", id ); fprintf( stdout, "test case %s... ", id );
if (!xmlStrlen( result )) { if (!xmlStrlen( result )) {
fprintf( stdout, "abstract." ); fprintf( stdout, "abstract.\n" );
continue; break;
} }
// 1. calculate the user key. // 1. calculate the user key.
@ -129,23 +130,23 @@ int main(int argc, char *const argv[]) {
(char *)userName, (char *)userSecret, algorithm ); (char *)userName, (char *)userSecret, algorithm );
if (!userKey) { if (!userKey) {
ftl( "Couldn't derive user key." ); ftl( "Couldn't derive user key." );
abort(); break;
} }
// Check the user key. // Check the user key.
if (!spectre_id_equals( &keyID, &userKey->keyID )) { if (!spectre_id_equals( &keyID, &userKey->keyID )) {
++failedTests; ++failedTests;
fprintf( stdout, "FAILED! (keyID: got %s != expected %s)\n", userKey->keyID.hex, keyID.hex ); fprintf( stdout, "FAILED! (keyID: got %s != expected %s)\n", userKey->keyID.hex, keyID.hex );
continue; break;
} }
// 2. calculate the site password. // 2. calculate the site password.
const char *testResult = spectre_site_result( const char *testResult = spectre_site_result(
userKey, (char *)siteName, resultType, NULL, keyCounter, keyPurpose, (char *)keyContext ); userKey, (char *)siteName, resultType, (char *)resultParam, keyCounter, keyPurpose, (char *)keyContext );
spectre_free( &userKey, sizeof( *userKey ) ); spectre_free( &userKey, sizeof( *userKey ) );
if (!testResult) { if (!testResult) {
ftl( "Couldn't derive site password." ); ftl( "Couldn't derive site password." );
continue; break;
} }
// Check the site result. // Check the site result.
@ -153,7 +154,7 @@ int main(int argc, char *const argv[]) {
++failedTests; ++failedTests;
fprintf( stdout, "FAILED! (result: got %s != expected %s)\n", testResult, result ); fprintf( stdout, "FAILED! (result: got %s != expected %s)\n", testResult, result );
spectre_free_string( &testResult ); spectre_free_string( &testResult );
continue; break;
} }
spectre_free_string( &testResult ); spectre_free_string( &testResult );
@ -166,6 +167,7 @@ int main(int argc, char *const argv[]) {
xmlFree( userSecret ); xmlFree( userSecret );
xmlFree( siteName ); xmlFree( siteName );
xmlFree( resultTypeString ); xmlFree( resultTypeString );
xmlFree( resultParam );
xmlFree( keyPurposeString ); xmlFree( keyPurposeString );
xmlFree( keyContext ); xmlFree( keyContext );
xmlFree( result ); xmlFree( result );