14
votes

I am looking for a JS crypto lib (similar to, say, OpenSSL's libcrypto) that facilitates digital signing of data in the browser.
I want to sign form form data on the client side using a private key (RSA, PKI certificates or similar).

EXAMPLE

  1. Form data loads in browser
  2. User A reviews data and signs it => the signature is created in the browser using the js lib and the private key signature=RSA_encrypt(A_private_key, hash(data))
  3. The form data and signature is sent to the server and stored

  4. Another user (B) can check the validity of the signature by comparing hash(data) with RSA_decrypt(A_public_key, signature) If someone alters the form data the signature will no longer be valid.

EDIT

https://developer.mozilla.org/en/javascript_crypto
http://www.hanewin.net/encrypt
http://tomas.styblo.name/cryptoapplet/

VIA APPLETS
Best way to sign data in web form with user certificate
! => http://www.nakov.com/research/documents-signing/digital-document-signing-in-java-based-web-applications/
http://www.nakov.com/research/documents-signing/
http://www.developer.com/java/other/article.php/10936_3587361_1
http://www.developer.com/java/web/article.php/3083161
http://blogs.nologin.es/rickyepoderi/index.php?/archives/12-Signature-Applet.html

RELATED
http://ccff02.minfin.fgov.be/CCFF_Authentication/views/login/signature/signatureHelp.html
http://msdn.microsoft.com/en-us/library/cc778518%28VS.85%29.aspx

2
Is there a reason that HTTPS is not sufficient for this? What are you trying to accomplish?cdhowie
HTTPS can't sign data, think of a form as some sort of document that needs to be signed, if the form data is changed, the signature is no longer validclyfe
Right, but who does the private key belong to? The user, or your service? Should the user have access to the private key? (Because they do...) Why can you not sign the data after your service receives it?cdhowie
Signing != encryption... signing does NOT solve the same problem as HTTPS.Mark
@cdhowie the PK belongs to user A (the one that does the signing) and is probably inside a USB token. I need to do the signing on the client, as 1. I don't like the idea of sending the key over HTTP(S) and, nor having it stored in the server 2. Some tokens (all?) don't allow you to read the PK as a security measure, requiring you to send the data in the token and then get it back encrypted.clyfe

2 Answers