6

We have a project with a PWA where we want to implement client sided encryption. We wanted to use Webauthn as a second-factor in combination with passwords. In the background we use a randomly generated key to encrypt/decrypt the database, which is stored symmetrically encrypted with the password on the server. However I am struggling to find a good way to add encryption to this key with webauthn. My tries so far: Using raw JS samples from https://webauthn.guide , however I cannot find a part which is always the same and could be used for symmetric encryption/decryption, even the public key changes when logging in with the same USB token multiple times (???)

Using fido2-lib from npm: I couldn't get the sample to work, since the sample is not well documented and pretty long

Using server-sided authentication like spring webauthn, however I do not want the server to know anything about the client.

Any suggestions how I could implement an encryption with webauthn?

NoNameHD
  • 61
  • 2
  • The Web Authentication API is for, well, authentication, not general encryption. It only proves to a server possession of a previously registered device. That's all. Some of these devices may be capable of symmetric encryption/decryption, but those capabilities are not exposed through the WebAuthn API. – Peter Jan 21 '20 at 11:23
  • Maybe something like this could help? https://w3c.github.io/webauthn/#prf-extension though there may not be support for this across browsers/OSs – Vamos Dec 04 '22 at 18:50

4 Answers4

5

The protocol as it stands does not provide generic public key crypto services as far as I am aware. The best you can do is prove that a user is in possession of the private key related to the public key you hold.

mackie
  • 4,996
  • 1
  • 17
  • 17
1

Years after this question, the hmac-secret extension has arrived.

This extension binds a secret to a Webauthn credential. This secret can be used to decrypt or encrypt data on client side.

Another approach could be the use of the largeBlob to store a secret generated during the creation ceremony. Note that the availability of those extensions depends on the authenticator that is used and may fail.

Spomky-Labs
  • 15,473
  • 5
  • 40
  • 64
  • Are there any working example usage of `hmac-secret` or `largeBlob`? I couldn't get any of these work locally. – Yao Jan 02 '23 at 23:37
  • If it fails, it is mainly due to the lack of support on the authenticator side. And to be honest, I'm not sure extension adoption is the main feature authenticator manufacturers are working on. – Spomky-Labs Jan 08 '23 at 10:06
1

You can learn from the following github repo ,it has many Webauthn out of the box examples (see the tech it supports inside)

Here are some samples I found at github https://github.com/OwnID/samples

In addition,I read about FIDO ,Webauthn and passkeys at passkeys.com

Everything about this cool tech is there

Niv Navick
  • 192
  • 1
  • 4
  • 13
0

There is the prf extension defined for this in the WebAuthn level 3 specification draft of Mai 2023. It it based on the already mentioned hmac-secret. AFAIU, large-blob seems to head towards certificates or similiar.

You could find some JS code snippets at Encrypting Data in the Browser Using WebAuthn

There are some interesting discussion about the subject at:

aanno
  • 638
  • 8
  • 17