Exemple #1
0
def test_attack_batch_gcd_1024_bit_prime_product(attack_batch_gcd):

    # See: https://natmchugh.blogspot.com/2015/06/batch-gcd-ssh-key-challenge.html

    assert attack_batch_gcd([
        154562462709421668048811029574429176339967582770033927576824633187099552180626760770554766161885657196312518658221149688394800043151559510354818420232102676069730902564150494088745313126769777823443395885737730234868902723737890922926976276986298764777507242621301740051336797119228435868695641797422930394301,
        141870892963640483906191484688359999906901497888195706215571887802641521733841862353130672719272343785182876822221422152533930744933871548118719685110452659915157122801280912706475082870290416497225380769325061108597080567715885948417156740160002970573069043853048947718197839111694567700297700024292552486341,
    ]) == [
        11684605148985857191947476688613358870181874219280286003582682738923906001284052005536384750648711482951207682641537933896353133065876493903784581849780917,
        11684605148985857191947476688613358870181874219280286003582682738923906001284052005536384750648711482951207682641537933896353133065876493903784581849780917,
    ]
Exemple #2
0
def test_attack_batch_gcd_160_bit_primes(attack_batch_gcd):

    # See: http://www.loyalty.org/~schoen/rsa/

    assert attack_batch_gcd([15241555427044345769,
                             17477852958781876547]) == [1, 1]
Exemple #3
0
def test_attack_batch_gcd_small_primes_and_products(attack_batch_gcd):

    assert attack_batch_gcd([2, 3, 6]) == [2, 3, 6]
    assert attack_batch_gcd([7, 997, 7 * 997]) == [7, 997, 7 * 997]
Exemple #4
0
def test_attack_batch_gcd_only_small_primes(attack_batch_gcd):

    assert attack_batch_gcd([2, 3, 5, 7, 997]) == [1, 1, 1, 1, 1]
Exemple #5
0
def test_attack_batch_gcd_single(attack_batch_gcd, n):

    # The negative values do not make any sense here, so if you change the
    # behaviour for negatives, feel free to change this test too
    assert attack_batch_gcd([n]) == [1]
Exemple #6
0
def test_attack_batch_gcd_zero(attack_batch_gcd):

    with pytest.raises(ZeroDivisionError) as e:
        attack_batch_gcd([0])
Exemple #7
0
def test_attack_batch_gcd_empty(attack_batch_gcd):

    assert attack_batch_gcd([]) == []