利用openssl实现RSA密钥生成
#include <openssl/rsa.h>
#include <openssl/applink.c>
#include <stdio.h>
int main() {
RSA *r;
int bits=512,ret;
unsigned long e=RSA_3;
BIGNUM *bne;
r = RSA_generate_key(bits, e, NULL, NULL);
RSA_print_fp(stdout, r, 11);
RSA_free(r);
bne = BN_new();
ret = BN_set_word(bne, e);
r = RSA_new();
ret = RSA_generate_key_ex(r, bits, bne, NULL);
if (ret != 1) {
printf("RSA_generate_key_ex err!\n");
return -1;
}
RSA_free(r);
return 0;
}
本文介绍了一种使用openssl库生成RSA密钥的方法。通过C语言编程实现了密钥的生成,并详细展示了如何设置密钥长度及公钥指数等参数。
2881

被折叠的 条评论
为什么被折叠?



