diff options
author | Technion <technion@lolware.net> | 2015-01-04 22:01:16 +0000 |
---|---|---|
committer | Technion <technion@lolware.net> | 2015-01-04 22:01:16 +0000 |
commit | 4df2c4c7033670fcc14048a505efc24666c7834c (patch) | |
tree | c26e9c6a0139690a667104240215656416cee714 | |
parent | 2077980fb15f3196a49f7891a13d9dd268b6d890 (diff) |
Tests and documentaiton regarding #35.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | main.c | 12 |
2 files changed, 14 insertions, 0 deletions
@@ -26,6 +26,8 @@ Sane constants have been created for N, r and p so you can create a hash like th libscrypt_hash(outbuf, "My cats's breath smells like cat food", SCRYPT_N, SCRYPT_r, SCRYPT_p); +This function sets errno as required for any error conditions. + Output stored in "outbuf" is stored in a standardised MCF form, which means includes the randomly created, 128 bit salt, all N, r and p values, and a BASE64 encoded version of the hash. The entire MCF can be stored in a database, and compared for use as below: retval = libscrypt_check(mcf, "pleasefailme"); @@ -1,6 +1,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <errno.h> #include "b64.h" #include "crypto_scrypt-hexconvert.h" @@ -43,6 +44,17 @@ int main() printf("TEST ONE: SUCCESSFUL\n"); + printf("TEST ONE and a half: Review errno on invalid input\n"); + + retval = libscrypt_scrypt((uint8_t*)"password",strlen("password"), (uint8_t*)"NaCl", strlen("NaCl"), 47, 1, 1, hashbuf, sizeof(hashbuf)); + + if(retval != -1) + { + printf("TEST ONE FAILED: Failed to detect invalid input\n"); + exit(EXIT_FAILURE); + } + printf("TEST ONE and a half: Successfully failed on error: %s\n", strerror(errno)); + /* Convert the binary string to hex representation. Outbuf must be * at least sizeof(hashbuf) * 2 + 1 * Returns 0 on fail, 1 on success |