0
$\begingroup$

I need to encrypt and digital sign an html form that contains sensitive data. The legal need is that the user can't deny that he filled the form and the data sent was not altered.

I was thinking to generate server side RSA public key and private key, and I will store the public key in the database with a technical id.

Then I send the private key to the html page (ajax call or at load). The Javascript code will encrypt the form before sending it. The Javascript will send the encrypted data and the public key id so i can retrieve it server side and can decrypt it.

Is it the good approach, or do you see any security issues?

$\endgroup$
  • 1
    $\begingroup$ I could be wrong, but this question might be better off at Information Security. $\endgroup$ – Glorfindel Feb 1 '18 at 9:55
  • $\begingroup$ You would need to sign the form, you cannot encrypt with a private key. But even if you would transport the private key over a trusted connection, how would you prove that you didn't sign the form? What you need is a way to create legally valid signatures for non-repudiation. That's not an easy thing to do; it certainly cannot be handled by a browser alone. Anyway, now you know the terms, I propose you google them and start learning. $\endgroup$ – Maarten Bodewes Feb 1 '18 at 16:22
  • $\begingroup$ I answered the question as is, but it is a good example of the XY problem. You are asking us to validate a solution you came up with instead of describing your problem and let us help you come up with the best solution. $\endgroup$ – mikeazo Feb 2 '18 at 13:53
  • $\begingroup$ can u stop telling me what i have to say, i gave the problem i proposed a solution and asked for review, if you don't like it deal with it and dont make those unconstructive answers. My god wha'ts your problem today ? $\endgroup$ – riadh gomri Feb 2 '18 at 16:44
  • 1
    $\begingroup$ @riadhgomri, calm down. I'm trying to help you. Yes, you gave the problem and proposed a solution. My answer tells why your solution is not viable. My comment above gives a suggestion for how you may be able to get better help. If you choose not to take the advice, that is your choice, but you don't need to get bent out of shape about it. Be nice. $\endgroup$ – mikeazo Feb 2 '18 at 20:50
2
$\begingroup$

Is it the good approach?

No, it is not. You say you want to do this for legal reasons. If your server knows the private key (as it does in this case), the server or anyone with access to the server will also have access to the private key and can therefore sign any form they want. Therefore, your proposal does not meet your goals.

$\endgroup$

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.