diff --git a/BUILDING b/BUILDING index 1be21dfe..2e4eec3b 100644 --- a/BUILDING +++ b/BUILDING @@ -15,6 +15,15 @@ Official scrypt tarball releases should build and run on any IEEE Std 1003.1 3. Provides /dev/urandom. +libscrypt +--------- + +To install the development library, run: + + ./configure --enable-libscrypt + make install + + Platform-specific notes ----------------------- diff --git a/README.md b/README.md index 9e1d0d08..2083587f 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,16 @@ int crypto_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t, uint32_t, uint32_t, uint8_t *, size_t); ``` +There is a sample of using `crypto_scrypt()` in `tests/libscrypt`. If you +installed `libscrypt`, you can compile that file and run the binary: + +``` +$ cd tests/libscrypt/ +$ cc sample-libscrypt.c -lscrypt +$ ./a.out +crypto_scrypt(): success +``` + Building -------- diff --git a/tests/libscrypt/sample-libscrypt.c b/tests/libscrypt/sample-libscrypt.c new file mode 100644 index 00000000..9d0c17a7 --- /dev/null +++ b/tests/libscrypt/sample-libscrypt.c @@ -0,0 +1,33 @@ +#include +#include +#include + +#include "crypto_scrypt.h" + +/* Parameters controlling memory usage and CPU time. */ +#define N 16384 +#define r 8 +#define p 1 + +/* How much data should scrypt return? */ +#define OUTPUT_BUFLEN 8 + +int main() +{ + const char * passwd = "hunter2"; + const char * salt = "DANGER -- this should be a random salt -- DANGER"; + uint8_t output[OUTPUT_BUFLEN]; + int exitcode; + + exitcode = crypto_scrypt((const uint8_t *)passwd, strlen(passwd), + (const uint8_t*)salt, strlen(salt), N, r, p, + output, OUTPUT_BUFLEN); + + /* Notify user of success / failure. */ + if (exitcode == 0) + printf("crypto_scrypt(): success\n"); + else + printf("crypto_scrypt(): failure %i\n", exitcode); + + return (exitcode); +}