From 8c024afad91d2701f9ff981aabd6b27ee90764fc Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Fri, 17 Apr 2015 13:22:34 +0200 Subject: [PATCH] more debuggin... --- libpcp/mgmt.c | 9 +++++---- libpcp/scrypt.c | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libpcp/mgmt.c b/libpcp/mgmt.c index 601ca5a..c7b7ab2 100644 --- a/libpcp/mgmt.c +++ b/libpcp/mgmt.c @@ -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 */ - buffer_dump(blob); pcp_key_t *sk = pcp_import_secret_native(ptx, blob, passphrase); 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) goto impserr1; + fprintf(stderr, "import\n"); symkey = pcp_scrypt(ptx, passphrase, strlen(passphrase), nonce, crypto_secretbox_NONCEBYTES); + fprintf(stderr, "import done\n"); cipherlen = buffer_left(cipher); if(cipherlen < minlen) { @@ -834,11 +835,9 @@ pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphras } /* 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), cipherlen, nonce, symkey) != 0) { + fatal(ptx, "failed to decrypt the secret key file\n"); goto impserr1; } @@ -894,5 +893,7 @@ pcp_key_t *pcp_import_secret_native(PCPCTX *ptx, Buffer *cipher, char *passphras buffer_free(blob); if(symkey != NULL) sfree(symkey); + if(clear != NULL) + free(clear); return NULL; } diff --git a/libpcp/scrypt.c b/libpcp/scrypt.c index 11c0345..8bef998 100644 --- a/libpcp/scrypt.c +++ b/libpcp/scrypt.c @@ -20,6 +20,7 @@ */ #include "scrypt.h" +#include "util.h" byte* pcp_scrypt(PCPCTX *ptx, char *passwd, size_t passwdlen, byte *nonce, size_t noncelen) { 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; 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; } else {