PPC assembly pack: fix copy-paste error in CTR mode
authorDaniel Axtens <dja@axtens.net>
Sun, 17 Mar 2019 23:22:44 +0000 (10:22 +1100)
committerPauli <paul.dale@oracle.com>
Mon, 18 Mar 2019 08:13:24 +0000 (18:13 +1000)
There are two copy-paste errors in handling CTR mode. When dealing
with a 2 or 3 block tail, the code branches to the CBC decryption exit
path, rather than to the CTR exit path.

This can lead to data corruption: in the Linux kernel we have a copy
of this file, and the bug leads to corruption of the IV, which leads
to data corruption when we call the encryption function again later to
encrypt subsequent blocks.

Originally reported to the Linux kernel by Ondrej Mosnáček <omosnacek@gmail.com>

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8510)

crypto/aes/asm/aesp8-ppc.pl

index ce3fae0912442d2ce07d9e251bbbcbb6ae434660..44056e31aa19228c1848c61c35dc606e652df22b 100755 (executable)
@@ -1829,7 +1829,7 @@ Lctr32_enc8x_three:
        stvx_u          $out1,$x10,$out
        stvx_u          $out2,$x20,$out
        addi            $out,$out,0x30
-       b               Lcbc_dec8x_done
+       b               Lctr32_enc8x_done
 
 .align 5
 Lctr32_enc8x_two:
@@ -1841,7 +1841,7 @@ Lctr32_enc8x_two:
        stvx_u          $out0,$x00,$out
        stvx_u          $out1,$x10,$out
        addi            $out,$out,0x20
-       b               Lcbc_dec8x_done
+       b               Lctr32_enc8x_done
 
 .align 5
 Lctr32_enc8x_one: