summaryrefslogtreecommitdiff
path: root/toxencryptsave
diff options
context:
space:
mode:
authordubslow <bill@mint>2014-09-12 21:15:05 -0500
committerdubslow <bill@mint>2014-09-12 21:15:05 -0500
commit579e7998b7c33962c645b9476949aa58c76be876 (patch)
tree92682d3c73e828b48a3b33d81c478a581053b0a8 /toxencryptsave
parentc26c6d86aeb2a0dd672ff7611394ebbf806d70c7 (diff)
encrypted save fully work with both libsodium and nacl
they both reliably pass "make check"
Diffstat (limited to 'toxencryptsave')
-rw-r--r--toxencryptsave/Makefile.inc4
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/export.h3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.h3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c8
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.h3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c3
-rw-r--r--toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h3
-rw-r--r--toxencryptsave/toxencryptsave.c2
17 files changed, 53 insertions, 3 deletions
diff --git a/toxencryptsave/Makefile.inc b/toxencryptsave/Makefile.inc
index 1155e954..b4f06c90 100644
--- a/toxencryptsave/Makefile.inc
+++ b/toxencryptsave/Makefile.inc
@@ -20,6 +20,10 @@ libtoxencryptsave_la_SOURCES = ../toxencryptsave/crypto_pwhash_scryptsalsa208sha
20 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h \ 20 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h \
21 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \ 21 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \
22 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c \ 22 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c \
23 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/hmac_hmacsha256.c \
24 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_auth_hmacsha256.h \
25 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_hash_sha256.h \
26 ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/hash_sha256.c \
23 ../toxencryptsave/toxencryptsave.h \ 27 ../toxencryptsave/toxencryptsave.h \
24 ../toxencryptsave/toxencryptsave.c 28 ../toxencryptsave/toxencryptsave.c
25 29
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h
index e10a81d8..5cb32f8d 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifndef crypto_pwhash_scryptsalsa208sha256_H 6#ifndef crypto_pwhash_scryptsalsa208sha256_H
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c
index 159dac10..5a5c5525 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt-common.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h
index 1f70b7a2..3f0b7d72 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/export.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/export.h
index d6975e8d..ee5b30f7 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/export.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/export.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifndef __SODIUM_EXPORT_H__ 6#ifndef __SODIUM_EXPORT_H__
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c
index 0dc896f1..97d9ba68 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c
index d66a5395..01eb7dff 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.h
index 6e5f2832..b74bc6a3 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
index 0a519937..52c51abc 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
@@ -1,11 +1,14 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3
4#include <errno.h> 6#include <errno.h>
5#include <limits.h> 7#include <limits.h>
6#include <stddef.h> 8#include <stddef.h>
7#include <stdint.h> 9#include <stdint.h>
8#include <string.h> 10#include <string.h>
11//#include <stdio.h>
9 12
10#include "crypto_pwhash_scryptsalsa208sha256.h" 13#include "crypto_pwhash_scryptsalsa208sha256.h"
11#include "crypto_scrypt.h" 14#include "crypto_scrypt.h"
@@ -102,6 +105,7 @@ crypto_pwhash_scryptsalsa208sha256(unsigned char * const out,
102 unsigned long long opslimit, 105 unsigned long long opslimit,
103 size_t memlimit) 106 size_t memlimit)
104{ 107{
108 //fprintf(stderr, "Doing that dirty thang!!!!\n");
105 uint32_t N_log2; 109 uint32_t N_log2;
106 uint32_t p; 110 uint32_t p;
107 uint32_t r; 111 uint32_t r;
@@ -146,7 +150,7 @@ crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha2
146 errno = EINVAL; 150 errno = EINVAL;
147 return -1; 151 return -1;
148 } 152 }
149 randombytes_buf(salt, sizeof salt); 153 randombytes(salt, sizeof salt);
150 if (escrypt_gensalt_r(N_log2, r, p, salt, sizeof salt, 154 if (escrypt_gensalt_r(N_log2, r, p, salt, sizeof salt,
151 (uint8_t *) setting, sizeof setting) == NULL) { 155 (uint8_t *) setting, sizeof setting) == NULL) {
152 errno = EINVAL; 156 errno = EINVAL;
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c
index f02c3803..9b5c5131 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifdef HAVE_ANDROID_GETCPUFEATURES 6#ifdef HAVE_ANDROID_GETCPUFEATURES
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.h
index 2e5efddd..874915ef 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/runtime.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifndef __SODIUM_RUNTIME_H__ 6#ifndef __SODIUM_RUNTIME_H__
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c
index 9de9763a..58196514 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/scrypt_platform.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
index 18cf6ae6..856a655e 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3/*- 6/*-
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h
index e28c5202..04e5c1ed 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifndef _SYSENDIAN_H_ 6#ifndef _SYSENDIAN_H_
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c
index 677633b4..e61ccf3e 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.c
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifndef __STDC_WANT_LIB_EXT1__ 6#ifndef __STDC_WANT_LIB_EXT1__
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h
index 7d5214e1..fb2020c3 100644
--- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h
+++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h
@@ -1,3 +1,6 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
1#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */ 4#ifdef VANILLA_NACL /* toxcore only uses this when libsodium is unavailable */
2 5
3#ifndef __SODIUM_UTILS_H__ 6#ifndef __SODIUM_UTILS_H__
diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c
index ae042199..f4fdbe61 100644
--- a/toxencryptsave/toxencryptsave.c
+++ b/toxencryptsave/toxencryptsave.c
@@ -63,7 +63,7 @@ int tox_encrypted_save(const Tox *tox, uint8_t *data, uint8_t *passphrase, uint3
63 * once the pwhash competition (https://password-hashing.net/) is over */ 63 * once the pwhash competition (https://password-hashing.net/) is over */
64 uint8_t salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES]; 64 uint8_t salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
65 uint8_t key[crypto_box_KEYBYTES]; 65 uint8_t key[crypto_box_KEYBYTES];
66 randombytes_buf(salt, sizeof salt); 66 randombytes(salt, sizeof salt);
67 67
68 if (crypto_pwhash_scryptsalsa208sha256( 68 if (crypto_pwhash_scryptsalsa208sha256(
69 key, sizeof(key), passphrase, pplength, salt, 69 key, sizeof(key), passphrase, pplength, salt,