Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add argon2 hash functions #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gmsvalente
Copy link

Adds argon2 encryption to the encryption methods offered by this library

@weavejester
Copy link
Owner

Thanks for the patch. Can you remove any code unrelated to the feature being implemented?

Copy link
Owner

@weavejester weavejester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. Can you ensure any lines in the README are within 72 character, and any lines in the source code are within 80 characters. Once that's done, could you squash down your commits?

Could you also explain your choice of default parameters?

See:
https://infosecscout.com/best-algorithm-password-storage
https://github.com/phxql/argon2-jvm"
(:import (de.mkammerer.argon2 Argon2 Argon2Factory Argon2Advanced)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the () into [] to ensure it's consistent with the rest of the library?

@gmsvalente
Copy link
Author

Hello Mr. Reeves,

Firstly, thank you for your patience, and sorry for the mess I will squash down my commits, just see if it is ok for you now.

About the parameters, I followed this https://github.com/phxql/argon2-jvm#recommended-parameters, and take the default-iterations number by running the function,

(de.mkammerer.argon2.Argon2Helper/findIterations argon2 1000 default-memory-cost default-parallelization-parameter)

;;; (findIterations argon2 maxMillisecs memory parallelism)
;;; argon2       <-- argon2 instance
;;; maxMillisecs <-- Millisecs that the hash must take
;;; memory       <-- Sets memory usage to x kibibytes
;;; parallelism  <-- Number of threads and compute lane

Which give me the answer 22 used at default-iterations

For reference:

I was thinking of doing something like this on my side here:

(def default-memory-cost ,,,)
(def default-parallelization-parameter ,,,)

(defn n-iters []
 (Argon2Helper/findIterations argon2 1000 default-memory-cost default-parallelization-parameter))

(def ^:private default-iterations
  (Long/parseLong (System/getProperty "crypto.password.argon2.default-iterations" (n-iters))))

Copy link
Owner

@weavejester weavejester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, and apologies for the delay. There's some very minor styling changes needed, but other than that the code looks fine. After you've addressed the changes, can you squash your commits down?

I have a small contributing document for my other repos that I haven't copied into this one quite yet.

(def ^:private default-parallelization-parameter
(Long/parseLong (System/getProperty "crypto.password.argon2.default-parallelization-parameter" "1")))


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this extra blank line?

Comment on lines 24 to 25
* `iter` - the number of iterations, defaults to 22 (see:
Argon2Helper/findIterations)
* `mem` - the memory cost, defaults to 65536
* `parallel` - the parallelization parameter, defaults to 1"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the default needs to be justified in the docstring. Better to just keep the relevant information for usage, and line up the definitions for clarity. So:

  * `iter`     - the number of iterations, defaults to 22
  * `mem`      - the memory cost, defaults to 65536
  * `parallel` - the parallelization parameter, defaults to 1

* `mem` - the memory cost, defaults to 65536
* `parallel` - the parallelization parameter, defaults to 1"
([raw]
(encrypt raw default-iterations default-memory-cost default-parallelization-parameter))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep this line within 80 characters? I know this rule is violated for the default parameter variables in all the namespaces, but we can fix that separately.


(defn check
"Compare a raw string with a string encrypted with the [[encrypt]]
function. Returns true if the string matches, false otherwise."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a single space after the .. So:

function. Returns true if the string matches, false otherwise."

@gmsvalente
Copy link
Author

gmsvalente commented May 4, 2023 via email

Co-authored-by: Soulflyer <iain.wood@flexiana.com>

Add deps.edn

Fix bad url in README

Remove unrelated code

Co-authored-by: Iain Wood <iain.wood@flexiana.com>

Remove more unrelated code

Co-authored-by: Iain Wood <iain.wood@flexiana.com>

Fix README and docstrings length

Fix format
@gmsvalente
Copy link
Author

gmsvalente commented Jun 1, 2023

Hi Mr. Reeves, please see if the changes are ok. And sorry about the delay!

@puchka
Copy link

puchka commented Dec 28, 2023

Hi @weavejester @gmsvalente, any update about this PR :)

Thanks,

Marius

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

Successfully merging this pull request may close these issues.

None yet

3 participants