backup

package
v4.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmixFromBackup

func NewCmixFromBackup(ndfJSON, storageDir, backupPassphrase string,
	sessionPassword []byte, backupFileContents []byte) ([]*id.ID,
	string, error)

NewCmixFromBackup initializes a new e2e storage from an encrypted backup. The backup is decrypted using the backupPassphrase. On a successful client creation, the function will return a JSON encoded list of the E2E partners contained in the backup and a json-encoded string containing parameters stored in the backup

Types

type Backup

type Backup struct {
	// contains filtered or unexported fields
}

Backup stores the user's key and backup callback used to encrypt and transmit the backup data.

func InitializeBackup

func InitializeBackup(backupPassphrase string, updateBackupCb UpdateBackupFn,
	container *xxdk.Container, e2e E2e, session Session, ud UserDiscovery,
	kv versioned.KV, rng *fastRNG.StreamGenerator) (*Backup, error)

InitializeBackup creates a new Backup object with the callback to return backups when triggered. On initialization, 32-bit key is derived from the user's password via Argon2 and a 16-bit salt is generated. Both are saved to storage along with the parameters used in Argon2 to be used when encrypting new backups. Call this to turn on backups for the first time or to replace the user's password.

func ResumeBackup

func ResumeBackup(updateBackupCb UpdateBackupFn, container *xxdk.Container,
	e2e E2e, session Session, ud UserDiscovery, kv versioned.KV,
	rng *fastRNG.StreamGenerator) (*Backup, error)

ResumeBackup resumes a backup by restoring the Backup object and registering a new callback. Call this to resume backups that have already been initialized. Returns an error if backups have not already been initialized.

func (*Backup) AddJson

func (b *Backup) AddJson(newJson string)

func (*Backup) IsBackupRunning

func (b *Backup) IsBackupRunning() bool

IsBackupRunning returns true if the backup has been initialized and is running. Returns false if it has been stopped.

func (*Backup) StopBackup

func (b *Backup) StopBackup() error

StopBackup stops the backup processes and deletes the user's password, key, salt, and parameters from storage.

func (*Backup) TriggerBackup

func (b *Backup) TriggerBackup(reason string)

TriggerBackup assembles the backup and calls it on the registered backup callback. Does nothing if no encryption key or backup callback is registered. The passed in reason will be printed to the log when the backup is sent. It should be in the past tense. For example, if a contact is deleted, the reason can be "contact deleted" and the log will show:

Triggering backup: contact deleted

type E2e

type E2e interface {
	GetAllPartnerIDs() []*id.ID
	GetHistoricalDHPubkey() *cyclic.Int
	GetHistoricalDHPrivkey() *cyclic.Int
}

E2e is a subset of functions from the interface e2e.Handler.

type Session

type Session interface {
	GetRegCode() (string, error)
	GetTransmissionID() *id.ID
	GetTransmissionSalt() []byte
	GetReceptionID() *id.ID
	GetReceptionSalt() []byte
	GetReceptionRSA() rsa.PrivateKey
	GetTransmissionRSA() rsa.PrivateKey
	GetTransmissionRegistrationValidationSignature() []byte
	GetReceptionRegistrationValidationSignature() []byte
	GetRegistrationTimestamp() time.Time
}

Session is a subset of functions from the interface storage.Session.

type UpdateBackupFn

type UpdateBackupFn func(encryptedBackup []byte)

UpdateBackupFn is the callback that encrypted backup data is returned on

type UserDiscovery

type UserDiscovery interface {
	GetFacts() fact.FactList
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL