Ticket #9674: trac9674_fix_Sbox_init.patch

File trac9674_fix_Sbox_init.patch, 971 bytes (added by ylchapuy, 11 years ago)
  • sage/crypto/mq/sbox.py

    # HG changeset patch
    # User Yann Laigle-Chapuy <yannlaiglechapuy@gmail.com>
    # Date 1281378692 -7200
    # Node ID 2b747a962f8b072d15d1e5c1d0b70d7e50a07952
    # Parent  5b338f2e484f2065d3d30d47bc204d6e9ed13d12
    9674 fix Sbox init again
    
    diff -r 5b338f2e484f -r 2b747a962f8b sage/crypto/mq/sbox.py
    a b  
    105105            Traceback (most recent call last):
    106106            ...
    107107            TypeError: Lookup table length is not a power of 2.
     108            sage: S = mq.SBox(5, 6, 0, 3, 4, 2, 1, 2)
     109            sage: S.n
     110            3
    108111        """
    109112        if "S" in kwargs:
    110113            S = kwargs["S"]
     
    127130        self._S = S
    128131
    129132        self.m = ZZ(len(S)).exact_log(2)
    130         self.n = ZZ(max(S)+1).exact_log(2)
     133        self.n = ZZ(max(S)).nbits()
    131134        self._F = GF(2)
    132135        self._big_endian = kwargs.get("big_endian",True)
    133136