Server IP : 162.240.98.243 / Your IP : 18.190.160.106 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/python2-cryptography-1.7.2/docs/development/custom-vectors/idea/ |
Upload File : |
import binascii import botan from tests.utils import load_nist_vectors BLOCK_SIZE = 64 def encrypt(mode, key, iv, plaintext): encryptor = botan.Cipher("IDEA/{0}/NoPadding".format(mode), "encrypt", binascii.unhexlify(key)) cipher_text = encryptor.cipher(binascii.unhexlify(plaintext), binascii.unhexlify(iv)) return binascii.hexlify(cipher_text) def verify_vectors(mode, filename): with open(filename, "r") as f: vector_file = f.read().splitlines() vectors = load_nist_vectors(vector_file) for vector in vectors: ct = encrypt( mode, vector["key"], vector["iv"], vector["plaintext"] ) assert ct == vector["ciphertext"] cbc_path = "tests/hazmat/primitives/vectors/ciphers/IDEA/idea-cbc.txt" verify_vectors("CBC", cbc_path) ofb_path = "tests/hazmat/primitives/vectors/ciphers/IDEA/idea-ofb.txt" verify_vectors("OFB", ofb_path) cfb_path = "tests/hazmat/primitives/vectors/ciphers/IDEA/idea-cfb.txt" verify_vectors("CFB", cfb_path)