I'm new to cryptography, and I was making an experiment a few minutes ago, but I want to have some deeper knowledge about RSA public and private keys.

I have a set of keys

One begins with


and another with

-----END PUBLIC KEY-----

I've parsed them using Java and I can make use of them, as RSA private and public keys respectively.

But the question I have is....

Are there some checksum mechanisms built into RSA keys ?

I ask this because, I'd like to know what happens if, by error or intentional, one or more characters from the encoded PEM are modified. Does this breaks the key ? Or changes the key internally, without breaking it ?


No, there is no checksum built-in to the RSA keys per se. There is no need for that.

Does this breaks the key ? Or changes the key internally, without breaking it ?

[EDIT] It was rightfully pointed out to me that at least one of the statements I typed (in haste) was plain wrong. Now that the answer has served its initial purpose, I've removed my badly worded and therefore wrong statements and just duplicating here the link to a much better explanation of things (which I really liked): Why does my SSH private key still work after changing some bytes in the file?

| improve this answer | |
  • $\begingroup$ Yes! I was just doing this. Dumping both private and public key info with openssl, and comparing modulus and exponent (I've read that if those two elements match, then the keys match each other). Just one doubt remaining. I just DID change a single character on the RSA PRIVATE KEY section, and I did obtained a private key (with different values). I'm guessing this key, even "corrupted", is still valid for signing? $\endgroup$ – Cristian Meneses Jun 24 '16 at 7:21
  • $\begingroup$ Check the question I linked above, which deals precisely with the scenario you are talking about. $\endgroup$ – cygnusv Jun 24 '16 at 7:22
  • $\begingroup$ @cygnusv You are right! Thanks so much for the link! $\endgroup$ – Cristian Meneses Jun 24 '16 at 7:26
  • $\begingroup$ Agreed. Edited. $\endgroup$ – tum_ Jun 24 '16 at 10:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.