# HG changeset patch # User Olaf Wintermann # Date 1575539199 -3600 # Node ID 48ec0ab1701172faac078d725f03c2a03c3bdeee # Parent ce253cfb91277883ad99ba82d14b541861241cae fix encryption of files with specific length diff -r ce253cfb9127 -r 48ec0ab17011 libidav/crypto.c --- a/libidav/crypto.c Wed Dec 04 15:48:58 2019 +0100 +++ b/libidav/crypto.c Thu Dec 05 10:46:39 2019 +0100 @@ -1239,9 +1239,11 @@ // encrypt int flags = 0; - if(inlen % 16 != 0) { + if(inlen % 16 != 0 || enc->end) { + enc->end = 1; + } + if(enc->end) { flags = BCRYPT_BLOCK_PADDING; - enc->end = 1; } if(BCryptEncrypt(enc->ctx.hKey, in, inlen, NULL, enc->ctx.pbIV, 16, out, outalloc, &outlen, flags)) { fprintf(stderr, "Error: BCryptEncrypt failed\n");