dedup

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

commit 55cb1cd3104e7adc0632b501925d7178e2c9ebc8
parent 7fbb8c1db056f7fd2fc88a9454bbf5470675075d
Author: sin <sin@2f30.org>
Date:   Thu,  2 May 2019 23:51:11 +0100

Rework key.c asserts again

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

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