Documentation ¶
Index ¶
- Constants
- func Decrypt(blob, key []byte) ([]byte, error)
- func DeriveKey(password string, salt []byte, params Params) []byte
- func Encrypt(rand csprng.Source, plaintext, key []byte) ([]byte, error)
- func MakeSalt(csprng csprng.Source) ([]byte, error)
- type Backup
- type Contacts
- type Params
- type ReceptionIdentity
- type TransmissionIdentity
- type UserDiscoveryRegistration
Constants ¶
View Source
const ( // KeyLen is the length of the backup key generated KeyLen = chacha20poly1305.KeySize // SaltLen is the required length of the salt. Recommended being set to 16 // bytes here: // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-argon2-04#section-3.1 SaltLen = 16 )
View Source
const (
// ParamsLen is the length of the marshalled Params object.
ParamsLen = paramTimeLen + paramMemoryLen + paramThreadsLen
)
Length of fields in the Params object.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backup ¶
type Backup struct { RegistrationTimestamp int64 `json:"registrationTimestamp"` RegistrationCode string `json:"registrationCode"` JSONParams string `json:"jsonParams"` TransmissionIdentity TransmissionIdentity `json:"transmissionIdentity"` ReceptionIdentity ReceptionIdentity `json:"receptionIdentity"` UserDiscoveryRegistration UserDiscoveryRegistration `json:"userDiscoveryRegistration"` Contacts Contacts `json:"contacts"` }
func (*Backup) Decrypt ¶
Decrypt decrypts the encrypted serialized backup. Returns an error for invalid version or invalid tag.
func (*Backup) Encrypt ¶
Encrypt returns the encrypted serialized backup with the format for account backups:
"XXACCTBAK" | [VERSION as 1 byte] | [salt and params] | [DATA]
The key passed in must be derived via DeriveKey and the salt must be the same used to derive the key. Key derivation happens outside the encryption because it is slow, so that the key can be stored and reused.
type Params ¶
type Params struct { Time uint32 `json:"time"` // Number of passes over the memory Memory uint32 `json:"memory"` // Amount of memory used in KiB Threads uint8 `json:"threads"` // Number of threads used }
Params contains the cost parameters used by Argon2.
func DefaultParams ¶
func DefaultParams() Params
DefaultParams returns the recommended general purposes parameters.
type ReceptionIdentity ¶
type ReceptionIdentity struct { RSASigningPrivateKey *rsa.PrivateKey `json:"rsaSigningPrivateKey"` RegistrarSignature []byte `json:"registrarSignature"` Salt []byte `json:"salt"` ComputedID *id.ID `json:"computedID"` DHPrivateKey *cyclic.Int `json:"dhPrivateKey"` DHPublicKey *cyclic.Int `json:"dhPublicKey"` }
type TransmissionIdentity ¶
Click to show internal directories.
Click to hide internal directories.