views:

45

answers:

2

Or concrete - I am using this javascript RSA library for the client side code of my experimental project... I would like to be able to sign and verify messages (-> encrypt with private and decrypt with public key)

Is there a way to alter the key data in a way that the algorithms for en/decrypting do it with the "reverse" key? I tried to swap e and d (because that is what it seemed to me from wikipedia the difference is) - for "signing" it worked (but I assume it was undecryptable garbage)... for "verifying" I tried to calculate d mod (p-1), d mod (q-1) and 1/q mod p with e instead of e for usage of the decryption algorithm for verification... but is it really what I think it is? If it was, I suppose it wouldn't have to be stored in the private key, because it would be very easy to calculate, having d, p and q...?

The point: If there is a way to feed a modified private key into the encryption algorighm for signing and the same for the counterpart - how do I do this? What modifications have to be done to the keys?

+1  A: 

Look here: http://www.di-mgt.com.au/rsa_alg.html#signing

z5h
thats not quite a specific answer to my question, but thanks, I'll read through it and try to make something with it...
apirogov
Ok I think I understood the difference... but still: I need my implementation to be OpenSSL compatible - can you tell me how openssl is doing it? I mean, what digest does it use? etc...
apirogov
oh damn I got it... the PKCS signing algorithm! ok thanks again :)
apirogov
A: 

You can't.

Encryption and signatures have different paddings. Sometimes you see suggestions to encrypt the hash of your message to get a signature. However, this suggestion is bincorrect. It leads to something that is incompatible with correct signature schemes. Moreover, your implementation may be actually be insecure. RSA paddings have long history of flaws. Even standardization commitees don't always get it right.

uuu
Using the information from the link above I successfully implemented an openssl compatible signature... and I think openssl is quite secure? ...
apirogov