예제 #1
0
def encrypt(pt):
    pt = junk() + pt + junk()
    k, iv = util.rbytes(16), util.rbytes(16)
    if util.rbool():
        return "ECB", util.AesEcbCipher(k).encrypt(pt)
    else:
        return "CBC", util.AesCbcCipher(k, iv).encrypt(pt)
예제 #2
0
 def __init__(self):
     self.ecb = util.AesEcbCipher(util.rbytes(16))
     self.suffix = base64.b64decode(INPUT)
예제 #3
0
def test_solve():
    ecb = util.AesEcbCipher(b"YELLOW SUBMARINE")
    ctr = AesCtrEditingCipher(util.rbytes(16), util.rbytes(8))
    with open("files/25.txt") as f:
        pt = ecb.decrypt(base64.b64decode(f.read()))
    assert recover_pt(ctr, ctr.crypt(pt)) == pt
예제 #4
0
def test_aes_ecb_cipher():
    for n in range(1, 33):
        k, pt = util.rbytes(16), util.rbytes(n)
        cipher = util.AesEcbCipher(k)
        assert cipher.decrypt(cipher.encrypt(pt)) == pt
예제 #5
0
def test_solve():
    with open("files/07.txt") as f:
        ct = base64.b64decode(f.read())
    with open("files/play_that_funky_music.txt") as f:
        pt = f.read()
    assert util.AesEcbCipher(b"YELLOW SUBMARINE").decrypt(ct).decode() == pt
예제 #6
0
 def __init__(self):
     self.ecb = util.AesEcbCipher(util.rbytes(16))