Beispiel #1
0
    """
    You must fill in this method. This is the adversary that the problem is
    asking for.

    :param fn: This is the oracle supplied by GameKR, you can call this
    oracle to get an "encryption" of the data you pass into it.
    :return: return the a string that represents a key guess.
    """

    pass

from crypto.games.game_kr import GameKR
from crypto.simulator.kr_sim import KRSim

if __name__ == '__main__':
    g = GameKR(F, key_len, block_len)
    s = KRSim(g, A)

    key = random_string(key_len)

    for j in range(100):
        message = random_string(block_len)
        cypher = F(key, message)
        if message != F_I(key, cypher):
            print "Your Decryption function is incorrect."
            sys.exit()

    print "Your Decryption function appears correct."

    print "The advantage of your adversary is ~" + str(s.compute_advantage(20))
Beispiel #2
0
    You must fill in this method. This is the adversary that the problem is
    asking for.

    :param fn: This is the oracle supplied by GameKR, you can call this
    oracle to get an "encryption" of the data you pass into it.
    :return: return the a string that represents a key guess.
    """

    pass


from crypto.games.game_kr import GameKR
from crypto.simulator.kr_sim import KRSim

if __name__ == '__main__':
    g = GameKR(F, key_len, block_len)
    s = KRSim(g, A)

    key = random_string(key_len)

    for j in range(100):
        message = random_string(block_len)
        cypher = F(key, message)
        if message != F_I(key, cypher):
            print "Your Decryption function is incorrect."
            sys.exit()

    print "Your Decryption function appears correct."

    print "The advantage of your adversary is ~" + str(s.compute_advantage(20))
Beispiel #3
0
    oracle to get an "encryption" of the data you pass into it.
    :return: return the a string that represents a key guess.
    """

    pass

"""
Running this code will give you some intuition about whether or not your code
is working. However you must explain two things:

1. [30 points] Why does your adversary have Adv(kr, E, A) = 1?
2. [30 points] Why is the tkr advantage small for *any* A?
--&--
[Answer here].
"""


from crypto.games.game_kr import GameKR
from crypto.games.game_tkr import GameTKR
from crypto.simulator.kr_sim import KRSim

if __name__ == '__main__':
    g1 = GameKR(E, key_len, block_len)
    s1 = KRSim(g1, A)

    g2 = GameTKR(E, key_len, block_len)
    s2 = KRSim(g2, A)

    print "The advantage of your adversary under KR is ~" + str(s1.compute_advantage())
    print "The advantage of your adversary under TKR is ~" + str(s2.compute_advantage())