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