示例#1
0
def test_active_bits():    
    from crypto.analysis.active_bits import search_minimum_active_bits, count_active_sboxes, display_active_words_progress
    from crypto.utilities import integer_to_bytes, bytes_to_integer
    
    def test_function(state):
        a, b, c, d = state        
        #sbox_layer(a, b, c, d)  
        print
        for byte in a + b + c  + d:
            print format(byte, 'b').zfill(8)        
        mix_state(a, b, c, d)         
        print "Output: "
        for byte in a + b + c  + d:
            print format(byte, 'b').zfill(8)
            
        #sbox_layer(a, b, c, d)
        #mix_state(a, b, c, d)        
        #mix_state(a, b, c, d)
        #mix_state(a, b, c, d)        
        return a, b, c, d
        
    def argument_function(a, b, c, d):
        return integer_to_bytes(a, 4), integer_to_bytes(b, 4), integer_to_bytes(c, 4), integer_to_bytes(d, 4)                
        
    def output_function(state):
        return tuple(bytes_to_integer(section) for section in state)
    
    search_minimum_active_bits(test_function, argument_function, output_function)#, 
示例#2
0
def test_active_bits():    
    from crypto.analysis.active_bits import search_minimum_active_bits
    from crypto.utilities import integer_to_bytes, bytes_to_integer
    
    def test_function(state):
        a, b, c, d = state
        mix_state(a, b, c, d)
        return a, b, c, d
        
    def argument_function(a, b, c, d):
        return integer_to_bytes(a, 4), integer_to_bytes(b, 4), integer_to_bytes(c, 4), integer_to_bytes(d, 4)                
        
    def output_function(state):
        return tuple(bytes_to_integer(section) for section in state)
    
    search_minimum_active_bits(test_function, argument_function, output_function)
示例#3
0
def test_active_bits():
    from crypto.analysis.active_bits import search_minimum_active_bits
    from crypto.utilities import integer_to_bytes, bytes_to_integer

    def test_function(state):
        a, b, c, d = state
        mix_state(a, b, c, d)
        return a, b, c, d

    def argument_function(a, b, c, d):
        return integer_to_bytes(a,
                                4), integer_to_bytes(b, 4), integer_to_bytes(
                                    c, 4), integer_to_bytes(d, 4)

    def output_function(state):
        return tuple(bytes_to_integer(section) for section in state)

    search_minimum_active_bits(test_function, argument_function,
                               output_function)
示例#4
0
def test_permutation_active_bits(): 
    from crypto.analysis.active_bits import search_minimum_active_bits
    pass_function = lambda *args: args
    search_minimum_active_bits(lambda args: permutation(*args), pass_function, lambda *args: args[0])
示例#5
0
def test_permutation_active_bits(): 
    from crypto.analysis.active_bits import search_minimum_active_bits, THOROUGH_TEST
    pass_function = lambda *args: args
    search_minimum_active_bits(lambda args: permutation(*args), pass_function, lambda *args: args[0])#, test_inputs=THOROUGH_TEST)
示例#6
0
def test_permutation_active_bits():
    from crypto.analysis.active_bits import search_minimum_active_bits, THOROUGH_TEST
    pass_function = lambda *args: args
    search_minimum_active_bits(
        lambda args: permutation(*args), pass_function,
        lambda *args: args[0])  #, test_inputs=THOROUGH_TEST)
示例#7
0
def test_active_bits():
    from crypto.analysis.active_bits import search_minimum_active_bits    
    from os import urandom
    from crypto.utilities import bytes_to_words
    key = tuple(bytes_to_words(bytearray(urandom(16)), 4))        
    search_minimum_active_bits(lambda args: bit_permutation(*args + key), lambda *args: args, lambda args: args)
示例#8
0
def test_active_bits():
    from crypto.analysis.active_bits import search_minimum_active_bits
    search_minimum_active_bits(lambda args: keyed_permutation(*args),
                               lambda *args: args, lambda args: args)
示例#9
0
def test_permutation_active_bits():
    from crypto.analysis.active_bits import search_minimum_active_bits
    pass_function = lambda *args: args
    search_minimum_active_bits(lambda args: permutation(*args), pass_function,
                               lambda *args: args[0])
示例#10
0
def test_active_bits():
    from crypto.analysis.active_bits import search_minimum_active_bits
    search_minimum_active_bits(lambda args: keyed_permutation(*args), lambda *args: args, lambda args: args)