I have written a raw (textbook) RSA implementation (just for fun) and I wonder is there an easy way to make it secure enough so it can be used in real life (without implementing OAEP+ and RSASSA-PSS)? Are there any simple algorithms for padding and generating secure digital signatures?
Actually, RSASSA-PKCS1-v1_5 signature padding is quite simple, and has no known weaknesses (the similarly named RSAES-PKCS1-v1_5 padding is broken for encryption unless implemented in a very very careful way; don't use that).
The padding format is:
00 01 FF FF FF ... FF FF 00 <DER of Hash Type> <Hash>
where DER of Hash Type
is a byte string that depends on the type of hash you used, and Hash
is the output of the hash function. For SHA-256, the DER is the byte string:
30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20
So, you take your hash, prepend it with a fixed string, and you're done.
If you want to make things a bit simpler, you could omit the DER of Hash Type
(which would mean that you're not precisely PKCS #1.5, however it does not introduce any known weaknesses.