Add native yescrypt ($y$) format#6013
Conversation
|
I opened a PR with an initial working implementation: #6013 It calls src/yescrypt/ directly (the same yescrypt_r() that scrypt_fmt.c Known limitation: valid() is intentionally permissive right now -- it Tested locally against self-generated |
|
Update: Just pushed an update refactoring the code to handle raw binaries and bumped MAX_KEYS_PER_CRYPT to 128 for a massive speedup and better OpenMP scaling. |
|
Thank you for the contribution, and I'm sorry I didn't implement this properly years ago. My plan was to add an exported parameter parser function to yescrypt itself, and then use that here, but I never got around to doing that - hopefully I will.
I don't see any pushed update here.
I don't know what this means.
This sounds wrong to me. These hashes are supposed to be slow enough that high MKPC should be both unnecessary and problematic in other ways. |
| length = base64_valid_length(p, e_b64_cryptBS, flg_Base64_NO_FLAGS, 0); | ||
|
|
||
| /* yescrypt hashes are 32 raw bytes -> 43 base64 chars, same alphabet as scrypt */ | ||
| return p[length] == 0 && length >= 43; |
There was a problem hiding this comment.
I think we should require exactly 43 here. The >= was added in 1a4fb06 to support what I think are Django scrypt hashes. yescrypt encoding does not support such long hashes.
| static int cmp_all(void *binary, int count) | ||
| { | ||
| int index; | ||
| int len = strlen(buffer[0].out) - 2; |
There was a problem hiding this comment.
We shouldn't do the - 2 thing in cmp_all and cmp_one. Basically, just revert this back to simple strcmp:
$ git show 1a4fb06cb5 | tail -25
@@ -366,9 +388,13 @@ static int crypt_all(int *pcount, struct db_salt *salt)
static int cmp_all(void *binary, int count)
{
int index;
+ // binary was created as 32 bytes. It will always be
+ // <= length of buffer.out. So we use the binary as
+ // our hash indication lentth (and avoid looking at last byte)
+ int len = strlen(buffer[0].out)-2;
for (index = 0; index < count; index++)
- if (!strcmp((char *)binary, buffer[index].out))
+ if (!strncmp((char *)binary, buffer[index].out, len))
return 1;
return 0;
@@ -376,7 +402,8 @@ static int cmp_all(void *binary, int count)
static int cmp_one(void *binary, int index)
{
- return !strcmp((char *)binary, buffer[index].out);
+ int len = strlen(buffer[index].out)-2;
+ return !strncmp((char *)binary, buffer[index].out,len);
}
static int cmp_exact(char *source, int index)
|
When you do push any update, please amend and force-push the one commit - don't add more commits. BTW, you seem to have some processing of dollar signs in your commit message and first comment here - you'll need to fix this in the commit message at least. |
98221a0 to
6d9b1bc
Compare
|
Hi @solardiz, I have amended the commit and force-pushed the updates to address your feedback. Here is a summary of the changes made inside the code:
Everything is now clean, consolidated into a single commit, and ready for your review. Thanks! |
c9e6db2 to
8a5818e
Compare
8a5818e to
a468bed
Compare
Adds a native format for yescrypt (yy
y) hashes, calling src/yescrypt/ directly instead of going through the slow generic crypt(3) fallback. Related to issue #4621. This is an initial working version — valid() is intentionally permissive and doesn't yet fully decode all flavor/N/r/p/t/g/NROM parameters like scrypt_fmt.c does for 77
7. Tested against self-generated yy
y hashes and confirms correct cracking.