本文整理汇总了Python中speck.SpeckCipher类的典型用法代码示例。如果您正苦于以下问题:Python SpeckCipher类的具体用法?Python SpeckCipher怎么用?Python SpeckCipher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpeckCipher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_pcbc_mode_single
def test_pcbc_mode_single(self):
c = SpeckCipher(self.key, self.key_size, self.block_size, 'PCBC', init=self.iv)
pcbc_out = c.encrypt(self.plaintxt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'ECB')
pcbc_equivalent = c.encrypt(self.iv ^ self.plaintxt)
assert pcbc_out == pcbc_equivalent
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:8,代码来源:tests.py
示例2: test_speck128_256
def test_speck128_256(self):
block_size = 128
key_size = 256
for x in range(self.test_cnt):
key = randint(0, (2**key_size) - 1)
plaintxt = randint(0, (2**block_size) - 1)
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.decrypt(c.encrypt(plaintxt)) == plaintxt, 'Test %r Failed with Random Key %r and Random Plaintext %r' % (x, hex(key), hex(plaintxt))
开发者ID:prashantbarca,项目名称:simon-speck-sim,代码行数:8,代码来源:tests.py
示例3: test_speck64_96
def test_speck64_96(self):
key = 0x131211100b0a090803020100
plaintxt = 0x74614620736e6165
ciphertxt = 0x9f7952ec4175946c
block_size = 64
key_size = 96
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例4: test_speck96_144
def test_speck96_144(self):
key = 0x1514131211100d0c0b0a0908050403020100
plaintxt = 0x656d6974206e69202c726576
ciphertxt = 0x2bf31072228a7ae440252ee6
block_size = 96
key_size = 144
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例5: test_ctr_mode_equivalent
def test_ctr_mode_equivalent(self):
c = SpeckCipher(self.key, self.key_size, self.block_size, 'CTR', init=self.iv, counter=self.counter)
ctr_out = c.encrypt(self.plaintxt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'ECB')
ecb_out = c.encrypt(self.iv + self.counter)
ctr_equivalent = ecb_out ^ self.plaintxt
assert ctr_out == ctr_equivalent
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例6: test_speck48_96
def test_speck48_96(self):
key = 0x1a19181211100a0908020100
plaintxt = 0x6d2073696874
ciphertxt = 0x735e10b6445d
block_size = 48
key_size = 96
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例7: test_speck128_256
def test_speck128_256(self):
block_size = 128
key_size = 256
for x in range(self.test_cnt):
key = randint(0, (2**key_size) - 1)
plaintxt = randint(0, (2**block_size) - 1)
print(x, hex(key), hex(plaintxt))
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.decrypt(c.encrypt(plaintxt)) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例8: test_speck48_72
def test_speck48_72(self):
key = 0x1211100a0908020100
plaintxt = 0x20796c6c6172
ciphertxt = 0xc049a5385adc
block_size = 48
key_size = 72
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例9: test_speck32_64
def test_speck32_64(self):
key = 0x1918111009080100
plaintxt = 0x6574694c
ciphertxt = 0xa86842f2
block_size = 32
key_size = 64
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例10: test_speck96_96
def test_speck96_96(self):
key = 0x0d0c0b0a0908050403020100
plaintxt = 0x65776f68202c656761737520
ciphertxt = 0x9e4d09ab717862bdde8f79aa
block_size = 96
key_size = 96
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例11: test_ofb_mode_chain
def test_ofb_mode_chain(self):
plaintxts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
c = SpeckCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
ciphertexts = [c.encrypt(x) for x in plaintxts]
c = SpeckCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
decryptexts = [c.decrypt(x) for x in ciphertexts]
assert plaintxts == decryptexts
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例12: test_speck64_128
def test_speck64_128(self):
key = 0x1b1a1918131211100b0a090803020100
plaintxt = 0x3b7265747475432d
ciphertxt = 0x8c6fa548454e028b
block_size = 64
key_size = 128
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例13: test_speck128_128
def test_speck128_128(self):
key = 0x0f0e0d0c0b0a09080706050403020100
plaintxt = 0x6c617669757165207469206564616d20
ciphertxt = 0xa65d9851797832657860fedf5c570d18
block_size = 128
key_size = 128
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例14: test_speck128_192
def test_speck128_192(self):
key = 0x17161514131211100f0e0d0c0b0a09080706050403020100
plaintxt = 0x726148206665696843206f7420746e65
ciphertxt = 0x1be4cf3a13135566f9bc185de03c1886
block_size = 128
key_size = 192
c = SpeckCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:9,代码来源:tests.py
示例15: test_ctr_mode_single_cycle
def test_ctr_mode_single_cycle(self):
self.counter = 0x01
c = SpeckCipher(self.key, self.key_size, self.block_size, 'CTR', init=self.iv, counter=self.counter)
ctr_out = c.encrypt(self.plaintxt)
self.counter = 0x01
c = SpeckCipher(self.key, self.key_size, self.block_size, 'CTR', init=self.iv, counter=self.counter)
output_plaintext = c.decrypt(ctr_out)
assert output_plaintext == self.plaintxt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:13,代码来源:tests.py
示例16: test_ctr_mode_chain
def test_ctr_mode_chain(self):
c = SpeckCipher(self.key, self.key_size, self.block_size, 'CTR', init=self.iv, counter=self.counter)
ctr_out = 0
for x in range(1000):
ctr_out = c.encrypt(self.plaintxt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'ECB')
ctr_equivalent = 0
for x in range(1000):
ecb_out = c.encrypt(self.iv + self.counter)
self.counter += 1
ctr_equivalent = ecb_out ^ self.plaintxt
assert ctr_out == ctr_equivalent
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:16,代码来源:tests.py
示例17: test_cbc_mode_chain
def test_cbc_mode_chain(self):
c = SpeckCipher(self.key, self.key_size, self.block_size, 'CBC', init=self.iv)
cbc_out = 0
for x in range(1000):
cbc_out = c.encrypt(self.plaintxt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'ECB')
cbc_equivalent = self.iv
for x in range(1000):
cbc_input = self.plaintxt ^ cbc_equivalent
cbc_equivalent = c.encrypt(cbc_input)
assert cbc_out == cbc_equivalent
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:16,代码来源:tests.py
示例18: test_pcbc_mode_chain
def test_pcbc_mode_chain(self):
c = SpeckCipher(self.key, self.key_size, self.block_size, 'PCBC', init=self.iv)
pcbc_out = 0
for x in range(1000):
pcbc_out = c.encrypt(self.plaintxt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'ECB')
pcbc_equivalent = 0
for x in range(1000):
pcbc_input = self.plaintxt ^ self.iv
pcbc_equivalent = c.encrypt(pcbc_input)
self.iv = pcbc_equivalent ^ self.plaintxt
assert pcbc_out == pcbc_equivalent
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:17,代码来源:tests.py
示例19: argon2_test
def argon2_test():
start = time.time()
ph = PasswordHasher()
hash = ph.hash(password)
hashed = hashlib.sha256(hash).digest()
end = time.time()
print "argon2 : ",(end-start)
start = time.time()
obj =AES.new(hashed,AES.MODE_CBC, 'This is an IV456')
ciphertext = obj.encrypt("The answer is no")
end = time.time()
print "AES Encrypt: ",(end-start)*1000
start = time.time()
obj =AES.new(hashed,AES.MODE_CBC, 'This is an IV456')
plaintext = obj.decrypt(ciphertext)
end = time.time()
print "AES Decrypt: ",(end-start)*1000
my_plaintext = 0xCCCCAAAA55553333
start = time.time()
big_cipher = SimonCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
simon = big_cipher.encrypt(my_plaintext)
end = time.time()
print "Simon Encrypt: ",(end-start)*1000
start = time.time()
big_cipher1 = SpeckCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
speck = big_cipher1.encrypt(my_plaintext)
end = time.time()
print "Speck Encrypt: ",(end-start)*1000
start = time.time()
big_cipher = SimonCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
plain = big_cipher.decrypt(simon)
end = time.time()
print plain
print "Simon Decrypt: ",(end-start)*1000
start = time.time()
big_cipher1 = SpeckCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
plain = big_cipher1.decrypt(speck)
end = time.time()
print plain
print "Speck Decrypt: ",(end-start)*1000
开发者ID:prashantbarca,项目名称:simon-speck-sim,代码行数:40,代码来源:share.py
示例20: test_ofb_mode_equivalent
def test_ofb_mode_equivalent(self):
c = SpeckCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
ofb_encrypt = c.encrypt(self.plaintxt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
ofb_decrypt = c.decrypt(ofb_encrypt)
c = SpeckCipher(self.key, self.key_size, self.block_size, 'ECB')
ecb_out = c.encrypt(self.iv)
ofb_equivalent_encrypt = ecb_out ^ self.plaintxt
ofb_equivalent_decrypt = ecb_out ^ ofb_equivalent_encrypt
assert ofb_encrypt == ofb_equivalent_encrypt
assert ofb_decrypt == ofb_equivalent_decrypt
开发者ID:yuehann,项目名称:IOT_Gateway,代码行数:13,代码来源:tests.py
注:本文中的speck.SpeckCipher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论