我在客户端/服务器应用程序上使用 openssl 库,我需要与客户端共享公钥。这是数据包的结构:
typedef struct pack {
char op[10];
char message[1024];
int id;
}packet;
这就是提取公钥并将其放入消息字段的方法:
packet *send_pack
RSA *rsa,
const unsigned char *my_public_key;
my_public_key = malloc(1024);
send_pack = (packet*) malloc(sizeof (packet));
rsa = RSA_new();
rsa = RSA_generate_key(1024, 17, NULL, NULL);
i2d_RSAPublicKey(rsa, &my_public_key);
printf("my public key: %X\n", (unsigned int)my_public_key);
strcpy(send_pack->message, my_public_key);
printf("field message of send pack %X", (unsigned int)send_pack->message );
...
但是两个 printf 打印两个相似的值,但不一样(例如第一个 printf 返回 A0B9092 和第二个 A0B944 )。怎么了 ?