session

package
v0.0.0-...-3295f72 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: GPL-3.0 Imports: 16 Imported by: 1

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(sessionRecord *record.Session, 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(remoteAddress *protocol.SignalAddress,
	sessionStore store.Session, preKeyStore store.PreKey, identityKeyStore store.IdentityKey,
	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) DecryptMessage

func (d *Cipher) DecryptMessage(ciphertextMessage *protocol.PreKeySignalMessage) ([]byte, error)

func (*Cipher) DecryptMessageReturnKey

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

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
y or Y : Canonical URL