diff --git a/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MasterKey.java b/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MasterKey.java index a13ed702..a1013c1c 100644 --- a/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MasterKey.java +++ b/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MasterKey.java @@ -112,6 +112,8 @@ public class MasterKey { siteContext == null? "(null)": siteContext ); byte[] sitePasswordInfo = Bytes.concat( siteScope.getBytes( MP_charset ), siteNameLengthBytes, siteNameBytes, siteCounterBytes ); + if (siteContextBytes != null) + sitePasswordInfo = Bytes.concat( sitePasswordInfo, siteContextLengthBytes, siteContextBytes ); logger.trc( "sitePasswordInfo ID: %s", CodeUtils.encodeHex( idForBytes( sitePasswordInfo ) ) ); byte[] sitePasswordSeed = MP_mac.of( masterKey, sitePasswordInfo ); diff --git a/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MPWTests.java b/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MPWTests.java index a77ba0ca..bcd145f9 100644 --- a/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MPWTests.java +++ b/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MPWTests.java @@ -4,6 +4,7 @@ import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*; import com.lyndir.lhunath.opal.system.logging.Logger; import com.lyndir.lhunath.opal.system.util.NNSupplier; +import com.lyndir.lhunath.opal.system.util.NSupplier; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -117,7 +118,7 @@ public class MPWTests { return parentCase.getSiteVariant().name(); } } ); - siteContext = ifNotNullElse( siteContext, new NNSupplier() { + siteContext = ifNotNullElseNullable( siteContext, new NSupplier() { @Nonnull @Override public String get() { diff --git a/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MasterKeyTest.java b/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MasterKeyTest.java index 2758c01f..523dc44b 100644 --- a/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MasterKeyTest.java +++ b/MasterPassword/Java/masterpassword-algorithm/src/test/java/com/lyndir/masterpassword/MasterKeyTest.java @@ -3,6 +3,7 @@ package com.lyndir.masterpassword; import static org.testng.Assert.*; import com.google.common.io.Resources; +import com.lyndir.lhunath.opal.system.CodeUtils; import com.lyndir.lhunath.opal.system.logging.Logger; import java.net.URL; import javax.xml.bind.JAXBContext; @@ -35,9 +36,9 @@ public class MasterKeyTest { for (MPWTests.Case testCase : tests.getCases()) { MasterKey masterKey = new MasterKey( testCase.getFullName(), testCase.getMasterPassword() ); - assertEquals( masterKey.encode( testCase.getSiteName(), testCase.getSiteType(), testCase.getSiteCounter(), - testCase.getSiteVariant(), testCase.getSiteContext() ), testCase.getResult(), - "Failed test case: " + testCase ); + assertEquals( + masterKey.encode( testCase.getSiteName(), testCase.getSiteType(), testCase.getSiteCounter(), testCase.getSiteVariant(), + testCase.getSiteContext() ), testCase.getResult(), "Failed test case: " + testCase ); } } @@ -55,7 +56,7 @@ public class MasterKeyTest { for (MPWTests.Case testCase : tests.getCases()) { MasterKey masterKey = new MasterKey( testCase.getFullName(), testCase.getMasterPassword() ); - assertEquals( masterKey.getKeyID(), testCase.getKeyID(), "Failed test case: " + testCase ); + assertEquals( CodeUtils.encodeHex( masterKey.getKeyID() ), testCase.getKeyID(), "Failed test case: " + testCase ); } } diff --git a/MasterPassword/Java/masterpassword-algorithm/src/test/resources/mpw_tests.xml b/MasterPassword/Java/masterpassword-algorithm/src/test/resources/mpw_tests.xml index b5d4e41f..09ca5a21 100644 --- a/MasterPassword/Java/masterpassword-algorithm/src/test/resources/mpw_tests.xml +++ b/MasterPassword/Java/masterpassword-algorithm/src/test/resources/mpw_tests.xml @@ -7,7 +7,6 @@ 1 GeneratedLong Password - Jejr5[RepuSosp