compat

package
v0.0.0-...-9c7a536 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2015 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) HandleErrorMessage(error otr3.ErrorCode) []byte

func (*Conversation) HandleMessageEvent

func (e *Conversation) HandleMessageEvent(event otr3.MessageEvent, message []byte, err error)

func (*Conversation) HandleSMPEvent

func (e *Conversation) HandleSMPEvent(event otr3.SMPEvent, progressPercent int, question string)

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

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(rand io.Reader, hashed []byte) []byte

Sign will generate a signature of a hashed data using dsa Sign.

type PublicKey

type PublicKey struct {
	otr3.PublicKey
}

PublicKey represents an OTR Public Key

func (*PublicKey) Fingerprint

func (pub *PublicKey) Fingerprint() []byte

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL