def aes_cbc_no_padding_encrypt(key, data, iv):
cipher = _calculate_aes_cipher(key)<EOL>if not iv:<EOL><INDENT>iv = rand_bytes(<NUM_LIT:16>)<EOL><DEDENT>elif len(iv) != <NUM_LIT:16>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>len(iv)<EOL>))<EOL><DEDENT>if len(data) % <NUM_LIT:16> != <NUM_LIT:0>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>len(data)<EOL>))<EOL><DEDENT>return (iv, _encrypt(cipher, key, data, iv, False))<EOL>
Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
no padding. This means the ciphertext must be an exact multiple of 16 bytes
long.

:param key:
    The encryption key - a byte string either 16, 24 or 32 bytes long

:param data:
    The plaintext - a byte string

:param iv:
    The initialization vector - either a byte string 16-bytes long or None
    to generate an IV

:raises:
    ValueError - when any of the parameters contain an invalid value
    TypeError - when any of the parameters are of the wrong type
    OSError - when an error is returned by OpenSSL

:return:
    A tuple of two byte strings (iv, ciphertext)