나는 다음과 같은 코드가 있습니다위치를 기록하는 동안 액세스 위반이
이#include <openssl/bn.h>
#include <openssl/rsa.h>
unsigned char* key;
RSA* rsa = RSA_new();
rsa = RSA_generate_key(1024,65537,NULL,NULL);
//init pubkey
key[BN_num_bytes(rsa->n)] = '\0';
BN_bn2bin(rsa->n, key);
printf("RSA Pub: %s\n", key);
RSA_free(rsa);
rsa = NULL;
디버거 내게 말하고있다
내가 선
key[BN_num_bytes(rsa->n)] = '\0';
에 문제 "액세스 위반 쓰기 위치"를 가지고 내가 주석 경우를 그 줄이 바로 아래로 이동
BN_bn2bin(rsa->n, key);
이 문제를 해결하는 방법에 대한 제안 사항은 다음과 같습니다. 좋아.
키의 포인터 당신이 그것에 어떤 메모리를 할당 하시겠습니까? 그렇다면 key = new char [100]; // some buffer – JonH