<s> import binascii <EOL> import botan <EOL> from tests . utils import load_nist_vectors <EOL> BLOCK_SIZE = <NUM_LIT:64> <EOL> def encrypt ( mode , key , iv , plaintext ) : <EOL> encryptor = botan . Cipher ( "<STR_LIT>" . format ( mode ) , "<STR_LIT>" , <EOL> binascii . unhexlify ( key ) ) <EOL> cipher_text = encryptor . cipher ( binascii . unhexlify ( plaintext ) , <EOL> binascii . unhexlify ( iv ) ) <EOL> return binascii . hexlify ( cipher_text ) <EOL> def verify_vectors ( mode , filename ) : <EOL> with open ( filename , "<STR_LIT:r>" ) as f : <EOL> vector_file = f . read ( ) . splitlines ( ) <EOL> vectors = load_nist_vectors ( vector_file ) <EOL> for vector in vectors : <EOL> ct = encrypt ( <EOL> mode , <EOL> vector [ "<STR_LIT:key>" ] , <EOL> vector [ "<STR_LIT>" ] , <EOL> vector [ "<STR_LIT>" ] <EOL> ) <EOL> assert ct == vector [ "<STR_LIT>" ] <EOL> cbc_path = "<STR_LIT>" <EOL> verify_vectors ( "<STR_LIT>" , cbc_path ) <EOL> ofb_path = "<STR_LIT>" <EOL> verify_vectors ( "<STR_LIT>" , ofb_path ) <EOL> cfb_path = "<STR_LIT>" <EOL> verify_vectors ( "<STR_LIT>" , cfb_path ) </s>
