session

package
Version: v0.0.0-...-d09bcab Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2017 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package session provides the methods necessary to build sessions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is responsible for setting up encrypted sessions. Once a session has been established, SessionCipher can be used to encrypt/decrypt messages in that session.

Sessions are built from one of three different vectors:

* PreKeyBundle retrieved from a server.
* PreKeySignalMessage received from a client.
* KeyExchangeMessage sent to or received from a client.

Sessions are constructed per recipientId + deviceId tuple. Remote logical users are identified by their recipientId, and each logical recipientId can have multiple physical devices.

func NewBuilder

func NewBuilder(sessionStore store.Session, preKeyStore store.PreKey,
	signedStore store.SignedPreKey, identityStore store.IdentityKey,
	remoteAddress *protocol.SignalAddress, serializer *serialize.Serializer) *Builder

NewBuilder constructs a session builder.

func NewBuilderFromSignal

func NewBuilderFromSignal(signalStore store.SignalProtocol,
	remoteAddress *protocol.SignalAddress, serializer *serialize.Serializer) *Builder

NewBuilderFromSignal Store constructs a session builder using a SignalProtocol Store.

func (*Builder) Process

func (b *Builder) Process(message *protocol.PreKeySignalMessage) (unsignedPreKeyID *optional.Uint32, err error)

Process builds a new session from a session record and pre key signal message.

func (*Builder) ProcessBundle

func (b *Builder) ProcessBundle(preKey *prekey.Bundle) error

ProcessBundle builds a new session from a PreKeyBundle retrieved from a server.

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

Cipher is the main entry point for Signal Protocol encrypt/decrypt operations. Once a session has been established with session.Builder, this can be used for all encrypt/decrypt operations within that session.

func NewCipher

func NewCipher(builder *Builder, remoteAddress *protocol.SignalAddress) *Cipher

NewCipher constructs a session cipher for encrypt/decrypt operations on a session. In order to use the session cipher, a session must have already been created and stored using session.Builder.

func NewCipherFromSession

func NewCipherFromSession(session *record.Session, remoteAddress *protocol.SignalAddress,
	sessionStore store.Session, preKeyStore store.PreKey,
	preKeyMessageSerializer protocol.PreKeySignalMessageSerializer,
	signalMessageSerializer protocol.SignalMessageSerializer) *Cipher

func (*Cipher) Decrypt

func (d *Cipher) Decrypt(ciphertextMessage *protocol.SignalMessage) ([]byte, error)

Decrypt decrypts the given message using an existing session that is stored in the session store.

func (*Cipher) DecryptAndGetKey

func (d *Cipher) DecryptAndGetKey(ciphertextMessage *protocol.SignalMessage) ([]byte, *message.Keys, error)

DecryptAndGetKey decrypts the given message using an existing session that is stored in the session store and returns the message keys used for encryption.

func (*Cipher) DecryptWithKey

func (d *Cipher) DecryptWithKey(ciphertextMessage *protocol.SignalMessage, key *message.Keys) ([]byte, error)

DecryptWithKey will decrypt the given message using the given symmetric key. This can be used when decrypting messages at a later time if the message key was saved.

func (*Cipher) DecryptWithRecord

func (d *Cipher) DecryptWithRecord(sessionRecord *record.Session, ciphertext *protocol.SignalMessage) ([]byte, *message.Keys, error)

DecryptWithRecord decrypts the given message using the given session record.

func (*Cipher) DecryptWithState

func (d *Cipher) DecryptWithState(sessionState *record.State, ciphertextMessage *protocol.SignalMessage) ([]byte, *message.Keys, error)

DecryptWithState decrypts the given message with the given session state.

func (*Cipher) Encrypt

func (d *Cipher) Encrypt(plaintext []byte) (protocol.CiphertextMessage, error)

Encrypt will take the given message in bytes and return an object that follows the CiphertextMessage interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL