fix encryption of files with specific length

Thu, 05 Dec 2019 10:46:39 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 05 Dec 2019 10:46:39 +0100
changeset 691
48ec0ab17011
parent 690
ce253cfb9127
child 692
56b66fe2b4f5

fix encryption of files with specific length

libidav/crypto.c file | annotate | diff | comparison | revisions
--- 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");

mercurial