def pad_pkcs7(key, block_len=16):
    """Pad given key using PKCS#7.
    Args
        key: byte array of key to pad
        block_len: length of block to which to pad key
    Returns
        bytearray of padded key
    """
    if block_len == len(key):
        pad_len = block_len
    else:
        pad_len = block_len - len(key)
    return key + bytearray([pad_len] * pad_len)