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

Difference between native and java implementation #52

@trauchhaupt

Description

@trauchhaupt

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();
}
}
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions