more debuggin...

This commit is contained in:
TLINDEN
2015-04-17 13:22:34 +02:00
parent 03cb002cd7
commit 8c024afad9
2 changed files with 9 additions and 4 deletions

View File

@@ -802,7 +802,6 @@ pcp_key_t *pcp_import_secret(PCPCTX *ptx, byte *raw, size_t rawsize, char *passp
} }
/* now we've got the blob, parse it */ /* now we've got the blob, parse it */
buffer_dump(blob);
pcp_key_t *sk = pcp_import_secret_native(ptx, blob, passphrase); pcp_key_t *sk = pcp_import_secret_native(ptx, blob, passphrase);
buffer_free(blob); buffer_free(blob);
@@ -823,7 +822,9 @@ pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphras
if(buffer_get_chunk(cipher, nonce, crypto_secretbox_NONCEBYTES) == 0) if(buffer_get_chunk(cipher, nonce, crypto_secretbox_NONCEBYTES) == 0)
goto impserr1; goto impserr1;
fprintf(stderr, "import\n");
symkey = pcp_scrypt(ptx, passphrase, strlen(passphrase), nonce, crypto_secretbox_NONCEBYTES); symkey = pcp_scrypt(ptx, passphrase, strlen(passphrase), nonce, crypto_secretbox_NONCEBYTES);
fprintf(stderr, "import done\n");
cipherlen = buffer_left(cipher); cipherlen = buffer_left(cipher);
if(cipherlen < minlen) { if(cipherlen < minlen) {
@@ -834,11 +835,9 @@ pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphras
} }
/* decrypt the blob */ /* decrypt the blob */
buffer_info(cipher);
fprintf(stderr, "cipherpen: %ld\n", cipherlen);
_dump(" symkey", symkey, crypto_secretbox_KEYBYTES);
if(pcp_sodium_verify_mac(&clear, buffer_get_remainder(cipher), if(pcp_sodium_verify_mac(&clear, buffer_get_remainder(cipher),
cipherlen, nonce, symkey) != 0) { cipherlen, nonce, symkey) != 0) {
fatal(ptx, "failed to decrypt the secret key file\n"); fatal(ptx, "failed to decrypt the secret key file\n");
goto impserr1; goto impserr1;
} }
@@ -894,5 +893,7 @@ pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphras
buffer_free(blob); buffer_free(blob);
if(symkey != NULL) if(symkey != NULL)
sfree(symkey); sfree(symkey);
if(clear != NULL)
free(clear);
return NULL; return NULL;
} }

View File

@@ -20,6 +20,7 @@
*/ */
#include "scrypt.h" #include "scrypt.h"
#include "util.h"
byte* pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_t noncelen) { byte* pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_t noncelen) {
uint8_t *dk = smalloc(64); /* resulting hash */ uint8_t *dk = smalloc(64); /* resulting hash */
@@ -31,6 +32,9 @@ byte* pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_
size_t buflen = 64; size_t buflen = 64;
if (crypto_scrypt((byte *)passwd, passwdlen, (uint8_t *)nonce, noncelen, N, r, p, dk, buflen) == 0) { if (crypto_scrypt((byte *)passwd, passwdlen, (uint8_t *)nonce, noncelen, N, r, p, dk, buflen) == 0) {
_dump("nonce", nonce, noncelen);
_dump(" pass", (byte*)passwd, passwdlen);
_dump(" dk", dk, 64);
return dk; return dk;
} }
else { else {