Closed sosthene-nitrokey closed 1 year ago
How does this key lead to an actual symmetric key for data-encryption?
The resulting (symmetric, derived, "key derivation") key A
is then used to encryption the actual data-encryption-key (B
), which was generated randomly? We need this second level to avoid re-encrypting the entire (encrypted)-data-set, if the PIN is changed?
Is this correct ?
@sosthene-nitrokey
The verification can be useful to go faster when we don't wan't to derive any keys, but I'm thinking we don't gain that much unless we also go without the application_key as a pepper for verification.
client_id
isn't the pepper. The application key (output of HKDF(exctract, info: client_id)
is the pepper)
The key derived from the PIN should indeed be used to wrap the actual key that is returned to allow changing the PIN without changing the key.
I updated the issue to reflect that.
What okm
and hardware_ikm
stands for?
I shouldn't have called it okm
i renamed it to exctract
aka the result of the HKDF-EXCTRACT step. hardware_ikm
stands for the initial key material from the hardware registers (or from wherever the runner gets them).
Implemented in https://github.com/trussed-dev/trussed-auth/pull/10.
The idea is for every app to be able to derive a unique symmetric key from validating the password.
Here is the layout:
When the backend is created, the runner can pass it a
hardware_ikm: Bytes<N>
. The backend loads from storage or generates and stores a random salt. It then runsHKDF-EXTRACT(salt, hardware_ikm)
. It then derives anapplication_key
for each client using the client ID as theinfo
parameter:HKDF-EXPAND(exctract, info: client_id)
. All of this is performed lazily.The
application_key
is added to the salt when hashing pins as a form of pepper. The hashing for validation would be done withHMAC(application_key, "verification" || SALT || PIN)
[^1]. If the verification is successful, a key is derived usingpin_kek = HMAC(application_key, "key derivation" || SALT || PIN)
.pin_kek
is then used to unwrap a fully random 32 byte symmetric key that is then returned to the user.What key kind should be the derived key? We can't directly create a ChaCha key because we would also need a nonce. Should we use AES-CBC, for which nonce-reuse is not as catastrophic, or should we add a new mechanism like XChaCha that could b used with a random nonce?
[^1]:
||
means concatenation