Documentation ¶
Overview ¶
Package session provides the methods necessary to build sessions
Index ¶
- type Builder
- type Cipher
- func (d *Cipher) Decrypt(ciphertextMessage *protocol.SignalMessage) ([]byte, error)
- func (d *Cipher) DecryptAndGetKey(ciphertextMessage *protocol.SignalMessage) ([]byte, *message.Keys, error)
- func (d *Cipher) DecryptWithKey(ciphertextMessage *protocol.SignalMessage, key *message.Keys) ([]byte, error)
- func (d *Cipher) DecryptWithRecord(sessionRecord *record.Session, ciphertext *protocol.SignalMessage) ([]byte, *message.Keys, error)
- func (d *Cipher) DecryptWithState(sessionState *record.State, ciphertextMessage *protocol.SignalMessage) ([]byte, *message.Keys, error)
- func (d *Cipher) Encrypt(plaintext []byte) (protocol.CiphertextMessage, error)
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.
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.