Documentation ¶
Overview ¶
Package ratchetserver manages a ratcheting server. It takes care of handling fountain creation, pregeneration and persistence.
Index ¶
- Constants
- type DummyFileStore
- type Persistence
- type RatchetServer
- func (rs *RatchetServer) Decrypt(msg []byte) ([]byte, error)
- func (rs *RatchetServer) GenerateKeys()
- func (rs *RatchetServer) GetKeys() []byte
- func (rs *RatchetServer) Persist() error
- func (rs *RatchetServer) SignatureKey() [ed25519.PublicKeySize]byte
- func (rs *RatchetServer) StartService()
- func (rs *RatchetServer) StopService()
- type ServerKeys
- type StoreType
Constants ¶
const ( // StoreTypeServerKeys for ServerKeys. StoreTypeServerKeys = iota // StoreTypeFountain for Fountain data. StoreTypeFountain // StoreTypePregen for pregenerator config. StoreTypePregen // StoreTypeKeyList for the pregenerated key list. StoreTypeKeyList )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DummyFileStore ¶
type DummyFileStore struct {
Path string // filesystem path, directory.
}
DummyFileStore is trivial storage to files.
type Persistence ¶
type Persistence interface { Store(storeType StoreType, data []byte) error // Write data of type StoreType to persistent storage. Load(storeType StoreType) ([]byte, error) // Load data of type StoreType from persistent storage. }
Persistence defines the persistency interface of a ratchet server.
type RatchetServer ¶
type RatchetServer struct {
// contains filtered or unexported fields
}
RatchetServer implements a ratchet server.
func LoadRatchetServer ¶
func LoadRatchetServer(persistence Persistence, rand io.Reader) (*RatchetServer, error)
LoadRatchetServer from persistence layer.
func NewRatchetServer ¶
func NewRatchetServer(persistence Persistence, rand io.Reader, interKeyDuration, pregenInterval int64) (*RatchetServer, error)
NewRatchetServer creates a new RatchetServer. interKeyDuration is the time between ratchet steps. Seconds. pregenInterval is the time for which to pregenerate keys. Seconds.
func (*RatchetServer) Decrypt ¶
func (rs *RatchetServer) Decrypt(msg []byte) ([]byte, error)
Decrypt the message and return it's payload. Only use over TLS. EXPOSED.
func (*RatchetServer) GenerateKeys ¶
func (rs *RatchetServer) GenerateKeys()
GenerateKeys generates the ratchet server keys.
func (*RatchetServer) GetKeys ¶
func (rs *RatchetServer) GetKeys() []byte
GetKeys returns the current pregenerated keys. EXPOSED.
func (*RatchetServer) Persist ¶
func (rs *RatchetServer) Persist() error
Persist writes ratchet server data to persistence layer.
func (*RatchetServer) SignatureKey ¶
func (rs *RatchetServer) SignatureKey() [ed25519.PublicKeySize]byte
SignatureKey returns the key to verify the identity of this server.
func (*RatchetServer) StartService ¶
func (rs *RatchetServer) StartService()
StartService starts the ratchet server goroutine.
func (*RatchetServer) StopService ¶
func (rs *RatchetServer) StopService()
StopService stops the background service.
type ServerKeys ¶
type ServerKeys struct { EncPublicKey [32]byte // curve25519 public key. EncPrivateKey [32]byte // curve25519 private key. SigPublicKey [ed25519.PublicKeySize]byte // ed25519 public key. SigPrivateKey [ed25519.PrivateKeySize]byte // ed25519 private key. }
ServerKeys defines the keys of a ratchet server.
func NewServerKeys ¶
func NewServerKeys(rand io.Reader) (*ServerKeys, error)
NewServerKeys generates new server keys.
func (*ServerKeys) Marshall ¶
func (sk *ServerKeys) Marshall() []byte
Marshall ServerKeys into []byte.
func (*ServerKeys) Unmarshall ¶
func (sk *ServerKeys) Unmarshall(d []byte) (*ServerKeys, error)
Unmarshall byte slice into serverkeys. Returns the filled serverkeys, does not change recipient.