]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_crypt.c
gost_crypt: process full available block in CFB and CNT mode
[openssl-gost/engine.git] / gost_crypt.c
index f9ed2cf22b0c8125252ef354b653e096476b0251..08a82a9e58a7e1bd8177f0e009bf908de2c9eb41 100644 (file)
@@ -487,7 +487,6 @@ static void gost_cnt_next(void *ctx, unsigned char *iv, unsigned char *buf)
 int gost_cipher_do_cbc(EVP_CIPHER_CTX *ctx, unsigned char *out,
                        const unsigned char *in, size_t inl)
 {
-    OPENSSL_assert(inl % 8 == 0);
     unsigned char b[8];
     const unsigned char *in_ptr = in;
     unsigned char *out_ptr = out;
@@ -550,7 +549,7 @@ int gost_cipher_do_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out,
         }
     }
 
-    for (; i + 8 < inl; i += 8, in_ptr += 8, out_ptr += 8) {
+    for (; (inl - i) >= 8; i += 8, in_ptr += 8, out_ptr += 8) {
         /*
          * block cipher current iv
          */
@@ -611,7 +610,7 @@ static int gost_cipher_do_cnt(EVP_CIPHER_CTX *ctx, unsigned char *out,
         }
     }
 
-    for (; i + 8 < inl; i += 8, in_ptr += 8, out_ptr += 8) {
+    for (; (inl - i) >= 8; i += 8, in_ptr += 8, out_ptr += 8) {
         /*
          * block cipher current iv
          */