77c23f
From b8c8288a65146952cdfe7d5f0cd96734c9de8ee1 Mon Sep 17 00:00:00 2001
77c23f
From: jmaloy <jmaloy@redhat.com>
77c23f
Date: Thu, 7 May 2020 17:57:08 +0100
77c23f
Subject: [PATCH 1/7] target/arm: Fix PAuth sbox functions
77c23f
MIME-Version: 1.0
77c23f
Content-Type: text/plain; charset=UTF-8
77c23f
Content-Transfer-Encoding: 8bit
77c23f
77c23f
RH-Author: jmaloy <jmaloy@redhat.com>
77c23f
Message-id: <20200507175708.1165177-2-jmaloy@redhat.com>
77c23f
Patchwork-id: 96341
77c23f
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 1/1] target/arm: Fix PAuth sbox functions
77c23f
Bugzilla: 1813940
77c23f
RH-Acked-by: Andrew Jones <drjones@redhat.com>
77c23f
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
77c23f
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
77c23f
77c23f
From: Vincent Dehors <vincent.dehors@smile.fr>
77c23f
77c23f
In the PAC computation, sbox was applied over wrong bits.
77c23f
As this is a 4-bit sbox, bit index should be incremented by 4 instead of 16.
77c23f
77c23f
Test vector from QARMA paper (https://eprint.iacr.org/2016/444.pdf) was
77c23f
used to verify one computation of the pauth_computepac() function which
77c23f
uses sbox2.
77c23f
77c23f
Launchpad: https://bugs.launchpad.net/bugs/1859713
77c23f
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
77c23f
Signed-off-by: Vincent DEHORS <vincent.dehors@smile.fr>
77c23f
Signed-off-by: Adrien GRASSEIN <adrien.grassein@smile.fr>
77c23f
Message-id: 20200116230809.19078-2-richard.henderson@linaro.org
77c23f
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
77c23f
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
77c23f
(cherry picked from commit de0b1bae6461f67243282555475f88b2384a1eb9)
77c23f
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
77c23f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
77c23f
---
77c23f
 target/arm/pauth_helper.c | 4 ++--
77c23f
 1 file changed, 2 insertions(+), 2 deletions(-)
77c23f
77c23f
diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c
77c23f
index d3194f2..0a5f41e 100644
77c23f
--- a/target/arm/pauth_helper.c
77c23f
+++ b/target/arm/pauth_helper.c
77c23f
@@ -89,7 +89,7 @@ static uint64_t pac_sub(uint64_t i)
77c23f
     uint64_t o = 0;
77c23f
     int b;
77c23f
 
77c23f
-    for (b = 0; b < 64; b += 16) {
77c23f
+    for (b = 0; b < 64; b += 4) {
77c23f
         o |= (uint64_t)sub[(i >> b) & 0xf] << b;
77c23f
     }
77c23f
     return o;
77c23f
@@ -104,7 +104,7 @@ static uint64_t pac_inv_sub(uint64_t i)
77c23f
     uint64_t o = 0;
77c23f
     int b;
77c23f
 
77c23f
-    for (b = 0; b < 64; b += 16) {
77c23f
+    for (b = 0; b < 64; b += 4) {
77c23f
         o |= (uint64_t)inv_sub[(i >> b) & 0xf] << b;
77c23f
     }
77c23f
     return o;
77c23f
-- 
77c23f
1.8.3.1
77c23f