uplink mobile: add passphrase generation helpers (#2428)

Change-Id: I59229e5221c42919473bc4e14de7e6d186d3832c
This commit is contained in:
JT Olio 2019-07-05 04:14:34 -05:00 committed by Kaloyan Raev
parent 8b07df37f5
commit f275f2a0f9
2 changed files with 18 additions and 0 deletions

View File

@ -29,6 +29,12 @@ func (e *EncryptionAccess) SetDefaultKey(keyData []byte) error {
return nil
}
// Serialize returns a base58-serialized encryption access for use with later
// parsing.
func (e *EncryptionAccess) Serialize() (b58data string, err error) {
return e.lib.Serialize()
}
// ParseEncryptionAccess parses the base58 encoded encryption context data and
// returns the resulting context.
func ParseEncryptionAccess(b58data string) (*EncryptionAccess, error) {

View File

@ -172,3 +172,15 @@ func safeError(err error) error {
}
return fmt.Errorf("%v", err.Error())
}
// SaltedKeyFromPassphrase returns a key generated from the given passphrase using a stable,
// project-specific salt
func (project *Project) SaltedKeyFromPassphrase(passphrase string) (keyData []byte, err error) {
scope := project.scope.child()
key, err := project.lib.SaltedKeyFromPassphrase(scope.ctx, passphrase)
if err != nil {
return nil, err
}
return key[:], nil
}