Fix JNI write-back, bad V3 api usage, duplicate length passing.
This commit is contained in:
@@ -28,3 +28,11 @@ processResources {
|
||||
}
|
||||
} )
|
||||
}
|
||||
|
||||
compileJava {
|
||||
doLast {
|
||||
ant.javah( class: 'com.lyndir.masterpassword.impl.MPAlgorithmV0',
|
||||
outputFile: '../../c/src/mpw-jni.h',
|
||||
classpath: files( sourceSets.main.compileClasspath, sourceSets.main.output ).asPath )
|
||||
}
|
||||
}
|
||||
|
@@ -90,15 +90,13 @@ public class MPAlgorithmV0 extends MPAlgorithm {
|
||||
@Nullable
|
||||
protected byte[] scrypt(final byte[] secret, final byte[] salt, final int keySize) {
|
||||
byte[] buffer = new byte[keySize];
|
||||
if (_scrypt(
|
||||
secret, secret.length, salt, salt.length,
|
||||
scrypt_N(), scrypt_r(), scrypt_p(), buffer, buffer.length ) < 0)
|
||||
if (_scrypt( secret, salt, scrypt_N(), scrypt_r(), scrypt_p(), buffer ) < 0)
|
||||
return null;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
protected native int _scrypt(byte[] passwd, int passwdlen, byte[] salt, int saltlen, int N, int r, int p, byte[] buf, int buflen);
|
||||
protected native int _scrypt(byte[] passwd, byte[] salt, int N, int r, int p, byte[] buf);
|
||||
|
||||
@Override
|
||||
public byte[] siteKey(final byte[] masterKey, final String siteName, UnsignedInteger siteCounter,
|
||||
|
@@ -50,7 +50,7 @@ public class MPAlgorithmV3 extends MPAlgorithmV2 {
|
||||
logger.trc( "masterKey: scrypt( masterPassword, masterKeySalt, N=%d, r=%d, p=%d )",
|
||||
scrypt_N(), scrypt_r(), scrypt_p() );
|
||||
byte[] masterPasswordBytes = toBytes( masterPassword );
|
||||
byte[] masterKey = scrypt( masterKeySalt, masterPasswordBytes, mpw_dkLen() );
|
||||
byte[] masterKey = scrypt( masterPasswordBytes, masterKeySalt, mpw_dkLen() );
|
||||
Arrays.fill( masterKeySalt, (byte) 0 );
|
||||
Arrays.fill( masterPasswordBytes, (byte) 0 );
|
||||
if (masterKey == null)
|
||||
|
@@ -60,7 +60,7 @@ public class MPTests {
|
||||
}
|
||||
|
||||
public Case getCase(final String identifier) {
|
||||
for (final Case testCase : getCases())
|
||||
for (final Case testCase : cases)
|
||||
if (identifier.equals( testCase.getIdentifier() ))
|
||||
return testCase;
|
||||
|
||||
|
@@ -39,7 +39,7 @@ public class MPMasterKeyTest {
|
||||
throws Exception {
|
||||
|
||||
testSuite = new MPTestSuite();
|
||||
//testSuite.getTests().addFilters( "v0" );
|
||||
//testSuite.getTests().addFilters( "v3_type_maximum" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user