Skip to content

Commit a2e6c6e

Browse files
committed
fix for non-invertible sbox
1 parent 3202f65 commit a2e6c6e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sage/crypto/sbox.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,15 +1410,21 @@ cdef class SBox(SageObject):
14101410
sage: S = SBox([12,5,6,11,9,0,10,13,3,14,15,8,4,7,1,2])
14111411
sage: S.linear_branch_number()
14121412
2
1413+
1414+
TESTS::
1415+
1416+
sage: f = SBox([0, 2, 0, 6, 2, 2, 3, 7])
1417+
sage: f.linear_branch_number()
1418+
1
14131419
"""
14141420
cdef Py_ssize_t m = self.m
14151421
cdef Py_ssize_t n = self.n
14161422
cdef Matrix lat = <Matrix> self.linear_approximation_table()
14171423
cdef Py_ssize_t ret = (1 << m) + (1 << n)
14181424

14191425
cdef Py_ssize_t a, b, w
1420-
for a in range(1, 1 << m):
1421-
for b in range(1 << n):
1426+
for a in range(1 << m):
1427+
for b in range(1, 1 << n):
14221428
if lat.get_unsafe(a, b) != 0:
14231429
w = hamming_weight(a) + hamming_weight(b)
14241430
if w < ret:

0 commit comments

Comments
 (0)