Exemplo n.º 1
0
 def sigma2(self, m_list):
     s = self.sigma1(m_list)
     ones = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
     teta1 = s + m_list[48:64]
     teta2 = xor(s, ones) + m_list[32:48]
     u1 = m_list[0:16]
     u2 = m_list[16:32]
     my_belt = belt.belt(teta1)
     tmp = xor(my_belt.encryption(u1), u1)
     my_belt2 = belt.belt(teta2)
     tm2 = xor(my_belt2.encryption(u2), u2)
     return tmp + tm2
Exemplo n.º 2
0
 def sigma2(self, m_list):
     s = self.sigma1(m_list)
     ones = [
         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
         0xff, 0xff, 0xff, 0xff, 0xff
     ]
     teta1 = s + m_list[48:64]
     teta2 = xor(s, ones) + m_list[32:48]
     u1 = m_list[0:16]
     u2 = m_list[16:32]
     my_belt = belt.belt(teta1)
     tmp = xor(my_belt.encryption(u1), u1)
     my_belt2 = belt.belt(teta2)
     tm2 = xor(my_belt2.encryption(u2), u2)
     return tmp + tm2
Exemplo n.º 3
0
def test_belt_decr():
    c = list(binascii.unhexlify('E12BDC1AE28257EC703FCCF095EE8DF1'))
    key2 = list(
        binascii.unhexlify(
            '92BD9B1CE5D141015445FBC95E4D0EF2682080AA227D642F2687F93490405511')
    )
    belt2 = belt(key2)
    d1 = binascii.hexlify(bytearray(belt2.decryption(c)))
    assert d1 == b'0dc5300600cab840b38448e5e993f421'
Exemplo n.º 4
0
def test_belt_encr():
    key = list(
        binascii.unhexlify(
            'E9DEE72C8F0C0FA62DDB49F46F73964706075316ED247A3739CBA38303A98BF6')
    )
    belt1 = belt(key)
    m = list(binascii.unhexlify('B194BAC80A08F53B366D008E584A5DE4'))
    c1 = binascii.hexlify(bytearray(belt1.encryption(m)))
    assert c1 == b'69cca1c93557c9e3d66bc3e0fa88fa6e'
Exemplo n.º 5
0
 def test_belt_decr(self):
     c = list(binascii.unhexlify('E12BDC1AE28257EC703FCCF095EE8DF1'))
     key2 = list(binascii.unhexlify('92BD9B1CE5D141015445FBC95E4D0EF2682080AA227D642F2687F93490405511'))
     belt2 = belt(key2)
     d1 = binascii.hexlify(bytearray(belt2.decryption(c)))
     self.assertEqual(d1, b'0dc5300600cab840b38448e5e993f421')
Exemplo n.º 6
0
 def test_belt_encr(self):
     key = list(binascii.unhexlify('E9DEE72C8F0C0FA62DDB49F46F73964706075316ED247A3739CBA38303A98BF6'))
     belt1 = belt(key)
     m = list(binascii.unhexlify('B194BAC80A08F53B366D008E584A5DE4'))
     c1 = binascii.hexlify(bytearray(belt1.encryption(m)))
     self.assertEqual(c1, b'69cca1c93557c9e3d66bc3e0fa88fa6e')
Exemplo n.º 7
0
 def sigma1(self, m_list):
     my_belt = belt.belt(m_list[:32])
     m = xor(m_list[32:48], m_list[48:64])
     sigma1 = xor(my_belt.encryption(m), m_list[32:48])
     sigma1 = xor(sigma1, m_list[48:64])
     return sigma1
Exemplo n.º 8
0
 def sigma1(self, m_list):
     my_belt = belt.belt(m_list[:32])
     m = xor(m_list[32:48], m_list[48:64])
     sigma1 = xor(my_belt.encryption(m), m_list[32:48])
     sigma1 = xor(sigma1, m_list[48:64])
     return sigma1