def pkcs_7(b: bytes, size: int) -> bytes:
    """
    PKCS#7 padding.
    Given the block size, pad the input buffer,
    so that the result is a multiple of the specified size.

    Please note that this function will always pad,
    even if the buffer is already a multiple of the size.
    So, if size is 16 and b is "YELLOW SUBMARINE",
    it will be padded to:
    b'YELLOW SUBMARINE\x10\x10\x10\x10\...\x10\x10\x10\x10'

    :param b: A buffer of bytes.
    :param size: The block size.
    :return: The padded buffer.
    """
    assert size <= 0xff

    b = bytearray(b)
    padding = size - (len(b) % size)
    for _ in range(padding):
        b.append(padding)

    return bytes(b)