コード例 #1
0
def test_rowround_function():
    prg = PRG()

    # Create test variables.
    x = make_words(n=16)
    y0 = prg.quarterround_function(x[0:4])
    y1 = prg.quarterround_function(x[4:8])
    y2 = prg.quarterround_function(x[8:12])
    y3 = prg.quarterround_function(x[12:16])
    y = (y0, y1, y2, y3)
    assert type(y) is type(y0) is type(y1) is type(y2) is type(y3) is tuple

    # Unpack y.
    y_unpacked = []
    for words in y:
        for word in words:
            y_unpacked.append(word)
    assert type(y_unpacked) is list
    y_unpacked = tuple(y_unpacked)
    assert type(y_unpacked) is tuple
    assert len(y_unpacked) == 16

    # Run function tests.
    output = prg.rowround_function(x)
    assert type(output) is tuple
    assert len(output) == 16
    for element in output:
        assert type(element) is str

    # Compare output.
    assert output == y_unpacked
コード例 #2
0
def test_doubleround_function():
    prg = PRG()
    x = make_words(n=16)
    verification = prg.columnround_function(x)
    verification = prg.rowround_function(verification)
    output = prg.doubleround_function(x)
    print(type(x))
    print(type(output))
    print(type(verification))
    assert type(output) is type(verification) is type(x) is tuple
    assert len(output) == len(verification) == len(x) == 16
    assert output == verification