コード例 #1
0
"""
State the probability achieved by your adversary and the number of oracle calls
it makes.

probability:

queries:
"""

from crypto.games.game_lr import GameLR
from crypto.simulator.lr_sim import LRSim

if __name__ == '__main__':
    g = GameLR(encrypt, 16, 16)
    s = LRSim(g, adversary)

    print "The advantage of your adversary is ~" + str(s.compute_advantage())

    key = random_string(block_size)

    for j in range(100):
        blocks = random.randrange(100)
        message = random_string(blocks * 16)
        cypher = encrypt(key, message)
        bad = False
        if message != decrypt(key, cypher):
            bad = True
    if bad:
        print "Your Decryption function is incorrect"
    else:
コード例 #2
0
ファイル: exercise_2.py プロジェクト: avivkiss/cs107-w16
    world.
    """

    pass


"""
3. [10 points] Provide a succinct analysis justifying the claimed advantage:
--&--
[Answer here.]
"""

from crypto.games.game_lr import GameLR
from crypto.simulator.lr_sim import LRSim

if __name__ == '__main__':
    g = GameLR(encrypt, key_len)
    s = LRSim(g, A)

    print "The advantage of your adversary is ~" + str(s.compute_advantage())

    key = random_string(key_len)

    for j in range(100):
        blocks = random.randrange(100)
        message = random_string(blocks*block_len)
        cypher = encrypt(key, message)
        if message != decrypt(key, cypher):
            print "Your Decryption function is incorrect"
    print "Your Decryption function is correct"
コード例 #3
0
ファイル: exercise_1.py プロジェクト: avivkiss/cs107-w16
    :param enc: This is an oracle supplied by GameINTCTXT, you can call this
    oracle to get an encryption of the data you pass into it.
    :param dec: This is an oracle supplied by GameINTCTXT, you can call this
    oracle to get a decryption of the data you pass into it.
    """
    pass


"""
3. [15 points] Is SE an Encrypt-and-MAC construction? Justify your answer.
--&--
[Answer here].
"""

from crypto.games.game_lr import GameLR
from crypto.simulator.lr_sim import LRSim

from crypto.games.game_int_ctxt import GameINTCTXT
from crypto.simulator.ctxt_sim import CTXTSim

if __name__ == '__main__':
    g1 = GameLR(E, 16)
    s1 = LRSim(g1, A_1)

    g2 = GameINTCTXT(E, D, key_len)
    s2 = CTXTSim(g2, A_2)

    print "The advantage of A_1 adversary is ~" + str(s1.compute_advantage())
    print "The advantage of A_2 adversary is ~" + str(s2.compute_advantage())
コード例 #4
0
    :param enc: This is an oracle supplied by GameINTCTXT, you can call this
    oracle to get an encryption of the data you pass into it.
    :param dec: This is an oracle supplied by GameINTCTXT, you can call this
    oracle to get a decryption of the data you pass into it.
    """
    pass


"""
3. [15 points] Is SE an Encrypt-and-MAC construction? Justify your answer.
--&--
[Answer here].
"""

from crypto.games.game_lr import GameLR
from crypto.simulator.lr_sim import LRSim

from crypto.games.game_int_ctxt import GameINTCTXT
from crypto.simulator.ctxt_sim import CTXTSim

if __name__ == '__main__':
    g1 = GameLR(E, 16)
    s1 = LRSim(g1, A_1)

    g2 = GameINTCTXT(E, D, key_len)
    s2 = CTXTSim(g2, A_2)

    print "The advantage of A_1 adversary is ~" + str(s1.compute_advantage())
    print "The advantage of A_2 adversary is ~" + str(s2.compute_advantage())