applies aes stream fix to macos implementation v1.2

Thu, 06 Sep 2018 12:13:37 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 06 Sep 2018 12:13:37 +0200
branch
v1.2
changeset 465
70ed56e56122
parent 464
37da70159bf6
child 468
4996f8953c3a

applies aes stream fix to macos implementation

libidav/crypto.c file | annotate | diff | comparison | revisions
--- a/libidav/crypto.c	Thu Sep 06 11:57:00 2018 +0200
+++ b/libidav/crypto.c	Thu Sep 06 12:13:37 2018 +0200
@@ -529,7 +529,7 @@
     size_t outlen = 0;
     size_t ivl = enc->ivlen;
     if(in_len != 0) {
-        outlen = len + 16;
+        outlen = len + 32;
         out = malloc(outlen + ivl);
         if(enc->iv) {
             memcpy(out, enc->iv, ivl);
@@ -538,15 +538,18 @@
         CCCryptorStatus status;
         size_t avail = outlen;
         status = CCCryptorUpdate(enc->ctx, in, in_len, out + ivl, avail, &outlen);
-        
-        free(in);
+        if(in_len != len) {
+            int newoutlen = 16;
+            status = CCCryptorFinal(enc->ctx, out + ivl + outlen, 16, &newoutlen);
+            outlen += newoutlen;
+            enc->end = 1;
+        }
     } else {
         out = malloc(32);
         CCCryptorStatus status;
         size_t avail = outlen;
         status = CCCryptorFinal(enc->ctx, out, 32, &outlen);
         enc->end = 1;
-        free(in);
     }
     enc->tmp = (char*)out;
     enc->tmplen = outlen + ivl;
@@ -558,6 +561,8 @@
         enc->ivlen = 0;
     }
     
+    free(in);
+    
     return aes_read(buf, s, n, enc);
 }
 

mercurial