Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Difference between native and java implementation #52

Open
trauchhaupt opened this issue Jun 9, 2020 · 0 comments
Open

Difference between native and java implementation #52

trauchhaupt opened this issue Jun 9, 2020 · 0 comments

Comments

@trauchhaupt
Copy link

When I use the native library to crypt an empty string ("") there is a result.
When I use the java code to crypt an empty string ("") I get the Exception
Exception in thread "main" java.lang.IllegalArgumentException: Empty key at java.base/javax.crypto.spec.SecretKeySpec.<init>(SecretKeySpec.java:95) at com.lambdaworks.crypto.SCrypt.scryptJ(SCrypt.java:87) at de.empic.scryptbug.Main.main(Main.java:19)

Example code to reproduce (on linux only):
`import java.security.GeneralSecurityException;
import java.security.SecureRandom;

import com.lambdaworks.crypto.SCrypt;

public class Main
{
private static final int CPU_COST = 16384;
private static final int MEMORY_COST = 8;
private static final int PARALLELIZATION = 1;

public static void main(String[] args) throws Exception
{
byte[] salt = new byte[16];
SecureRandom.getInstance("SHA1PRNG").nextBytes(salt);
final byte[] emptyStringInBytes = "".getBytes("UTF-8");
try
{
byte[] resultJava = SCrypt.scryptJ(emptyStringInBytes, salt, CPU_COST, MEMORY_COST, PARALLELIZATION, 32);
}
catch (GeneralSecurityException e)
{
e.printStackTrace();
}
try
{
byte[] resultNative = SCrypt.scryptN(emptyStringInBytes, salt, CPU_COST, MEMORY_COST, PARALLELIZATION, 32);
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant