diff --git a/src/sage/crypto/sbox.pyx b/src/sage/crypto/sbox.pyx index eb4388efd79..b786af7b0f3 100644 --- a/src/sage/crypto/sbox.pyx +++ b/src/sage/crypto/sbox.pyx @@ -1326,6 +1326,13 @@ 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([0, 1, 2, 3, 0, 1, 2, 3]) + sage: sb.component_function([1, 0]) + Boolean function with 3 variables """ cdef Py_ssize_t m = self.m cdef Py_ssize_t n = self.n @@ -1334,7 +1341,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) diff --git a/src/sage/crypto/sboxes.py b/src/sage/crypto/sboxes.py index 749593c401b..55590d1a4fe 100644 --- a/src/sage/crypto/sboxes.py +++ b/src/sage/crypto/sboxes.py @@ -93,7 +93,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]_) @@ -1574,6 +1574,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])