def test_RC4(self): # RC4 encrypt and decrypt kb = h('68F263DB3FCE15D031C9EAB02D67107A') conf = h('37245E73A45FBF72') keyusage = 4 plain = b'30 bytes bytes bytes bytes byt' ctxt = h( '95F9047C3AD75891C2E9B04B16566DC8B6EB9CE4231AFB2542EF87A7B5A0F260' 'A99F0460508DE0CECC632D07C354124E46C5D2234EB8') k = Key(Enctype.RC4, kb) self.assertEqual(encrypt(k, keyusage, plain, conf), ctxt) self.assertEqual(decrypt(k, keyusage, ctxt), plain)
def test_AES128(self): # AES128 encrypt and decrypt kb = h('9062430C8CDA3388922E6D6A509F5B7A') conf = h('94B491F481485B9A0678CD3C4EA386AD') keyusage = 2 plain = b'9 bytesss' ctxt = h( '68FB9679601F45C78857B2BF820FD6E53ECA8D42FD4B1D7024A09205ABB7CD2E' 'C26C355D2F') k = Key(Enctype.AES128, kb) self.assertEqual(encrypt(k, keyusage, plain, conf), ctxt) self.assertEqual(decrypt(k, keyusage, ctxt), plain)
def test_DES3(self): # DES3 encrypt and decrypt kb = h('0DD52094E0F41CECCB5BE510A764B35176E3981332F1E598') conf = h('94690A17B2DA3C9B') keyusage = 3 plain = b'13 bytes byte' ctxt = h( '839A17081ECBAFBCDC91B88C6955DD3C4514023CF177B77BF0D0177A16F705E8' '49CB7781D76A316B193F8D30') k = Key(Enctype.DES3, kb) self.assertEqual(encrypt(k, keyusage, plain, conf), ctxt) self.assertEqual(decrypt(k, keyusage, ctxt), _zeropad(plain, 8))
def test_AES256(self): # AES256 encrypt and decrypt kb = h( 'F1C795E9248A09338D82C3F8D5B567040B0110736845041347235B1404231398') conf = h('E45CA518B42E266AD98E165E706FFB60') keyusage = 4 plain = b'30 bytes bytes bytes bytes byt' ctxt = h( 'D1137A4D634CFECE924DBC3BF6790648BD5CFF7DE0E7B99460211D0DAEF3D79A' '295C688858F3B34B9CBD6EEBAE81DAF6B734D4D498B6714F1C1D') k = Key(Enctype.AES256, kb) self.assertEqual(encrypt(k, keyusage, plain, conf), ctxt) self.assertEqual(decrypt(k, keyusage, ctxt), plain)