2
0

Refactoring masterpassword-algorithm.

This commit is contained in:
Maarten Billemont
2018-05-16 00:12:31 -04:00
parent 8bdf1755b7
commit 0aa7baf59e
24 changed files with 468 additions and 479 deletions

View File

@@ -118,8 +118,8 @@ public abstract class MPBasicSite implements MPSite {
throws MPKeyUnavailableException {
return getUser().getMasterKey().siteResult(
getName(), ifNotNullElse( counter, getAlgorithm().mpw_default_counter() ), keyPurpose, keyContext,
type, state, getAlgorithm() );
getName(), getAlgorithm(), ifNotNullElse( counter, getAlgorithm().mpw_default_counter() ),
keyPurpose, keyContext, type, state );
}
protected String getState(final MPKeyPurpose keyPurpose, @Nullable final String keyContext,
@@ -127,8 +127,8 @@ public abstract class MPBasicSite implements MPSite {
throws MPKeyUnavailableException {
return getUser().getMasterKey().siteState(
getName(), ifNotNullElse( counter, getAlgorithm().mpw_default_counter() ), keyPurpose, keyContext,
type, state, getAlgorithm() );
getName(), getAlgorithm(), ifNotNullElse( counter, getAlgorithm().mpw_default_counter() ),
keyPurpose, keyContext, type, state );
}
@Override

View File

@@ -49,7 +49,7 @@ public class MPFileUser extends MPBasicUser<MPFileSite> {
private MPJSONFile json;
public MPFileUser(final String fullName) {
this( fullName, null, MPMasterKey.Version.CURRENT.getAlgorithm() );
this( fullName, null, MPAlgorithm.Version.CURRENT.getAlgorithm() );
}
public MPFileUser(final String fullName, @Nullable final byte[] keyID, final MPAlgorithm algorithm) {

View File

@@ -76,7 +76,7 @@ public class MPFlatUnmarshaller implements MPUnmarshaller {
headerStarted = true;
else
// Ends the header.
user = new MPFileUser( fullName, keyID, MPMasterKey.Version.fromInt( mpVersion ).getAlgorithm(),
user = new MPFileUser( fullName, keyID, MPAlgorithm.Version.fromInt( mpVersion ).getAlgorithm(),
avatar, defaultType, new DateTime( 0 ), MPMarshalFormat.Flat,
clearContent? MPMarshaller.ContentMode.VISIBLE : MPMarshaller.ContentMode.PROTECTED );
@@ -117,7 +117,7 @@ public class MPFlatUnmarshaller implements MPUnmarshaller {
switch (importFormat) {
case 0:
site = new MPFileSite( user, //
siteMatcher.group( 5 ), MPMasterKey.Version.fromInt( ConversionUtils.toIntegerNN(
siteMatcher.group( 5 ), MPAlgorithm.Version.fromInt( ConversionUtils.toIntegerNN(
colon.matcher( siteMatcher.group( 4 ) ).replaceAll( "" ) ) ).getAlgorithm(),
user.getAlgorithm().mpw_default_counter(),
MPResultType.forType( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ),
@@ -130,7 +130,7 @@ public class MPFlatUnmarshaller implements MPUnmarshaller {
case 1:
site = new MPFileSite( user, //
siteMatcher.group( 7 ), MPMasterKey.Version.fromInt( ConversionUtils.toIntegerNN(
siteMatcher.group( 7 ), MPAlgorithm.Version.fromInt( ConversionUtils.toIntegerNN(
colon.matcher( siteMatcher.group( 4 ) ).replaceAll( "" ) ) ).getAlgorithm(),
UnsignedInteger.valueOf( colon.matcher( siteMatcher.group( 5 ) ).replaceAll( "" ) ),
MPResultType.forType( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ),

View File

@@ -72,8 +72,8 @@ public class MPJSONFile extends MPJSONAnyObject {
// Clear Text
content = modelSite.getResult();
loginContent = modelUser.getMasterKey().siteResult(
modelSite.getName(), modelSite.getAlgorithm().mpw_default_counter(),
MPKeyPurpose.Identification, null, modelSite.getLoginType(), modelSite.getLoginState(), modelSite.getAlgorithm() );
modelSite.getName(), modelSite.getAlgorithm(), modelSite.getAlgorithm().mpw_default_counter(),
MPKeyPurpose.Identification, null, modelSite.getLoginType(), modelSite.getLoginState() );
} else {
// Redacted
if (modelSite.getResultType().supportsTypeFeature( MPSiteFeature.ExportContent ))
@@ -134,7 +134,7 @@ public class MPJSONFile extends MPJSONAnyObject {
public MPFileUser read(@Nullable final char[] masterPassword)
throws MPIncorrectMasterPasswordException, MPKeyUnavailableException {
MPAlgorithm algorithm = ifNotNullElse( user.algorithm, MPMasterKey.Version.CURRENT ).getAlgorithm();
MPAlgorithm algorithm = ifNotNullElse( user.algorithm, MPAlgorithm.Version.CURRENT ).getAlgorithm();
MPFileUser model = new MPFileUser(
user.full_name, CodeUtils.decodeHex( user.key_id ), algorithm, user.avatar,
(user.default_type != null)? user.default_type: algorithm.mpw_default_result_type(),
@@ -192,7 +192,7 @@ public class MPJSONFile extends MPJSONAnyObject {
@Nullable
String key_id;
@Nullable
MPMasterKey.Version algorithm;
MPAlgorithm.Version algorithm;
@Nullable
MPResultType default_type;
}
@@ -203,7 +203,7 @@ public class MPJSONFile extends MPJSONAnyObject {
@Nullable
MPResultType type;
long counter;
MPMasterKey.Version algorithm;
MPAlgorithm.Version algorithm;
@Nullable
String password;
@Nullable