From cdc086e5e9c8da9494504a1e16558e8f898b7213 Mon Sep 17 00:00:00 2001 From: Hossein Hadipour Date: Tue, 4 Jul 2023 12:09:12 +0200 Subject: [PATCH 1/8] add the warp's sbox --- src/sage/crypto/sboxes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sage/crypto/sboxes.py b/src/sage/crypto/sboxes.py index 056ce082b50..c0c79849b41 100644 --- a/src/sage/crypto/sboxes.py +++ b/src/sage/crypto/sboxes.py @@ -92,7 +92,7 @@ - SERPENT_S0, ..., SERPENT_S7 ([BAK1998]_) - KLEIN ([GNL2011]_) - MIBS ([ISSK2009)] - - Midori_Sb0 (MANTIS, CRAFT), Midori_Sb1 ([BBISHAR2015]_) + - Midori_Sb0 (MANTIS, CRAFT, WARP), Midori_Sb1 ([BBISHAR2015]_) - Noekeon ([DPVAR2000]_) - Piccolo ([SIHMAS2011]_) - Panda ([YWHWXSW2014]_) @@ -1572,6 +1572,7 @@ def monomial_function(n, e): MIBS = SBox([4,15,3,8,13,10,12,0,11,5,7,14,2,6,1,9]) Midori_Sb0 = SBox([0xc,0xa,0xd,0x3,0xe,0xb,0xf,0x7,0x8,0x9,0x1,0x5,0x0,0x2,0x4,0x6]) MANTIS = Midori_Sb0 +WARP = Midori_Sb0 CRAFT = Midori_Sb0 Midori_Sb1 = SBox([0x1,0x0,0x5,0x3,0xe,0x2,0xf,0x7,0xd,0xa,0x9,0xb,0xc,0x8,0x4,0x6]) Noekeon = SBox([0x7,0xA,0x2,0xC,0x4,0x8,0xF,0x0,0x5,0x9,0x1,0xE,0x3,0xD,0xB,0x6]) From 3fb33c32de148f4c458818ad3ba342a60c77089e Mon Sep 17 00:00:00 2001 From: hadipourh Date: Tue, 4 Jul 2023 13:17:49 +0200 Subject: [PATCH 2/8] debugged 'component_function' in the sbox module --- src/sage/crypto/sbox.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index 8f830240844..6dccf702aa5 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1286,7 +1286,7 @@ cdef class SBox(SageObject): b = list(b) if len(b) > n: raise ValueError("input (%s) is too long and would be truncated" % (b,)) - b = self.from_bits(b) + b = self.from_bits(b, n) except TypeError: try: b = ZZ(b) From 58f586b61a659c5d6f65d1cbde74dc92aa7bc225 Mon Sep 17 00:00:00 2001 From: hadipourh Date: Sat, 6 Apr 2024 12:41:21 +0200 Subject: [PATCH 3/8] add a test for component_function --- src/sage/crypto/sbox.pyx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index bfe08d54296..37b694e7207 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1326,6 +1326,12 @@ cdef class SBox(SageObject): sage: f5 = S.component_function([1, 0, 1]) sage: f5.algebraic_normal_form() # needs sage.rings.polynomial.pbori x0*x2 + x0 + x1*x2 + + TESTS:: + sage: from sage.crypto.sboxes import SBox + sage: sb = SBox(7, 6, 0, 4, 2, 5, 1, 3) + sage: sb.component_function([1, 0, 0]) + Boolean function with 3 variables """ cdef Py_ssize_t m = self.m cdef Py_ssize_t n = self.n From 82469daa899a8af534ae01b4b8c8affca09881d9 Mon Sep 17 00:00:00 2001 From: hadipourh Date: Sat, 6 Apr 2024 12:49:59 +0200 Subject: [PATCH 4/8] add a test for component_function --- src/sage/crypto/sbox.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index 37b694e7207..ebd243bff08 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1328,6 +1328,7 @@ cdef class SBox(SageObject): x0*x2 + x0 + x1*x2 TESTS:: + sage: from sage.crypto.sboxes import SBox sage: sb = SBox(7, 6, 0, 4, 2, 5, 1, 3) sage: sb.component_function([1, 0, 0]) From 68210f4acddd7292b84e35bb0758c6dea78f04e8 Mon Sep 17 00:00:00 2001 From: hadipourh Date: Sat, 6 Apr 2024 12:53:03 +0200 Subject: [PATCH 5/8] add a test for component_function --- src/sage/crypto/sbox.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index ebd243bff08..d22f91347a5 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1328,7 +1328,7 @@ cdef class SBox(SageObject): x0*x2 + x0 + x1*x2 TESTS:: - + sage: from sage.crypto.sboxes import SBox sage: sb = SBox(7, 6, 0, 4, 2, 5, 1, 3) sage: sb.component_function([1, 0, 0]) From 302274dc54410cceec2124d13005b3ba44cbd1ea Mon Sep 17 00:00:00 2001 From: hadipourh Date: Sat, 6 Apr 2024 13:01:44 +0200 Subject: [PATCH 6/8] add a test for component_function --- src/sage/crypto/sbox.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index d22f91347a5..a818ae5271b 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1326,7 +1326,7 @@ cdef class SBox(SageObject): sage: f5 = S.component_function([1, 0, 1]) sage: f5.algebraic_normal_form() # needs sage.rings.polynomial.pbori x0*x2 + x0 + x1*x2 - + TESTS:: sage: from sage.crypto.sboxes import SBox From c545fb3762d5eac370333b0b83a3347b6ef914f1 Mon Sep 17 00:00:00 2001 From: hadipourh Date: Tue, 28 May 2024 18:38:01 +0200 Subject: [PATCH 7/8] debug component_function in sbox module --- src/sage/crypto/sbox.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index ab02e82cb1e..6074bc3921c 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1330,9 +1330,9 @@ cdef class SBox(SageObject): TESTS:: sage: from sage.crypto.sboxes import SBox - sage: sb = SBox(7, 6, 0, 4, 2, 5, 1, 3) - sage: sb.component_function([1, 0, 0]) - Boolean function with 3 variables + sage: sb = SBox([0, 1, 2, 3, 0, 1, 2, 3]) + sage: sb.component_function([1, 0]) + Boolean function with 3 variabl """ cdef Py_ssize_t m = self.m cdef Py_ssize_t n = self.n From cdfaf8fd3b2a1e91fdf147590602b2e1ae4047a1 Mon Sep 17 00:00:00 2001 From: hadipourh Date: Mon, 17 Jun 2024 18:36:11 +0200 Subject: [PATCH 8/8] Debug component_function in S-box Module and Add the S-box of WARP Block Cipher --- src/sage/crypto/sbox.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index f177a9558a5..b786af7b0f3 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1332,7 +1332,7 @@ cdef class SBox(SageObject): sage: from sage.crypto.sboxes import SBox sage: sb = SBox([0, 1, 2, 3, 0, 1, 2, 3]) sage: sb.component_function([1, 0]) - Boolean function with 3 variabl + Boolean function with 3 variables """ cdef Py_ssize_t m = self.m cdef Py_ssize_t n = self.n