'Inject an early CCS while preserving the rest of the data.'

def _inject_ccs(self, record, hello_message_index):

    version = record.version
    ccs = TlsRecord(TlsRecord.CONTENT_TYPE.CHANGE_CIPHER_SPEC, version, [tls.types.ChangeCipherSpec(1)])
    rec = TlsRecord(TlsRecord.CONTENT_TYPE.HANDSHAKE, version, record.messages[:(hello_message_index + 1)])
    remaining = record.messages[(hello_message_index + 1):]
    if remaining:
        rest = TlsRecord(TlsRecord.CONTENT_TYPE.HANDSHAKE, version, remaining).to_bytes()
    else:
        rest = ''
    return ((rec.to_bytes() + ccs.to_bytes()) + rest)
