Simple hashing & checking example doesn't work
Closed this issue · 4 comments
paulwal commented
What am I doing wrong?
Example output:
$s1$0e0810$gDkDQGQo0pFlOyhbMbsFOA==$iyKYbepoMPb63RE0ED3iG05MccJCGBSy0sMFN/SvbybRwuDxyxmdPBBAe2pR6QC3HOVc9KGxJ99w9mNg9NdMAw=
retval:0
#include <stdio.h>
#include <stdlib.h>
#include <libscrypt.h>
int main (void)
{
char mcf[SCRYPT_MCF_LEN];
libscrypt_hash(mcf, "test", SCRYPT_N, SCRYPT_r, SCRYPT_p);
printf("%s\n", mcf);
int a = libscrypt_check(mcf, "test");
printf("retval:%d\n", a);
return 0;
}
jvarho commented
Your mcf is missing a final '=', most likely because you have an old version of libscrypt that had a bug in the return value.
paulwal commented
Wow, yeah that's it. I also had to change the string size to [SCRYPT_MCF_LEN+1]
This is the package libscrypt-dev 1-2.2 on Debian 8.11.
jvarho commented
Yeah, that's quite old. The versions 1.21-something in debian 9 and ubuntu 16.04 and newer run your example as is.
paulwal commented
Thanks