Add trustKey to password update and implement getTrustKey function for ChaCha20 protocol
This commit is contained in:
@@ -64,6 +64,7 @@ function Security.updatePassword(password)
|
||||
hash = derived:toHex(),
|
||||
salt = salt,
|
||||
iter = PBKDF2_ITERATIONS,
|
||||
trustKey = SHA.compute(password),
|
||||
}
|
||||
Config.update('os', config)
|
||||
end
|
||||
@@ -72,4 +73,15 @@ function Security.getPassword()
|
||||
return Config.load('os').password
|
||||
end
|
||||
|
||||
-- Returns the trust key for ChaCha20-based trust protocol.
|
||||
-- Compatible with both new (PBKDF2 table) and legacy (SHA-256 string) formats.
|
||||
function Security.getTrustKey()
|
||||
local stored = Security.getPassword()
|
||||
if type(stored) == 'table' then
|
||||
return stored.trustKey
|
||||
end
|
||||
-- Legacy: the stored string IS the SHA-256 hex
|
||||
return stored
|
||||
end
|
||||
|
||||
return Security
|
||||
|
||||
Reference in New Issue
Block a user