mpw-tests was not checking mpw_tests.xml's keyID.
This commit is contained in:
parent
34540f0844
commit
dc7089c38c
@ -57,6 +57,7 @@ int main(int argc, char *const argv[]) {
|
|||||||
MPKeyPurpose keyPurpose = mpw_purposeWithName( (char *)keyPurposeString );
|
MPKeyPurpose keyPurpose = mpw_purposeWithName( (char *)keyPurposeString );
|
||||||
|
|
||||||
// Run the test case.
|
// Run the test case.
|
||||||
|
do {
|
||||||
fprintf( stdout, "test case %s... ", id );
|
fprintf( stdout, "test case %s... ", id );
|
||||||
if (!xmlStrlen( result )) {
|
if (!xmlStrlen( result )) {
|
||||||
fprintf( stdout, "abstract.\n" );
|
fprintf( stdout, "abstract.\n" );
|
||||||
@ -68,29 +69,39 @@ int main(int argc, char *const argv[]) {
|
|||||||
(char *)fullName, (char *)masterPassword, algorithm );
|
(char *)fullName, (char *)masterPassword, algorithm );
|
||||||
if (!masterKey) {
|
if (!masterKey) {
|
||||||
ftl( "Couldn't derive master key.\n" );
|
ftl( "Couldn't derive master key.\n" );
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the master key.
|
||||||
|
MPKeyID testKeyID = mpw_id_buf( masterKey, MPMasterKeySize );
|
||||||
|
if (xmlStrcmp( keyID, BAD_CAST testKeyID ) != 0) {
|
||||||
|
++failedTests;
|
||||||
|
fprintf( stdout, "FAILED! (keyID: got %s != expected %s)\n", testKeyID, keyID );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. calculate the site password.
|
// 2. calculate the site password.
|
||||||
const char *sitePassword = mpw_siteResult(
|
const char *testResult = mpw_siteResult(
|
||||||
masterKey, (char *)siteName, siteCounter, keyPurpose, (char *)keyContext, resultType, NULL, algorithm );
|
masterKey, (char *)siteName, siteCounter, keyPurpose, (char *)keyContext, resultType, NULL, algorithm );
|
||||||
mpw_free( &masterKey, MPMasterKeySize );
|
mpw_free( &masterKey, MPMasterKeySize );
|
||||||
if (!sitePassword) {
|
if (!testResult) {
|
||||||
ftl( "Couldn't derive site password.\n" );
|
ftl( "Couldn't derive site password.\n" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the result.
|
// Check the site result.
|
||||||
if (xmlStrcmp( result, BAD_CAST sitePassword ) == 0)
|
if (xmlStrcmp( result, BAD_CAST testResult ) != 0) {
|
||||||
fprintf( stdout, "pass.\n" );
|
|
||||||
|
|
||||||
else {
|
|
||||||
++failedTests;
|
++failedTests;
|
||||||
fprintf( stdout, "FAILED! (got %s != expected %s)\n", sitePassword, result );
|
fprintf( stdout, "FAILED! (result: got %s != expected %s)\n", testResult, result );
|
||||||
|
mpw_free_string( &testResult );
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
mpw_free_string( &testResult );
|
||||||
|
|
||||||
|
fprintf( stdout, "pass.\n" );
|
||||||
|
} while(false);
|
||||||
|
|
||||||
// Free test case.
|
// Free test case.
|
||||||
mpw_free_string( &sitePassword );
|
|
||||||
xmlFree( id );
|
xmlFree( id );
|
||||||
xmlFree( fullName );
|
xmlFree( fullName );
|
||||||
xmlFree( masterPassword );
|
xmlFree( masterPassword );
|
||||||
|
Loading…
Reference in New Issue
Block a user