1

Here is context:

I am using PGP to encrypt messages in a chat web app. After going through some articles, I get brief idea how PGP works and here is how I am doing it with openPGPJs :

  • Client(web browser) generate the public/private key-pairs and send public key to server to store it.
  • Sender use receiver's public key to encrypt data and send it.
  • Receiver use their own private key to decrypt the message.

As a chat app I need to store all messages and decrypt them when user wants to see old message. decryption of messages need the private key. here the client is web browser which neither can store the private keys for long nor can keep them safe. so I decided to store the private key on web server. Now client(web browser) asks server for the private key whenever decryption of message needed.

Considering PGP an End to End protocol, storing private key on server is vulnerable. my question is:

  • How PGP encryption works for web based applications where client is not able to keep private key safe and confidential?

  • Is it Okay to store private key on server?

  • Is there any better way to do this?

Thanks for any suggestions.

  • 2
    What's your threat model? – a CVn Aug 12 '17 at 20:22
  • Question is only coincidentally about security. If you are not aware of localstorage, and need to ask if storing the private key on the server is safe, then I would be rather suspect of the overall security of the application ( developer.mozilla.org/en/docs/Web/API/Window/localStorage ) – symcbean Aug 12 '17 at 22:33
  • 1
    @symcbean local storage get cleared when we clear browser data. so local storage is not a solution to store keys permanently. – Suraj Aug 13 '17 at 5:56
  • 1
    @suraj, and files are cleared when you delete them. What is your point? – symcbean Aug 13 '17 at 15:06
0

I've been working on something similar for signing messages. The short answer is: it's only supported in Chrome, but the future is not bright.

You can do it using the Filesystem API. However, the problem is: this is not getting standardized by the w3c, support for it in any browsers other than chrome doesn't work, and, it's wholly possible that a rogue script could access the filesystem API and steal your key.

I ultimately abandoned the project. You would be wise to reconsider what you're working on. CryptoCat already solved the secure browser chat problem...

EDIT:

Seems crypto cat was re-written in 2016 and now has PC based versions. There is a crypto-cat legacy repo that appears to have the original CryptoCat code.

  • I checked the crypto-cat legacy repo, seems they are using OTR protocol. I have do it with PGP. I am wondering its a common use case but not find any solution. – Suraj Aug 13 '17 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.