// End ends a secure conversation by generating a termination message for // the peer and switches to unencrypted communication. func (c *Conversation) End() (toSend [][]byte) { c.compatInit() ret, _ := c.Conversation.End() if ret != nil { toSend = otr3.Bytes(ret) } c.updateValues() return }
// Send takes a human readable message from the local user, possibly encrypts // it and returns zero one or more messages to send to the peer. func (c *Conversation) Send(in []byte) (toSend [][]byte, err error) { c.compatInit() var ret []otr3.ValidMessage ret, err = c.Conversation.Send(in) if ret != nil { toSend = otr3.Bytes(ret) } c.updateValues() return }
// Authenticate begins an authentication with the peer. Authentication involves // an optional challenge message and a shared secret. The authentication // proceeds until either Receive returns SMPComplete, SMPSecretNeeded (which // indicates that a new authentication is happening and thus this one was // aborted) or SMPFailed. func (c *Conversation) Authenticate(question string, mutualSecret []byte) (toSend [][]byte, err error) { c.compatInit() var ret []otr3.ValidMessage if c.eventHandler.waitingForSecret { c.eventHandler.waitingForSecret = false ret, err = c.ProvideAuthenticationSecret(mutualSecret) } else { ret, err = c.StartAuthenticate(question, mutualSecret) } c.updateValues() return otr3.Bytes(ret), err }
// Receive handles a message from a peer. It returns a human readable message, // an indicator of whether that message was encrypted, a hint about the // encryption state and zero or more messages to send back to the peer. // These messages do not need to be passed to Send before transmission. func (c *Conversation) Receive(in []byte) (out []byte, encrypted bool, change SecurityChange, toSend [][]byte, err error) { c.compatInit() var ret []otr3.ValidMessage out, ret, err = c.Conversation.Receive(in) encrypted = c.IsEncrypted() if ret != nil { toSend = otr3.Bytes(ret) } c.updateValues() change = c.eventHandler.consumeSecurityChange() return }