def _add_pkcs1v15_padding(key_length, data, operation):
if operation == '<STR_LIT>':<EOL><INDENT>second_byte = b'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>second_byte = b'<STR_LIT>'<EOL><DEDENT>if not isinstance(data, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(data)<EOL>))<EOL><DEDENT>if not isinstance(key_length, int_types):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(key_length)<EOL>))<EOL><DEDENT>if key_length < <NUM_LIT:64>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>repr(key_length)<EOL>))<EOL><DEDENT>if len(data) > key_length - <NUM_LIT:11>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>key_length - <NUM_LIT:11>,<EOL>len(data)<EOL>))<EOL><DEDENT>required_bytes = key_length - <NUM_LIT:3> - len(data)<EOL>padding = b'<STR_LIT>'<EOL>while required_bytes > <NUM_LIT:0>:<EOL><INDENT>temp_padding = rand_bytes(required_bytes)<EOL>temp_padding = b'<STR_LIT>'.join(temp_padding.split(b'<STR_LIT:\x00>'))<EOL>padding += temp_padding<EOL>required_bytes -= len(temp_padding)<EOL><DEDENT>return b'<STR_LIT:\x00>' + second_byte + padding + b'<STR_LIT:\x00>' + data<EOL>
Adds PKCS#1 v1.5 padding to a message

:param key_length:
    An integer of the number of bytes in the key

:param data:
    A byte string to unpad

:param operation:
    A unicode string of "encrypting" or "signing"

:return:
    The padded data as a byte string