From 44c5312e6c1cf5f3eb3394c2b8c19f3ea66ea7d2 Mon Sep 17 00:00:00 2001 From: Technion Date: Mon, 20 Jan 2014 00:06:02 +0000 Subject: Corrected signing for new prototypes. --- crypto-scrypt-saltgen.c | 2 +- crypto_scrypt-check.c | 5 +++-- crypto_scrypt-hash.c | 5 +++-- libscrypt.h | 5 +---- main.c | 9 +++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crypto-scrypt-saltgen.c b/crypto-scrypt-saltgen.c index 82af842..8b9caf4 100644 --- a/crypto-scrypt-saltgen.c +++ b/crypto-scrypt-saltgen.c @@ -5,7 +5,7 @@ #include "sha256.h" -void libscrypt_salt_gen(char *rand, size_t len) +void libscrypt_salt_gen(uint8_t *rand, size_t len) { unsigned char buf[32]; diff --git a/crypto_scrypt-check.c b/crypto_scrypt-check.c index 546e655..1d954a1 100644 --- a/crypto_scrypt-check.c +++ b/crypto_scrypt-check.c @@ -3,6 +3,7 @@ #include #include +#include "b64.h" #include "libscrypt.h" /* pow() works with doubles. Sounds like it should cast to int correctly, @@ -64,7 +65,7 @@ int libscrypt_check(char *mcf, char *password) printf("We've obtained salt 'N' r p of '%s' %d %d %d\n", tok, N,r,p); */ - retval = libscrypt_b64_decode(tok, salt, sizeof(salt)); + retval = libscrypt_b64_decode(tok, (uint8_t*)salt, sizeof(salt)); if (retval < 1) return -1; retval = libscrypt_scrypt((uint8_t*)password,strlen(password), (uint8_t*)salt, (uint32_t)retval, N, r, p, hashbuf, sizeof(hashbuf)); @@ -72,7 +73,7 @@ int libscrypt_check(char *mcf, char *password) if (retval != 0) return retval; - retval = libscrypt_b64_encode((char*)hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf)); + retval = libscrypt_b64_encode(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf)); if (retval == 0) return -1; diff --git a/crypto_scrypt-hash.c b/crypto_scrypt-hash.c index 1fcf49b..0816113 100644 --- a/crypto_scrypt-hash.c +++ b/crypto_scrypt-hash.c @@ -3,13 +3,14 @@ #include #include +#include "b64.h" #include "libscrypt.h" int libscrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8_t p) { int retval; - char salt[16]; + uint8_t salt[16]; uint8_t hashbuf[64]; char outbuf[256]; char saltbuf[256]; @@ -20,7 +21,7 @@ int libscrypt_hash(char *dst, char *passphrase, uint32_t N, uint8_t r, uint8_t p if(retval == -1) return 0; - retval = libscrypt_b64_encode((char*)hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf)); + retval = libscrypt_b64_encode(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf)); if(retval == -1) return 0; diff --git a/libscrypt.h b/libscrypt.h index 383d131..6af01e9 100644 --- a/libscrypt.h +++ b/libscrypt.h @@ -37,7 +37,7 @@ int libscrypt_mcf(uint32_t N, uint32_t r, uint32_t p, char *salt, char *hash, ch /* Generates a salt. This is not a cryptographically unpredictable function, * but should produce appropriately randomised output for this purpose */ -void libscrypt_salt_gen(/*@out@*/ char *rand, size_t len); +void libscrypt_salt_gen(/*@out@*/ uint8_t *rand, size_t len); /* Checks a given MCF against a password */ int libscrypt_check(char *mcf, char *password); @@ -45,9 +45,6 @@ int libscrypt_check(char *mcf, char *password); /* Creates a hash of a passphrase using a randomly generated salt */ int libscrypt_hash(char *dst, char* passphrase, uint32_t N, uint8_t r, uint8_t p); -int libscrypt_b64_encode(unsigned char const*, size_t, /*@out@*/ char*, size_t); -int libscrypt_b64_decode(char const*, /*@out@*/ unsigned char*, size_t); - /* Sane default values */ #define SCRYPT_HASH_LEN 64 /* This can be user defined - diff --git a/main.c b/main.c index 1c75a17..f9d2bfb 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,7 @@ #include #include +#include "b64.h" #include "libscrypt.h" #define REF1 "fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640" @@ -115,13 +116,13 @@ int main() printf("TEST SEVEN: BASE64 encoding the salt and hash output\n"); - retval = libscrypt_b64_encode((char*)hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf)); + retval = libscrypt_b64_encode(hashbuf, sizeof(hashbuf), outbuf, sizeof(outbuf)); if(retval == -1) { printf("TEST SEVEN FAILED\n"); exit(EXIT_FAILURE); } - retval = libscrypt_b64_encode("SodiumChloride", strlen("SodiumChloride"), saltbuf, sizeof(saltbuf)); + retval = libscrypt_b64_encode((unsigned char*)"SodiumChloride", strlen("SodiumChloride"), saltbuf, sizeof(saltbuf)); if(retval == -1) { printf("TEST SEVEN FAILED\n"); @@ -188,9 +189,9 @@ int main() printf("TEST ELEVEN: Testing salt generator\n"); /* TODO: I'm not presently sure how this function could fail */ - libscrypt_salt_gen(saltbuf, 16); + libscrypt_salt_gen((uint8_t*)saltbuf, 16); - retval = libscrypt_b64_encode((char*)saltbuf, 16, saltbuf, sizeof(saltbuf)); + retval = libscrypt_b64_encode((uint8_t*)saltbuf, 16, saltbuf, sizeof(saltbuf)); if(retval == -1) { printf("TEST ELEVEN FAILED\n"); -- cgit v1.2.3