GMP RSA implementation
I'm trying to implement the RSA algorithm (just for fun, with no padding). My code works fine encrypting up to 83 characters but after this the decryption output is only gibberish and (no matter the size of the input) the output is always 83 bits. Anyone have any idea what's going on here?
Basic encryption procedure:
1.) Take plaintext and concatenate each hex ascii value to form an integer representation of the text. Each hex value will be two digits.
2.) Encrypt this number.
1.) Take ciphertext and decrypt.
2.) Take decrypted number, convert to hex and split up into pairs of digits (i.e. one hex value) and convert to ascii character.
Any help most appreciated!
Could it have something to do with the size of your key? Since the calculation is mod PKn1 it obviously can't properly encode a message whose value is greater than PKn1.
Ah, of course.
Originally Posted by oogabooga
Do you have any ideas about the best way of splitting up the message into chunks <n ?
A typical approach is to use RSA to encrypt a key for symmetric encryption, then the splitting of the plaintext is done as per the normal methods of block (or stream) encryption, e.g., by using an IV with CBC.