I have a private 2048 key that I can use to decrypt 2056 bits of encrypted data. I get out 128 bits unencrypted data. I have verified that this data is correct. (I dont know the original encrypt command).
openssl rsautl -decrypt -inkey private.pem -in data.2056bits.enc.bin -out data.128bits.dec.bin
I guess that the shrinking from 2056 bits input to 128 bits output is done using some kind of padding.
What I would like to do now is to reverse the decryption. Encrypting data.128bits.dec.bin i would like to end up with the same data.2056bits.enc.bin that I started with. I thought that the below lines would do this:
opendssl rsa -in private.pem -pubout > pub.pem
openssl rsautl -encrypt -inkey pub.pem -pubin -in data.128bits.dec.bin -out data.2056bits.enc.bin
However data.2056bits.enc.bin is different than the one I started with.
It is however a valid encryption. I can do a
openssl rsautl -decrypt -inkey private.pem -in data.2056bits.enc.bin -out data.128bits.dec.bin
again and end up with the same data.128bits.dec.bin.
What am I dont wrong? Can there be 2 different data.2056bits.enc.bin s that yield the same data.128bits.dec.bin ?