Skip to content

From PIN to encryption

David Sugar edited this page Dec 23, 2023 · 2 revisions

Draft v0.1.0

One can use a PIN to authenticate to a authenticator using either the clientPin or getPinUv...PinWithPermission. This pin can also be used to encrypt sensitive data on a device. This could be especially useful if the authenticator itself does not include a TPM or other mechanism to de-/encrypt data.

The Idea

  1. Separate the authenticator data into Encrypted + Authenticated and Authenticated data
    • the pin counter is just authenticated (TODO: maybe NOT authenticated but non-interactive zero knowledge)
    • the remaining data is encrypted (you could also add a header that contains a encypted master secret, which encrypts the remaining data)
  2. Install a callback that is invoked after decryption the pin during PIN authentication but before the PIN is compared to the PIN stored on the device.
  3. The callback passes the submitted PIN to the underlying system.
  4. The system then derives two secrets from the PIN, a encryption key and and an authentication key.
    • The encryption key is used for en-/decrypting sensitive data
    • The authentication key is used to authenticate data using a Message Authentication Code
  5. The next step is to verify all MACs before continuing. If the verification fails the system has to handle the failure properly.
    • TODO: figure out a way to to decrement the pin counter without having a valid PIN available (i.e. the user submitted the wrong pin). This could be done using a non-interactive zero knowledge mechanism.
    • If the authentication fails, i.e. the PIN is incorrect or the local data has been damaged, decrement the pin counter (non-interactive zero knowledge should allow arithmetic, but even without key????) as one would normally do and return the correct error code (same as if the PIN comparison failed).
  6. If the authentication suceeded, store the pin for a unspecified time period. This time should be greater as the lifetime of the pinUvAuthToken generated during authentication.
  7. Use the encryption key to de-/encrypt the data requested by the authenticator code, e.g. secret key for generating assertions.
Clone this wiki locally