Hello, I am unsure how to correctly load a pem file I generate and saved to disk. I want to load the public key, encode a string and load the private key from another pem file to decrypt the string. I did try with LoadPem as no Password is given, but can not get it to work. I am currently generating and writing the pem files as follows (works very well):
asked
RootTag |

Generating a new RSA key makes no sense here. If you already have a private key, then you already have both the private and public key. Most people don't realize that a public key is just a sub-set of the private key. <RSAKeyValue> <Modulus>vqZ07gIBoLEz...JZJgk002xPgSAd</Modulus> <Exponent>AQAB</Exponent> <P>8RUZbaB91v8...VeGowfkHnEl</Q> <DP>oTHmarKg8N7...QKTTCGhQKz/aGg/3haj</DP> <DQ>TOlF8Bhyf...AmJbs9J</DQ> <InverseQ>3awPjKI4b...SOMqN/r7UZ96upx</InverseQ> <D>VieCz8u4YNTtbyue...pKx7Ga3J2HXtQ/d</D> </RSAKeyValue> A public key is just a sub-set of the private key. It contains just the Modulus and Exponent. Therefore, if you already have the private key, by definition you have the matching public key. To get the public key object from the private key object, just call privateKey.GetPublicKey.
answered
chilkat ♦♦ |

I only need to find a way to load my previously stored private key (inside my privateKey.pem file) into my rsa object. I saw the function getRsaPem() which is deprecated and will be removed. Anyway it does not load the correct string as written into the pem file itself. With my public key I was able to use the function getPem() and the Output of the string is exactly what is written inside the publicKey.pem. Isn't there such a function for the Private key as well?
answered
RootTag |