Esempio n. 1
0
def test_preimage():
    output = DummyOutput()
    n_collisions = 10
    hash_table_size = 2**32
    preimage_target = 'hello world'
    java.options['n_collisions'] = n_collisions
    java.options['target_type'] = 'preimage'
    java.options['target'] = preimage_target
    java.options['hash_table_size'] = hash_table_size
    java.run(CharGenerator(), output)
    target = java_common.java_hash(preimage_target, hash_table_size)
    assert output.count() == n_collisions
    for i in output:
        assert java_common.java_hash(i, hash_table_size) == target
Esempio n. 2
0
def test_run_small_collision_count():
    output = DummyOutput()
    n_collisions = 10
    hash_table_size = 2**32
    target = '42'
    java.options['n_collisions'] = n_collisions
    java.options['target_type'] = 'image'
    java.options['target'] = target
    java.options['hash_table_size'] = hash_table_size
    java.run(CharGenerator(), output)
    assert output.count() == n_collisions
    for i in output:
        assert java_common.java_hash(i, hash_table_size) == int(target)
Esempio n. 3
0
def test_run():
    output = DummyOutput()
    n_collisions = 1
    hash_table_size = 2**32
    target = '42'
    length = 10
    java_z3.options['n_collisions'] = n_collisions
    java_z3.options['length'] = length
    java_z3.options['target_type'] = 'image'
    java_z3.options['target'] = target
    java_z3.options['hash_table_size'] = hash_table_size
    java_z3.run(output)
    assert output.count() == n_collisions
    for i in output:
        assert java_common.java_hash(i, hash_table_size) == int(target)
        assert len(i) == length