Documentation ¶
Index ¶
- func NewSession(sessionID string, expiry uint64) (secret, pubKey string, err error)
- func NewSessionWithRemoteKey(sessionID, secret, remotePubKey string, expiry uint64) error
- func RatchetDecrypt(sessionID, message string) (string, error)
- func RatchetEncrypt(sessionID, message string) (string, error)
- func RatchetSessionSetInfo(sessionID, info string) error
- func Start(dbpath string) error
- func Stop() error
- type BoltDBKeysStorage
- func (*BoltDBKeysStorage) All() (map[doubleratchet.Key]map[uint]doubleratchet.Key, error)
- func (*BoltDBKeysStorage) Count(k doubleratchet.Key) (uint, error)
- func (*BoltDBKeysStorage) DeleteMk(k doubleratchet.Key, msgNum uint) error
- func (*BoltDBKeysStorage) DeleteOldMks(sessionID []byte, deleteUntilSeqKey uint) error
- func (*BoltDBKeysStorage) Get(k doubleratchet.Key, msgNum uint) (mk doubleratchet.Key, ok bool, err error)
- func (*BoltDBKeysStorage) Put(sessionID []byte, k doubleratchet.Key, msgNum uint, mk doubleratchet.Key, ...) error
- func (*BoltDBKeysStorage) TruncateMks(sessionID []byte, maxKeys int) error
- type BoltDBSessionStorage
- type DHPair
- type RatchetSessionDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSession ¶
NewSession is used by the initiator of the encrypted session. This function takes no paramters and returns:
sessionID: A unique string that identified the session for later use secret: A shared secret to be shared with the other side
This function creates a session and stores its state in the SessionStore Following this operation the caller can imediately use Encrypt/Decrypt by providing the sessionID as identifier.
func NewSessionWithRemoteKey ¶
NewSessionWithRemoteKey is used by the recepient side of the encrypted session. This function takes the following parameters:
secret: Shared secret that was agreed with the initiator side remotePubKey The initiator side public key.
This function creates a session and stores its state in the SessionStore Following this operation the caller can imediately use Encrypt/Decrypt by providing the sessionID as identifier.
func RatchetDecrypt ¶
RatchetDecrypt is used to decrypt a message providing a sessionID and a message to decrypt This function loads the session from the session store and use it to decrypt the message. This way the user is free of managing sessions state and only need to provide the sessionID.
func RatchetEncrypt ¶
RatchetEncrypt is used to encrypt a message providing a sessionID and a message to encrypt This function loads the session from the session store and use it to encrypt the message. This way the user is free of managing sessions state and only need to provide the sessionID.
func RatchetSessionSetInfo ¶
RatchetSessionSetInfo checks if a session matches the sessionID and set its details.
Types ¶
type BoltDBKeysStorage ¶
type BoltDBKeysStorage struct{}
BoltDBKeysStorage is a structure that implements the KeysStorge interface. Keys are saved for skipped messages that may come later. It uses boltdb to save the keys.
func (*BoltDBKeysStorage) All ¶
func (*BoltDBKeysStorage) All() (map[doubleratchet.Key]map[uint]doubleratchet.Key, error)
All returns all the keys
func (*BoltDBKeysStorage) Count ¶
func (*BoltDBKeysStorage) Count(k doubleratchet.Key) (uint, error)
Count returns number of message keys stored under the specified key.
func (*BoltDBKeysStorage) DeleteMk ¶
func (*BoltDBKeysStorage) DeleteMk(k doubleratchet.Key, msgNum uint) error
DeleteMk ensures there's no message key under the specified key and msgNum.
func (*BoltDBKeysStorage) DeleteOldMks ¶
func (*BoltDBKeysStorage) DeleteOldMks(sessionID []byte, deleteUntilSeqKey uint) error
DeleteOldMks deletes old message keys for a session.
func (*BoltDBKeysStorage) Get ¶
func (*BoltDBKeysStorage) Get(k doubleratchet.Key, msgNum uint) (mk doubleratchet.Key, ok bool, err error)
Get returns a message key by the given key and message number.
func (*BoltDBKeysStorage) Put ¶
func (*BoltDBKeysStorage) Put(sessionID []byte, k doubleratchet.Key, msgNum uint, mk doubleratchet.Key, keySeqNum uint) error
Put saves the given mk under the specified key and msgNum.
func (*BoltDBKeysStorage) TruncateMks ¶
func (*BoltDBKeysStorage) TruncateMks(sessionID []byte, maxKeys int) error
TruncateMks truncates the number of keys to maxKeys. We have short live sessions so currently we don't implemented that
type BoltDBSessionStorage ¶
type BoltDBSessionStorage struct{}
BoltDBSessionStorage is a structure that implements the SessionStore interface. It uses boltdb to save sessions
func (*BoltDBSessionStorage) Load ¶
func (s *BoltDBSessionStorage) Load(id []byte) (*doubleratchet.State, error)
Load session by id
func (*BoltDBSessionStorage) Save ¶
func (s *BoltDBSessionStorage) Save(id []byte, state *doubleratchet.State) error
Save the session to the session store
type DHPair ¶
type DHPair struct {
// contains filtered or unexported fields
}
DHPair is a key pair structure that implements the doubleratchet.DHPair interface
func (DHPair) PrivateKey ¶
func (p DHPair) PrivateKey() doubleratchet.Key
PrivateKey is part of the doubleratchets.DHPair interaface
func (DHPair) PublicKey ¶
func (p DHPair) PublicKey() doubleratchet.Key
PublicKey is part of the doubleratchets.DHPair interaface
type RatchetSessionDetails ¶
RatchetSessionDetails represents the info of existing session
func RatchetSessionInfo ¶
func RatchetSessionInfo(sessionID string) *RatchetSessionDetails
RatchetSessionInfo checks if a session matches the sessionID and returns its details.