- 论坛徽章:
- 0
|
sorry,不知道该不该在这个板块问,没找到加密相关的板块了。
在做一个加密通信的小东西,用rsa加密,现在碰到一个问题。
在linux下,c代码
rsa = RSA_generate_key(1024, RSA_F4, NULL, NULL);
FILE *pemfile = fopen("/webwall/pemprikey", "w+") ;
int pemres = PEM_write_RSAPrivateKey(pemfile, rsa,0, 0, 0, 0, 0, 0) ;
fclose(pemfile) ;
。。。。。这样保存的pem格式的文件貌似是对的。
。。。。。接着
FILE *pemfile = fopen("/webwall/pempubkey", "w+") ;
int pemres = PEM_write_RSAPublicKey(pemfile, rsa) ;
fprintf(stderr, "write file return %d\n", pemres);
fclose(pemfile) ;
。。。。这样保存的pem格式的文件就有些问题了。
生成了两个密钥文件
我用openssl命令,通过上面生成的priv密钥文件再生成一个pubkey文件,内容和刚才代码生成的文件不一样,好像是短一些。
刚才看到论坛中有过这样一个问题了,但是最后也没有个结论,求赐教 |
|