Versions in this module Expand all Collapse all v1 v1.0.0 Nov 2, 2018 Changes in this version + func WithCrypto(c Crypto) option + func WithKeysStorage(ks KeysStorage) option + func WithMaxKeep(n int) option + func WithMaxMessageKeysPerSession(n int) option + func WithMaxSkip(n int) option + type Crypto interface + DH func(dhPair DHPair, dhPub Key) Key + Decrypt func(mk Key, ciphertext, ad []byte) (plaintext []byte, err error) + Encrypt func(mk Key, plaintext, ad []byte) (authCiphertext []byte) + GenerateDH func() (DHPair, error) + type DHPair interface + PrivateKey func() Key + PublicKey func() Key + type DefaultCrypto struct + func (c DefaultCrypto) DH(dhPair DHPair, dhPub Key) Key + func (c DefaultCrypto) Decrypt(mk Key, authCiphertext, ad []byte) ([]byte, error) + func (c DefaultCrypto) Encrypt(mk Key, plaintext, ad []byte) []byte + func (c DefaultCrypto) GenerateDH() (DHPair, error) + func (c DefaultCrypto) KdfCK(ck Key) (chainKey Key, msgKey Key) + func (c DefaultCrypto) KdfRK(rk, dhOut Key) (rootKey, chainKey, headerKey Key) + type InMemoryKey struct + type KDFer interface + KdfCK func(ck Key) (chainKey, msgKey Key) + KdfRK func(rk, dhOut Key) (rootKey, chainKey, newHeaderKey Key) + type Key [32]byte + func (k Key) String() string + type KeysStorage interface + All func() (map[Key]map[uint]Key, error) + Count func(k Key) (uint, error) + DeleteMk func(k Key, msgNum uint) error + DeleteOldMks func(sessionID []byte, deleteUntilSeqKey uint) error + Get func(k Key, msgNum uint) (mk Key, ok bool, err error) + Put func(sessionID []byte, k Key, msgNum uint, mk Key, keySeqNum uint) error + TruncateMks func(sessionID []byte, maxKeys int) error + type KeysStorageInMemory struct + func (s *KeysStorageInMemory) All() (map[Key]map[uint]Key, error) + func (s *KeysStorageInMemory) Count(pubKey Key) (uint, error) + func (s *KeysStorageInMemory) DeleteMk(pubKey Key, msgNum uint) error + func (s *KeysStorageInMemory) DeleteOldMks(sessionID []byte, deleteUntilSeqKey uint) error + func (s *KeysStorageInMemory) Get(pubKey Key, msgNum uint) (Key, bool, error) + func (s *KeysStorageInMemory) Put(sessionID []byte, pubKey Key, msgNum uint, mk Key, seqNum uint) error + func (s *KeysStorageInMemory) TruncateMks(sessionID []byte, maxKeys int) error + type Message struct + Ciphertext []byte + Header MessageHeader + type MessageEncHeader []byte + func (mh MessageEncHeader) Decode() (MessageHeader, error) + type MessageHE struct + Ciphertext []byte + Header []byte + type MessageHeader struct + DH Key + N uint32 + PN uint32 + func (mh MessageHeader) Encode() MessageEncHeader + type Session interface + RatchetDecrypt func(m Message, associatedData []byte) ([]byte, error) + RatchetEncrypt func(plaintext, associatedData []byte) (Message, error) + func Load(id []byte, store SessionStorage, opts ...option) (Session, error) + func New(id []byte, sharedKey Key, keyPair DHPair, storage SessionStorage, ...) (Session, error) + func NewWithRemoteKey(id []byte, sharedKey, remoteKey Key, storage SessionStorage, opts ...option) (Session, error) + type SessionHE interface + RatchetDecrypt func(m MessageHE, associatedData []byte) ([]byte, error) + RatchetEncrypt func(plaintext, associatedData []byte) MessageHE + func NewHE(sharedKey, sharedHka, sharedNhkb Key, keyPair DHPair, opts ...option) (SessionHE, error) + func NewHEWithRemoteKey(sharedKey, sharedHka, sharedNhkb, remoteKey Key, opts ...option) (SessionHE, error) + type SessionStorage interface + Load func(id []byte) (*State, error) + Save func(id []byte, state *State) error + type State struct + Crypto Crypto + DHr Key + DHs DHPair + HKr Key + HKs Key + KeysCount uint + MaxKeep uint + MaxMessageKeysPerSession int + MaxSkip uint + MkSkipped KeysStorage + NHKr Key + NHKs Key + PN uint32 + RecvCh kdfChain + RootCh kdfRootChain + SendCh kdfChain + Step uint + func DefaultState(sharedKey Key) State Incompatible versions in this module v3.0.0+incompatible Oct 31, 2019 v2.0.0+incompatible Feb 14, 2019