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

Document OpenBSDBCrypt password handling #1742

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ public static byte[] passwordToByteArray(char[] password)

/**
* Calculates the <b>bcrypt</b> hash of an input - note for processing general passwords you want to
* make sure the password is terminated in a manner similar to what is done by passwordToByteArray().
* make sure the password is terminated in a manner similar to what is done by {@link #passwordToByteArray(char[])}.
* <p>
* This implements the raw <b>bcrypt</b> function as defined in the bcrypt specification, not
* the crypt encoded version implemented in OpenBSD.
* the crypt encoded version implemented in OpenBSD, see {@link OpenBSDBCrypt} for that.
* </p>
* @param pwInput the password bytes (up to 72 bytes) to use for this invocation.
* @param salt the 128 bit salt to use for this invocation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
* Password hashing scheme BCrypt,
* designed by Niels Provos and David Mazières, using the
* String format and the Base64 encoding
* of the reference implementation on OpenBSD
* of the reference implementation on OpenBSD.
* <p>
* Passwords are encoded using UTF-8. Encoded passwords longer than
Copy link
Author

@Marcono1234 Marcono1234 Jul 21, 2024

Choose a reason for hiding this comment

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

Regarding UTF-8: Do you think this wording here is misleading and it should say that this only applies when the password is provided as char[] (but not when provided as byte[])? Or is it fine like this?

And do you think it is clear enough that the "encoded passwords longer than ..." applies as well when users provide an already encoded password as byte[]?

* 72 bytes are truncated and all remaining bytes are ignored.
*/
public class OpenBSDBCrypt
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
* Password hashing scheme BCrypt,
* designed by Niels Provos and David Mazières, using the
* String format and the Base64 encoding
* of the reference implementation on OpenBSD
* of the reference implementation on OpenBSD.
* <p>
* Passwords are encoded using UTF-8. Encoded passwords longer than
* 72 bytes are truncated and all remaining bytes are ignored.
*/
public class OpenBSDBCrypt
{
Expand Down