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) IsBackupRunning ¶
IsBackupRunning returns true if the backup has been initialized and is running. Returns false if it has been stopped.
func (*Backup) StopBackup ¶
StopBackup stops the backup processes and deletes the user's password, key, salt, and parameters from storage.
func (*Backup) TriggerBackup ¶
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