Ejemplo n.º 1
0
def test_columnround_function():
    prg = PRG()
    x = make_words(n=16)
    y0 = prg.quarterround_function((x[0], x[4], x[8], x[12]))
    y1 = prg.quarterround_function((x[5], x[9], x[13], x[1]))
    y2 = prg.quarterround_function((x[10], x[14], x[2], x[6]))
    y3 = prg.quarterround_function((x[15], x[3], x[7], x[11]))
    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 len(y_unpacked) == 16
    y_unpacked = tuple(y_unpacked)

    # Run function tests.
    output = prg.columnround_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
Ejemplo n.º 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