dedup

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

commit daf72e281ef887f4754d0b224b10c9fb03440ddc
parent a1037d78c0b5a6d557e520a87d484e77168610b9
Author: sin <sin@2f30.org>
Date:   Thu,  2 May 2019 23:40:35 +0100

Rework asserts

Diffstat:
Mkey.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/key.c b/key.c @@ -10,7 +10,7 @@ keygen(unsigned char *key, size_t n) { if (n < crypto_aead_xchacha20poly1305_ietf_KEYBYTES) return -1; - assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES); + assert(n == KEYSIZE); if (sodium_init() < 0) return -1; crypto_aead_xchacha20poly1305_ietf_keygen(key); @@ -22,8 +22,8 @@ savekey(int fd, unsigned char *key, size_t n) { if (n < crypto_aead_xchacha20poly1305_ietf_KEYBYTES) return -1; - assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES); - if (write(fd, key, KEYSIZE) != KEYSIZE) + assert(n == KEYSIZE); + if (write(fd, key, n) != n) return -1; return 0; } @@ -33,8 +33,8 @@ loadkey(int fd, unsigned char *key, size_t n) { if (n < crypto_aead_xchacha20poly1305_ietf_KEYBYTES) return -1; - assert(KEYSIZE == crypto_aead_xchacha20poly1305_ietf_KEYBYTES); - if (read(fd, key, KEYSIZE) != KEYSIZE) + assert(n == KEYSIZE); + if (read(fd, key, n) != n) return -1; return 0; }