Revert "Store key in hex format" - dedup - deduplicating backup program
 (HTM) git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f3cfc694a10d1cd07ad4ddc04806e3819adfa510
 (DIR) parent bf808eff120238a6a3ef7cc243469143a7f8c40b
 (HTM) 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:
         M key.c                               |      18 ++----------------
       
       1 file changed, 2 insertions(+), 16 deletions(-)
       ---
 (DIR) 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;
        }