dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit f3cfc694a10d1cd07ad4ddc04806e3819adfa510
parent bf808eff120238a6a3ef7cc243469143a7f8c40b
Author: sin <sin@2f30.org>
Date:   Tue, 21 May 2019 12:10:15 +0100

Revert "Store key in hex format"

This reverts commit bf808eff120238a6a3ef7cc243469143a7f8c40b.

Diffstat:
Mkey.c | 18++----------------
1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/key.c b/key.c @@ -25,17 +25,12 @@ keygen(unsigned char *key, size_t n) int writekey(int fd, unsigned char *key, size_t n) { - unsigned char keystr[KEYSIZE * 2 + 1]; - assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES); if (n != KEYSIZE) { seterr("invalid key size"); return -1; } - - sodium_bin2hex(keystr, sizeof(keystr), key, n); - - if (xwrite(fd, keystr, sizeof(keystr) - 1) != sizeof(keystr) - 1) { + if (xwrite(fd, key, n) != n) { seterr("failed to write key"); return -1; } @@ -45,23 +40,14 @@ writekey(int fd, unsigned char *key, size_t n) int readkey(int fd, unsigned char *key, size_t n) { - unsigned char keystr[KEYSIZE * 2 + 1]; - size_t binlen; - assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES); if (n != KEYSIZE) { seterr("invalid key size"); return -1; } - - if (xread(fd, keystr, sizeof(keystr) - 1) != sizeof(keystr) - 1) { + if (xread(fd, key, n) != n) { seterr("failed to read key"); return -1; } - keystr[sizeof(keystr) - 1] = '\0'; - - sodium_hex2bin(key, n, keystr, sizeof(keystr), NULL, &binlen, NULL); - if (binlen != KEYSIZE) - return -1; return 0; }