uplink mobile: add passphrase generation helpers (#2428)
Change-Id: I59229e5221c42919473bc4e14de7e6d186d3832c
This commit is contained in:
parent
8b07df37f5
commit
f275f2a0f9
@ -29,6 +29,12 @@ func (e *EncryptionAccess) SetDefaultKey(keyData []byte) error {
|
|||||||
return nil
|
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
|
// ParseEncryptionAccess parses the base58 encoded encryption context data and
|
||||||
// returns the resulting context.
|
// returns the resulting context.
|
||||||
func ParseEncryptionAccess(b58data string) (*EncryptionAccess, error) {
|
func ParseEncryptionAccess(b58data string) (*EncryptionAccess, error) {
|
||||||
|
@ -172,3 +172,15 @@ func safeError(err error) error {
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("%v", err.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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user