Documentation ¶
Index ¶
- Variables
- type Conversation
- func (c *Conversation) Authenticate(question string, mutualSecret []byte) (toSend [][]byte, err error)
- func (c *Conversation) End() (toSend [][]byte)
- func (Conversation) HandleErrorMessage(error otr3.ErrorCode) []byte
- func (e *Conversation) HandleMessageEvent(event otr3.MessageEvent, message []byte, err error)
- func (e *Conversation) HandleSMPEvent(event otr3.SMPEvent, progressPercent int, question string)
- func (e *Conversation) HandleSecurityEvent(event otr3.SecurityEvent)
- func (c *Conversation) Receive(in []byte) (out []byte, encrypted bool, change SecurityChange, toSend [][]byte, err error)
- func (c *Conversation) SMPQuestion() string
- func (c *Conversation) Send(in []byte) (toSend [][]byte, err error)
- func (Conversation) WishToHandleErrorMessage() bool
- type PrivateKey
- type PublicKey
- type SecurityChange
Constants ¶
This section is empty.
Variables ¶
var ( // QueryMessage can be sent to a peer to start an OTR conversation. QueryMessage = "?OTRv2?" // ErrorPrefix can be used to make an OTR error by appending an error message // to it. ErrorPrefix = "?OTR Error:" )
Functions ¶
This section is empty.
Types ¶
type Conversation ¶
type Conversation struct { otr3.Conversation TheirPublicKey PublicKey PrivateKey *PrivateKey SSID [8]byte FragmentSize int // contains filtered or unexported fields }
Conversation represents a relation with a peer.
func (*Conversation) Authenticate ¶
func (c *Conversation) Authenticate(question string, mutualSecret []byte) (toSend [][]byte, err error)
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 (*Conversation) End ¶
func (c *Conversation) End() (toSend [][]byte)
End ends a secure conversation by generating a termination message for the peer and switches to unencrypted communication.
func (Conversation) HandleErrorMessage ¶
func (*Conversation) HandleMessageEvent ¶
func (e *Conversation) HandleMessageEvent(event otr3.MessageEvent, message []byte, err error)
func (*Conversation) HandleSMPEvent ¶
func (*Conversation) HandleSecurityEvent ¶
func (e *Conversation) HandleSecurityEvent(event otr3.SecurityEvent)
func (*Conversation) Receive ¶
func (c *Conversation) Receive(in []byte) (out []byte, encrypted bool, change SecurityChange, toSend [][]byte, err error)
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 (*Conversation) SMPQuestion ¶
func (c *Conversation) SMPQuestion() string
SMPQuestion returns the human readable challenge question from the peer. It's only valid after Receive has returned SMPSecretNeeded.
func (*Conversation) Send ¶
func (c *Conversation) Send(in []byte) (toSend [][]byte, err error)
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 (Conversation) WishToHandleErrorMessage ¶
func (Conversation) WishToHandleErrorMessage() bool
type PrivateKey ¶
type PrivateKey struct { otr3.PrivateKey PublicKey }
PrivateKey represents an OTR Private Key
func (*PrivateKey) Generate ¶
func (priv *PrivateKey) Generate(rand io.Reader)
Generate will generate a new Private Key using the provided randomness
func (*PrivateKey) Parse ¶
func (priv *PrivateKey) Parse(in []byte) (index []byte, ok bool)
Parse will parse a Private Key from the given data, by first parsing the public key components and then the private key component. It returns not ok for the same reasons as PublicKey.Parse.
func (*PrivateKey) Serialize ¶
func (priv *PrivateKey) Serialize(in []byte) []byte
Serialize will serialize the private key
type PublicKey ¶
PublicKey represents an OTR Public Key
func (*PublicKey) Fingerprint ¶
Fingerprint will generate a new SHA-1 fingerprint of the serialization of the public key
type SecurityChange ¶
type SecurityChange int
SecurityChange describes a change in the security state of a Conversation.
const ( // NoChange happened in the security status NoChange SecurityChange = iota // NewKeys indicates that a key exchange has completed. This occurs // when a conversation first becomes encrypted, and when the keys are // renegotiated within an encrypted conversation. NewKeys // SMPSecretNeeded indicates that the peer has started an // authentication and that we need to supply a secret. Call SMPQuestion // to get the optional, human readable challenge and then Authenticate // to supply the matching secret. SMPSecretNeeded // SMPComplete indicates that an authentication completed. The identity // of the peer has now been confirmed. SMPComplete // SMPFailed indicates that an authentication failed. SMPFailed // ConversationEnded indicates that the peer ended the secure // conversation. ConversationEnded )