Improve small block cipher performance
[openssl.git] / providers / implementations / ciphers / ciphercommon_block.c
index eff9484..ee54f48 100644 (file)
@@ -35,20 +35,17 @@ size_t fillblock(unsigned char *buf, size_t *buflen, size_t blocksize,
                  const unsigned char **in, size_t *inlen)
 {
     size_t blockmask = ~(blocksize - 1);
+    size_t bufremain = blocksize - *buflen;
 
     assert(*buflen <= blocksize);
     assert(blocksize > 0 && (blocksize & (blocksize - 1)) == 0);
 
-    if (*buflen != blocksize && (*buflen != 0 || *inlen < blocksize)) {
-        size_t bufremain = blocksize - *buflen;
-
-        if (*inlen < bufremain)
-            bufremain = *inlen;
-        memcpy(buf + *buflen, *in, bufremain);
-        *in += bufremain;
-        *inlen -= bufremain;
-        *buflen += bufremain;
-    }
+    if (*inlen < bufremain)
+        bufremain = *inlen;
+    memcpy(buf + *buflen, *in, bufremain);
+    *in += bufremain;
+    *inlen -= bufremain;
+    *buflen += bufremain;
 
     return *inlen & blockmask;
 }