iOS/Objective C: Display key pair generated by OpenSSL
I use openssl for RSA encryption in my iOS application. I have to send the publicKey to a SOAP webservice..I'm already able to generate a key pair, en-/decrypt data, but I wonder if there is a way to display the keys on console? Anybody know?
Open SSL is written in C..So I get this struct..
struct
{
BIGNUM *n; // public modulus
BIGN开发者_如何学GoUM *e; // public exponent
BIGNUM *d; // private exponent
BIGNUM *p; // secret prime factor
BIGNUM *q; // secret prime factor
BIGNUM *dmp1; // d mod (p-1)
BIGNUM *dmq1; // d mod (q-1)
BIGNUM *iqmp; // q^-1 mod p
// ...
};
RSA
At the documentation i found the function RSA_print..But I don't know how to use it right..All my tries failed...:(
Has anybody an idea?
First thing to try is NSLog(@"Here is my object: %@", [someobject description]);
.
description
works, more or less, on nearly all Objective-C classes (even yours). In some cases (the default behavior) it only displays the class name and object address, but in other cases (depending on the whim of the class developer) it rather delightfully formats the innards of the object. It generally works well for NSArray, NSDictionary, NSData, and most other common data types.
You can check this answer for some clues about how to get the key from an RSA struct.
To do you Debugging, either use an NSLog with %i instead of %@ for integers, or set a breakpoint in your callback functions and use the GDB Debugger console and it's mighty po
command. you should be able to do things like po rsa.e
精彩评论