def _openssl_key_iv(passphrase, salt):
def _openssl_kdf(req):<EOL><INDENT>if hasattr(passphrase, '<STR_LIT>'):<EOL><INDENT>passwd = passphrase.encode('<STR_LIT:ascii>', '<STR_LIT:ignore>')<EOL><DEDENT>else:<EOL><INDENT>passwd = passphrase<EOL><DEDENT>prev = b'<STR_LIT>'<EOL>while req > <NUM_LIT:0>:<EOL><INDENT>digest = hashes.Hash(hashes.MD5(), backend=default_backend())<EOL>digest.update(prev + passwd + salt)<EOL>prev = digest.finalize()<EOL>req -= IV_BLOCK_SIZE<EOL>yield prev<EOL><DEDENT><DEDENT>assert passphrase is not None<EOL>assert salt is not None<EOL>mat = b'<STR_LIT>'.join([x for x in _openssl_kdf(<NUM_LIT:32> + IV_BLOCK_SIZE)])<EOL>return mat[<NUM_LIT:0>:<NUM_LIT:32>], mat[<NUM_LIT:32>:<NUM_LIT:32> + IV_BLOCK_SIZE]<EOL>
Returns a (key, iv) tuple that can be used in AES symmetric encryption
from a *passphrase* (a byte or unicode string) and *salt* (a byte array).