iOS/Objective C:显示 OpenSSL 生成的密钥对
我在 iOS 应用程序中使用 openssl 进行 RSA 加密。 我必须将公钥发送到 SOAP Web 服务。我已经能够生成密钥对、加密/解密数据,但我想知道是否有办法在控制台上显示密钥? 有人知道吗?
Open SSL 是用 C 编写的..所以我得到了这个结构..
struct
{
BIGNUM *n; // public modulus
BIGNUM *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
在 文档 我找到了函数RSA_print..但我不知道如何使用是的..都是我的尝试失败...:(
有人有想法吗?
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
BIGNUM *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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先要尝试的是
NSLog(@"Here is my object: %@", [someobject description]);
。description
或多或少适用于几乎所有 Objective-C 类(甚至是您的类)。在某些情况下(默认行为),它只显示类名和对象地址,但在其他情况下(取决于类开发人员的突发奇想),它相当令人愉快地格式化对象的内部结构。它通常适用于 NSArray、NSDictionary、NSData 和大多数其他常见数据类型。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.您可以查看此答案,了解有关如何从 RSA 结构体获取密钥。
要进行调试,可以使用带有 %i 而不是 %@ 的 NSLog 来表示整数,或者在回调函数中设置断点并使用 GDB 调试器控制台及其强大的
po
命令。你应该能够做类似po rsa.e
的事情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 likepo rsa.e