summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTechnion <technion@lolware.net>2013-06-06 06:04:08 -0400
committerTechnion <technion@lolware.net>2013-06-06 06:04:08 -0400
commitf1dab123746babe78370e652bc8e52e2acadd6a3 (patch)
tree7d6b3cf770413515e8957fc612d80eaf115f89c6
parent8921653714fa99857613b5308144b4122bdba94a (diff)
Standardised naming. API now locked in.
-rw-r--r--README.md4
-rw-r--r--crypto-mcf.c2
-rw-r--r--crypto-scrypt-saltgen.c2
-rw-r--r--crypto_scrypt-check.c4
-rw-r--r--crypto_scrypt-hash.c8
-rw-r--r--crypto_scrypt-hexconvert.c2
-rw-r--r--crypto_scrypt-nosse.c2
-rw-r--r--libscrypt.h14
-rw-r--r--main.c22
9 files changed, 30 insertions, 30 deletions
diff --git a/README.md b/README.md
index 5898bd2..e29d3d7 100644
--- a/README.md
+++ b/README.md
@@ -14,10 +14,10 @@ http://www.lolware.net/libscrypt.html
Simple hashing interface
A hash can be generated using the following function:
-> int crypto_scrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8_t p)
+> int libscrypt_scrypt(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8_t p)
Sane constants have been created for N, r and p so you can create a has like this:
-> crypto_scrypt_hash(outbuf, "My cats's breath smells like cat food", SCRYPT_N, SCRYPT_r, SCRYPT_p);
+> libscrypt_scrypt(outbuf, "My cats's breath smells like cat food", SCRYPT_N, SCRYPT_r, SCRYPT_p);
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 = scrypt_check(mcf, "pleasefailme");
diff --git a/crypto-mcf.c b/crypto-mcf.c
index ac6ea70..b98b3e2 100644
--- a/crypto-mcf.c
+++ b/crypto-mcf.c
@@ -15,7 +15,7 @@ static float scrypt_log2( uint32_t n )
return (float)(log( n ) / log( 2 ));
}
-int crypto_scrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, char *mcf)
+int libscrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, char *mcf)
{
diff --git a/crypto-scrypt-saltgen.c b/crypto-scrypt-saltgen.c
index 3b73a22..82af842 100644
--- a/crypto-scrypt-saltgen.c
+++ b/crypto-scrypt-saltgen.c
@@ -5,7 +5,7 @@
#include "sha256.h"
-void scrypt_salt_gen(char *rand, size_t len)
+void libscrypt_salt_gen(char *rand, size_t len)
{
unsigned char buf[32];
diff --git a/crypto_scrypt-check.c b/crypto_scrypt-check.c
index 5d1b091..b2aebdf 100644
--- a/crypto_scrypt-check.c
+++ b/crypto_scrypt-check.c
@@ -6,7 +6,7 @@
#include "libscrypt.h"
#include "modp_b64.h"
-int scrypt_check(char *mcf, char *password)
+int libscrypt_check(char *mcf, char *password)
{
uint32_t params;
@@ -40,7 +40,7 @@ int scrypt_check(char *mcf, char *password)
*/
retval = modp_b64_decode(salt, tok, strlen(tok));
- retval = crypto_scrypt((uint8_t*)password,strlen(password), (uint8_t*)salt, retval, N, r, p, hashbuf, sizeof(hashbuf));
+ retval = libscrypt_scrypt((uint8_t*)password,strlen(password), (uint8_t*)salt, retval, N, r, p, hashbuf, sizeof(hashbuf));
if (retval != 0)
return retval;
diff --git a/crypto_scrypt-hash.c b/crypto_scrypt-hash.c
index fa8c146..70ff800 100644
--- a/crypto_scrypt-hash.c
+++ b/crypto_scrypt-hash.c
@@ -6,7 +6,7 @@
#include "libscrypt.h"
#include "modp_b64.h"
-int crypto_scrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8_t p)
+int libscrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8_t p)
{
int retval;
@@ -15,9 +15,9 @@ int crypto_scrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8
char outbuf[256];
char saltbuf[256];
- scrypt_salt_gen(salt, 16);
+ libscrypt_salt_gen(salt, 16);
- retval = crypto_scrypt((uint8_t*)passphrase,strlen(passphrase), (uint8_t*)salt, sizeof(salt), N, r, p, hashbuf, sizeof(hashbuf));
+ retval = libscrypt_scrypt((uint8_t*)passphrase,strlen(passphrase), (uint8_t*)salt, sizeof(salt), N, r, p, hashbuf, sizeof(hashbuf));
if(retval == -1)
return 0;
@@ -29,7 +29,7 @@ int crypto_scrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8
if(retval == -1)
return 0;
- retval = crypto_scrypt_mcf(N, r, p, saltbuf, outbuf, dst);
+ retval = libscrypt_mcf(N, r, p, saltbuf, outbuf, dst);
if(retval == -1)
return 0;
diff --git a/crypto_scrypt-hexconvert.c b/crypto_scrypt-hexconvert.c
index 806fd15..85d16f0 100644
--- a/crypto_scrypt-hexconvert.c
+++ b/crypto_scrypt-hexconvert.c
@@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdint.h>
-int crypto_scrypt_hexconvert(uint8_t *buf, size_t s, char *outbuf, size_t obs)
+int libscrypt_hexconvert(uint8_t *buf, size_t s, char *outbuf, size_t obs)
{
int i;
diff --git a/crypto_scrypt-nosse.c b/crypto_scrypt-nosse.c
index 8c013be..845f014 100644
--- a/crypto_scrypt-nosse.c
+++ b/crypto_scrypt-nosse.c
@@ -230,7 +230,7 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
* Return 0 on success; or -1 on error.
*/
int
-crypto_scrypt(const uint8_t * passwd, size_t passwdlen,
+libscrypt_scrypt(const uint8_t * passwd, size_t passwdlen,
const uint8_t * salt, size_t saltlen, uint64_t N, uint32_t r, uint32_t p,
uint8_t * buf, size_t buflen)
{
diff --git a/libscrypt.h b/libscrypt.h
index e1ccb28..fbbd802 100644
--- a/libscrypt.h
+++ b/libscrypt.h
@@ -13,7 +13,7 @@
* must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32. The parameter N
* must be a power of 2 greater than 1.
*
- * crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
+ * libscrypt_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
* password; duh
* N: CPU AND RAM cost (first modifier)
* r: RAM Cost
@@ -22,28 +22,28 @@
* standard unless you want to modify the CPU/RAM ratio.
* Return 0 on success; or -1 on error.
*/
-int crypto_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t,
+int libscrypt_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t,
uint32_t, uint32_t, uint8_t *, size_t);
/**
* Converts a binary string to a hex representation of that string
* outbuf must have size of at least buf * 2 + 1.
*/
-int crypto_scrypt_hexconvert(uint8_t *buf, size_t s, char *outbuf, size_t obs);
+int libscrypt_hexconvert(uint8_t *buf, size_t s, char *outbuf, size_t obs);
/* Converts a series of input parameters to a MCF form for storage */
-int crypto_scrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, char *mcf);
+int libscrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, char *mcf);
/* Generates a salt. This is not a cryptographically unpredictable function,
* but should produce appropriately randomised output for this purpose
*/
-void scrypt_salt_gen(char *rand, size_t len);
+void libscrypt_salt_gen(char *rand, size_t len);
/* Checks a given MCF against a password */
-int scrypt_check(char *mcf, char *password);
+int libscrypt_check(char *mcf, char *password);
/* Creates a hash of a passphrase using a randomly generated salt */
-int crypto_scrypt_hash(char *dst, char* passphrase, uint32_t N, uint8_t r, uint8_t p);
+int libscrypt_hash(char *dst, char* passphrase, uint32_t N, uint8_t r, uint8_t p);
/* Sane default values */
#define SCRYPT_HASH_LEN 64 /* This can be user defined -
diff --git a/main.c b/main.c
index 7d25db5..84922f6 100644
--- a/main.c
+++ b/main.c
@@ -19,20 +19,20 @@ int main()
char saltbuf[64];
int retval;
/**
- * crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
+ * libscrypt_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
* password; duh
* N: CPU AND RAM cost (first modifier)
* r: RAM Cost
* p: CPU cost (parallelisation)
* In short, N is your main performance modifier. Values of r = 8, p = 1 are
* standard unless you want to modify the CPU/RAM ratio.
- int crypto_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t,
+ int libscrypt_scrypt(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t,
uint32_t, uint32_t, uint8_t *, size_t);
*/
printf("TEST ONE: Direct call to reference function with password 'password' and salt 'NaCL'\n");
- retval = crypto_scrypt((uint8_t*)"password",strlen("password"), (uint8_t*)"NaCl", strlen("NaCl"), 1024, 8, 16, hashbuf, sizeof(hashbuf));
+ retval = libscrypt_scrypt((uint8_t*)"password",strlen("password"), (uint8_t*)"NaCl", strlen("NaCl"), 1024, 8, 16, hashbuf, sizeof(hashbuf));
if(retval != 0)
{
@@ -47,7 +47,7 @@ int main()
* Returns 0 on fail, 1 on success
*/
printf("TEST TWO: Convert binary output to hex\n");
- retval = crypto_scrypt_hexconvert(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
+ retval = libscrypt_hexconvert(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
if(!retval)
{
printf("TEST TWO: FAILED\n");
@@ -72,7 +72,7 @@ int main()
/* Tests 4-6 repeat tests 1-3 with a different reference vector */
- retval = crypto_scrypt((uint8_t*)"pleaseletmein",strlen("pleaseletmein"), (uint8_t*)"SodiumChloride", strlen("SodiumChloride"), 16384, 8, 1, hashbuf, sizeof(hashbuf));
+ retval = libscrypt_scrypt((uint8_t*)"pleaseletmein",strlen("pleaseletmein"), (uint8_t*)"SodiumChloride", strlen("SodiumChloride"), 16384, 8, 1, hashbuf, sizeof(hashbuf));
if(retval != 0)
{
@@ -86,7 +86,7 @@ int main()
* at least sizeof(hashbuf) * 2 + 1
*/
printf("TEST FIVE: Convert binary output to hex\n");
- retval = crypto_scrypt_hexconvert(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
+ retval = libscrypt_hexconvert(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf));
if(!retval)
{
printf("TEST FIVE: FAILED\n");
@@ -137,7 +137,7 @@ int main()
* int crypto_scrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, char *mcf);
* Returns 0 on error, most likely reason is log2(N) not an integer.
*/
- retval = crypto_scrypt_mcf(16384, 8, 1, saltbuf, outbuf, mcf);
+ retval = libscrypt_mcf(16384, 8, 1, saltbuf, outbuf, mcf);
if(!retval)
{
printf("TEST EIGHT FAILED\n");
@@ -156,7 +156,7 @@ int main()
*/
printf("TEST NINE: Password verify on given MCF\n");
- retval = scrypt_check(mcf, "pleaseletmein");
+ retval = libscrypt_check(mcf, "pleaseletmein");
if(retval < 0)
{
@@ -172,7 +172,7 @@ int main()
printf("TEST NINE: SUCCESSFUL, tested pleaseletmein password\n");
printf("TEST TEN: Password verify on same MCF, incorrect password\n");
- retval = scrypt_check(mcf2, "pleasefailme");
+ retval = libscrypt_check(mcf2, "pleasefailme");
if(retval < 0)
{
@@ -189,7 +189,7 @@ int main()
printf("TEST ELEVEN: Testing salt generator\n");
/* TODO: I'm not presently sure how this function could fail */
- scrypt_salt_gen(saltbuf, 16);
+ libscrypt_salt_gen(saltbuf, 16);
retval = modp_b64_encode(saltbuf, (char*)saltbuf, 16);
if(retval == -1)
@@ -201,7 +201,7 @@ int main()
printf("TEST TWELVE: Simple hash creation\n");
- retval = crypto_scrypt_hash(outbuf, "My cats's breath smells like cat food", SCRYPT_N, SCRYPT_r, SCRYPT_p);
+ retval = libscrypt_hash(outbuf, "My cats's breath smells like cat food", SCRYPT_N, SCRYPT_r, SCRYPT_p);
if(!retval)
{
printf("TEST TWELVE: FAILED, Failed to create simple hash\n");