Example #1
0
 def test_ecb_vectors(self):
     ciphtext = ""
     ciphtext += "7f679d90bebc24305a468d42b9d4edcd"
     ciphtext += "b429912c6e0032f9285452d76718d08b"
     ciphtext += "f0ca33549d247ceef3f5a5313bd4b157"
     ciphtext += "d0b09ccde830b9eb3a02c4c5aa8ada98"
     self.assertSequenceEqual(
         hexenc(ecb_encrypt(self.ciph.encrypt, 16, hexdec(self.plaintext))),
         ciphtext,
     )
     self.assertSequenceEqual(
         hexenc(ecb_decrypt(self.ciph.decrypt, 16, hexdec(ciphtext))),
         self.plaintext,
     )
Example #2
0
 def test_ecb_vectors(self):
     ciphtext = ""
     ciphtext += "2b073f0494f372a0"
     ciphtext += "de70e715d3556e48"
     ciphtext += "11d8d9e9eacfbc1e"
     ciphtext += "7c68260996c67efb"
     self.assertSequenceEqual(
         hexenc(ecb_encrypt(self.ciph.encrypt, 8, hexdec(self.plaintext))),
         ciphtext,
     )
     self.assertSequenceEqual(
         hexenc(ecb_decrypt(self.ciph.decrypt, 8, hexdec(ciphtext))),
         self.plaintext,
     )
Example #3
0
    def test_ecb_symmetric(self):
        for _ in range(100):
            pt = pad2(urandom(randint(0, 16 * 2)), 16)
            ciph = GOST3412Kuznechik(urandom(32))
            ct = ecb_encrypt(ciph.encrypt, 16, pt)
            dt = ecb_decrypt(ciph.decrypt, 16, ct)
            print(hexenc(self.key))
            #print(hexenc(dt))
'''
'''
key = ""
key += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
s = key.encode("utf-8").hex()
ciph = GOST3412Kuznechik(hexdec(s))
#print(s)
plaintext = ""
plaintext += "holaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".encode("utf-8").hex()
texto_enc = hexenc(ecb_encrypt(ciph.encrypt, 16, hexdec(plaintext)))
texto_dec = hexenc(ecb_decrypt(ciph.decrypt, 16, hexdec(texto_enc)))
print(plaintext)
print(texto_enc)
print(texto_dec)
'''

pt = hexdec("holaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".encode("utf-8").hex())
ciph = GOST3412Kuznechik(urandom(32))
ct = ecb_encrypt(ciph.encrypt, 16, pt)
dt = ecb_decrypt(ciph.decrypt, 16, ct)
print(hexenc(pt))
print(hexenc(ct))
print(hexenc(dt))
Example #4
0
 def encrypt(self, text):
     buffer = self.padding(text)
     res = gost3413.ecb_encrypt(self.enc, self.blen, buffer)
     return res
Example #5
0
 def test_ecb_symmetric(self):
     for _ in range(100):
         pt = pad2(urandom(randint(0, 16 * 2)), 16)
         ciph = GOST3412Kuznechik(urandom(32))
         ct = ecb_encrypt(ciph.encrypt, 16, pt)
         self.assertSequenceEqual(ecb_decrypt(ciph.decrypt, 16, ct), pt)