How can I use the Argon2 KDF in Processing?

Hello,
I am trying to write a simple Messenger myself, and of course I can’t simply send the password of the user to the backend. I found this GitHub repo, but I’m not quite sure how to use it. Cloning it with git and placing in the libaries folder inside the /Documents/Processing folder seems not to work. It’s structure is a completely other than the contributed libaries, but I found the Java source in Processing\libraries\argon2-jvm-master\src\main\java\de\mkammerer\argon2\ and a .jar file in Processing\libraries\argon2-jvm-master\gradle\wrapper. But when I try to compile with java C:\Users\<username>\Documents\Processing\libraries\argon2-jvm-master\src\main\java\de\mkammerer\argon2\Argon2.java, it says, “the main class could not be found”.

A bit additional background, i’m worrying about the security of my messenger.
My OS: Windows 10
Processing 3.5.4
I have Java 8 myself installed

Thanks to everybody who tries to help me.

1 Like

According to the Argon2 JVM repo that you linked it is sourceCompatibility = 1.6 – so it should work fine with Java8. Also, keep in mind that if you are using the Processing IDE (rather than Processing as a library, e.g. in Eclipse) then it uses its own internal Java 8, no matter what Java(s) you have installed on your system.

Are you writing a private messenger app using processing sketches as the messenger clients, e.g. for the desktop? And you want to log in to a server is using an Argon2 hash?

Here is a tutorial that might be helpful:

2 Likes

First, thank you for your answer.
Second, in the tutorial stands: Let’s take a look at an example. First, add a dependency to your Maven’s pom.xml file to include argon2-jvm:

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

I heard Maven makes builds easier, but is Processing using it? Following, how can I add an dependency/include to my sketch? (Sorry if this all are idiotic questions, Processing is my first contact with Java)

Third, yes, I am writing an private messenger app with Processing, and I am writing the backend with Python’s Flask. For authentication I am using the HTTP Requests Library and Basic Authentication with POST Requests. I want to deveriate a key from the password of the user, and then send this key to the server, so he can search the user in his database and returns if he had success.

I haven’t tried using Maven with Processing – I was assuming that you would simply add the jar files you need to MySketchFolder/code/theArgonJAr.jar.

Anything in the code folder is in your sketch path, so you can import from it as per the tutorial. I don’t know about other dependencies.

1 Like

Hm, I am not sure if you mean the gradle-wrapper.jar in argon2-jvm-master\gradle\wrapper. Can I simply make a subdirectory named code and put the gradle-wrapper.jar in it? Then, should I then import it with

import de.mkammerer.argon2.Argon2;

or

import gradle-wrapper.argon2.Argon2;

?
Should I copy the gradle-wrapper.properties alongside with it? Should I copy the whole directory alongside with it, or is everything included in gradle-wrapper.jar? (So many questions… thank you for your patience)

EDIT: Renaming it into grwp.jar and putting it into my code folder does not seem to work. Processing always cries,

No library found for grwp
Libraries must be installed in a folder named 'libraries' inside the sketchbook folder (see the Preferences window).
The package “grwp” does not exist. You might be missing a library.

After closing Processing and putting the grwp.jar it into the libraries folder and reopening Processing, it shows in Sketch->Import Library grwp. But when I click on it, the following imports appear:

import org.gradle.wrapper.*;
import org.gradle.cli.*;

which are not what I wanted. So where should I get the right .jar file?

1 Like

For the import statements in the tutorial, I think you might want

https://jar-download.com/artifacts/de.mkammerer/argon2-jvm/2.6/source-code

[Note: untested, I don’t know if this is a safe source, I just used it to peek at the jar contents]

but again, I know nothing about what dependencies if any might be missing – and if this client is a Java API to a system tool then you could need the non Java binary as well.

1 Like

Got it!
Indeed the link was the right .jar file, and it seems safe, I tested the file here and the site here. I put the argon2-jvm-2.4.jar in Processing\processing-3.5.4\libraries\argon2lib\library\ and renamed it into argon2lib.jar. When I started Processing, in Sketch->Import Library appears argon2lib. When I click on it, the following appears in my sketch:
grafik
Success! Only one more thing: In the tutorial is used to create an Argon2Factory:

Argon2 argon2 = Argon2Factory.create(Argon2Types.ARGON2id);

But it cries again, “Argon2Type could not be found”. So I let it at

Argon2 argon2 = Argon2Factory.create();

. Thank you for your help.

1 Like