dedup

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

commit 7102fc953fa622740207fbe9bce945d33aa9105e
parent 86e037e9f1ee5d564daa67fae8f4cc6fd8bc19d6
Author: sin <sin@2f30.org>
Date:   Fri, 17 May 2019 14:38:43 +0300

Use param.key directly, no need to keep a copy

Diffstat:
Mbencrypt.c | 7++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/bencrypt.c b/bencrypt.c @@ -51,7 +51,6 @@ static struct bops bops = { /* Encryption layer context */ struct ectx { int type; /* encryption algorithm type for new blocks */ - unsigned char key[KEYSIZE]; /* secret key */ }; /* Encryption descriptor */ @@ -128,7 +127,6 @@ becreat(struct bctx *bctx, char *path, int mode) } ectx = bctx->ectx; ectx->type = type; - memcpy(ectx->key, param.key, KEYSIZE); if (bstorageops()->creat(bctx, path, mode) < 0) { free(ectx); @@ -166,7 +164,6 @@ beopen(struct bctx *bctx, char *path, int flags, int mode) } ectx = bctx->ectx; ectx->type = type; - memcpy(ectx->key, param.key, KEYSIZE); if (bstorageops()->open(bctx, path, flags, mode) < 0) { free(ectx); @@ -227,7 +224,7 @@ beput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) case EDCHACHATYPE: crypto_aead_xchacha20poly1305_ietf_encrypt(&ebuf[EDSIZE], &elen, buf, n, ebuf, EDSIZE, NULL, - ed.nonce, ectx->key); + ed.nonce, param.key); assert(elen == en); break; } @@ -290,7 +287,7 @@ beget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) NULL, &ebuf[EDSIZE], ed.size, ebuf, EDSIZE, - ed.nonce, ectx->key) < 0) { + ed.nonce, param.key) < 0) { free(ebuf); seterr("authentication failed"); return -1;