Split the API into the three distinct phases of the mpw algorithm.
This commit is contained in:
@@ -64,7 +64,7 @@ int main(int argc, char *const argv[]) {
|
||||
// Similar to phase-two of mpw
|
||||
uint8_t *sitePasswordInfo = malloc( 128 );
|
||||
iterations = 3000000;
|
||||
masterKey = mpw_masterKeyForUser( fullName, masterPassword, MPAlgorithmVersionCurrent );
|
||||
masterKey = mpw_masterKey( fullName, masterPassword, MPAlgorithmVersionCurrent );
|
||||
if (!masterKey)
|
||||
ftl( "Could not allocate master key: %d\n", errno );
|
||||
mpw_getTime( &startTime );
|
||||
@@ -95,7 +95,7 @@ int main(int argc, char *const argv[]) {
|
||||
iterations = 50;
|
||||
mpw_getTime( &startTime );
|
||||
for (int i = 1; i <= iterations; ++i) {
|
||||
free( (void *)mpw_masterKeyForUser( fullName, masterPassword, MPAlgorithmVersionCurrent ) );
|
||||
free( (void *)mpw_masterKey( fullName, masterPassword, MPAlgorithmVersionCurrent ) );
|
||||
|
||||
if (modff(100.f * i / iterations, &percent) == 0)
|
||||
fprintf( stderr, "\rscrypt_mpw: iteration %d / %d (%.0f%%)..", i, iterations, percent );
|
||||
@@ -107,13 +107,16 @@ int main(int argc, char *const argv[]) {
|
||||
iterations = 50;
|
||||
mpw_getTime( &startTime );
|
||||
for (int i = 1; i <= iterations; ++i) {
|
||||
masterKey = mpw_masterKeyForUser( fullName, masterPassword, MPAlgorithmVersionCurrent );
|
||||
masterKey = mpw_masterKey( fullName, masterPassword, MPAlgorithmVersionCurrent );
|
||||
if (!masterKey)
|
||||
ftl( "Could not allocate master key: %d\n", errno );
|
||||
|
||||
free( (void *)mpw_passwordForSite(
|
||||
masterKey, siteName, siteType, siteCounter, siteVariant, siteContext, MPAlgorithmVersionCurrent ) );
|
||||
MPSiteKey siteKey = mpw_siteKey(
|
||||
masterKey, siteName, siteCounter, siteVariant, siteContext, MPAlgorithmVersionCurrent );
|
||||
free( (void *)mpw_sitePassword(
|
||||
siteKey, siteType, MPAlgorithmVersionCurrent ) );
|
||||
free( (void *)masterKey );
|
||||
free( (void *)siteKey );
|
||||
|
||||
if (modff(100.f * i / iterations, &percent) == 0)
|
||||
fprintf( stderr, "\rmpw: iteration %d / %d (%.0f%%)..", i, iterations, percent );
|
||||
|
@@ -311,16 +311,17 @@ int main(int argc, char *const argv[]) {
|
||||
mpw_free_string( identicon );
|
||||
|
||||
// Output the password.
|
||||
MPMasterKey masterKey = mpw_masterKeyForUser(
|
||||
MPMasterKey masterKey = mpw_masterKey(
|
||||
fullName, masterPassword, algorithmVersion );
|
||||
mpw_free_string( masterPassword );
|
||||
mpw_free_string( fullName );
|
||||
if (!masterKey)
|
||||
ftl( "Couldn't derive master key." );
|
||||
|
||||
const char *sitePassword = mpw_passwordForSite(
|
||||
masterKey, siteName, siteType, siteCounter, siteVariant, siteContextArg, algorithmVersion );
|
||||
MPSiteKey siteKey = mpw_siteKey( masterKey, siteName, siteCounter, siteVariant, siteContextArg, algorithmVersion );
|
||||
const char *sitePassword = mpw_sitePassword(siteKey, siteType, algorithmVersion );
|
||||
mpw_free( masterKey, MPMasterKeySize );
|
||||
mpw_free( siteKey, MPSiteKeySize );
|
||||
mpw_free_string( siteName );
|
||||
if (!sitePassword)
|
||||
ftl( "Couldn't derive site password." );
|
||||
|
@@ -24,7 +24,7 @@ int main(int argc, char *const argv[]) {
|
||||
|
||||
// Read in the test case.
|
||||
xmlChar *id = mpw_xmlTestCaseString( testCase, "id" );
|
||||
uint32_t algorithm = mpw_xmlTestCaseInteger( testCase, "algorithm" );
|
||||
MPAlgorithmVersion algorithm = (MPAlgorithmVersion)mpw_xmlTestCaseInteger( testCase, "algorithm" );
|
||||
xmlChar *fullName = mpw_xmlTestCaseString( testCase, "fullName" );
|
||||
xmlChar *masterPassword = mpw_xmlTestCaseString( testCase, "masterPassword" );
|
||||
xmlChar *keyID = mpw_xmlTestCaseString( testCase, "keyID" );
|
||||
@@ -46,15 +46,18 @@ int main(int argc, char *const argv[]) {
|
||||
}
|
||||
|
||||
// 1. calculate the master key.
|
||||
MPMasterKey masterKey = mpw_masterKeyForUser(
|
||||
MPMasterKey masterKey = mpw_masterKey(
|
||||
(char *)fullName, (char *)masterPassword, algorithm );
|
||||
if (!masterKey)
|
||||
ftl( "Couldn't derive master key." );
|
||||
|
||||
// 2. calculate the site password.
|
||||
const char *sitePassword = mpw_passwordForSite(
|
||||
masterKey, (char *)siteName, siteType, siteCounter, siteVariant, (char *)siteContext, algorithm );
|
||||
MPSiteKey siteKey = mpw_siteKey(
|
||||
masterKey, (char *)siteName, siteCounter, siteVariant, (char *)siteContext, algorithm );
|
||||
const char *sitePassword = mpw_sitePassword(
|
||||
siteKey, siteType, algorithm );
|
||||
mpw_free( masterKey, MPMasterKeySize );
|
||||
mpw_free( siteKey, MPSiteKeySize );
|
||||
if (!sitePassword)
|
||||
ftl( "Couldn't derive site password." );
|
||||
|
||||
|
Reference in New Issue
Block a user