phxql / argon2-jvm

Argon2 Binding for the JVM
GNU Lesser General Public License v3.0
330 stars 32 forks source link

Argon2Library.INSTANCE is null #96

Closed petulal closed 1 year ago

petulal commented 1 year ago

Hi there - we have recently upgraded our machines to the new mac m1 chips

I have included the correct dependency in my pom

 <dependency>
                <groupId>de.mkammerer</groupId>
                <artifactId>argon2-jvm</artifactId>
                <version>2.11</version>
            </dependency>

And the code to generate the hash is like this:

Argon2 argon2 = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2i, 16, 16);
        String hash = argon2.hash(10, 65536, 1, password.toCharArray());

        return hash.getBytes();

However when I step through the code it always drops off to the finally wipeArray line 85 at BaseArgon2 class. The line that is causing us problems is hashBytes line 280 because Argon2Library.INSTANCE is null. This is via debugging in intellij. I have also tried to run the tests via command line using maven and its the same results.

I have installed argon2 via brew and on the command line I can see that it has been installed

Can you please help me solve this problem? What am I missing?

Thank you in advance

EDIT: So I found out what was causing the issue: it was because the jdk that was downloaded previously was the x86-64 Have got the right jdk now . However it now fails at:

Argon2 argon2 = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2i, 16, 16);

NoClassDefError: Could not initilaize class de.mkammerer.argon2.Argon2Factory$Argon2Types

This line worked previously when I was using the nolibs version

phxql commented 1 year ago

Hm, looks like a JNA problem to me. Which version of JNA are you using? You can check with mvn dependency:tree or gradle dependencies.

Otherwise, could you please run https://github.com/phxql/jna-info and paste the output here?

petulal commented 1 year ago

Hi - I ran the jna-info and it outputted the following:

JNA version: 5.7.0 Prefix: darwin Arch: aarch64

Testing JNA... success

So I got the no libs version working, but I don't want to have to get every development machine to install the argon2 library (including our docker container during setup) so would prefer to get the with libs version working.

Thanks for your help

petulal commented 1 year ago

thank you I figured it out now and it works - I had jna conflicts with other libraries in the pom.