0

I want to encrypt/sign data so other apps must use a "read" key to get the data from a encoded file. So it's possible to read the data but it's not possible to manipulate the data because the "write" key is not available.


Usecase:

Administrators can create a configuration file and deploy it. A backend makes use of this file. It should not be possible to manipulate the deployed configuration file because attackers don't know the "write" key but it's fine they could read the configuration and create their own one with their own "write" and "read" key.


I thought about using the WebCrypto API to generate a public + private key using crypto.subtle.generateKey() and sign the configuration with the private key via crypto.subtle.sign().

Currently I would deploy

  • the public key as a PEM string
  • the signature ( to verify the configuration )
  • the base64 encoded configuration

but I think it would be better to "embed" the configuration into the signature so people can only get it by using the public key. This doesn't seem to be possible so I thought about using crypto.subtle.encrypt() and crypto.subtle.decrypt() instead but based on the question What is the difference between encrypting and signing in asymmetric encryption? this feels "wrong" because I want to ship the public key, not the private one.

How would you "encode"/"encrypt"/"sign" data and deploy it with a readonly-key?

( I think this is language/framework independent )

Maybe I could sign the data with a JWT using the package jose so the backend can verify the token using the public key. But it would be awesome if the WebCrypto API already provides some "native" solutions.

baitendbidz
  • 187
  • 3
  • 19

0 Answers0