From 306341e23427fed07f30e839cc19fe358dda93e2 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 14 May 2024 23:32:00 -0700 Subject: [PATCH] reference/test_cl_gfb_gfp.py: test reducing polynomial that is XLEN+1 bits --- gf_reference/test_cl_gfb_gfp.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gf_reference/test_cl_gfb_gfp.py b/gf_reference/test_cl_gfb_gfp.py index b4db911..a831639 100644 --- a/gf_reference/test_cl_gfb_gfp.py +++ b/gf_reference/test_cl_gfb_gfp.py @@ -540,10 +540,14 @@ class TestCL(unittest.TestCase): class TestGFBInstructions(unittest.TestCase): @staticmethod - def init_aes_red_poly(): + def init_aes_red_poly(XLEN=8): # AES's finite field reducing polynomial red_poly = GF2Poly([1, 1, 0, 1, 1, 0, 0, 0, 1]) - ST.reinit(GFBREDPOLY=pack_poly(red_poly.coefficients)) + REDPOLY = pack_poly(red_poly.coefficients) + if REDPOLY >= 2 ** XLEN: + REDPOLY %= 2 ** XLEN + REDPOLY &= ~1 + ST.reinit(XLEN=XLEN, GFBREDPOLY=REDPOLY) return red_poly def test_gfbmul(self): @@ -561,9 +565,9 @@ class TestGFBInstructions(unittest.TestCase): expectedv = pack_poly(expected.value.coefficients) self.assertEqual(product, expectedv) - def test_gfbmadd(self): + def test_gfbmadd(self, XLEN=8): # AES's finite field reducing polynomial - red_poly = self.init_aes_red_poly() + red_poly = self.init_aes_red_poly(XLEN=XLEN) a_width = 5 b_width = 4 c_width = 4 @@ -582,6 +586,9 @@ class TestGFBInstructions(unittest.TestCase): expectedv = pack_poly(expected.value.coefficients) self.assertEqual(result, expectedv) + def test_gfbmadd_64(self): + self.test_gfbmadd(XLEN=64) + def test_gfbinv(self): # AES's finite field reducing polynomial red_poly = self.init_aes_red_poly() -- 2.30.2