Hi all,
I want to assign the Hex string to the RSA *rsa, how can I do it, many thanks!!
the Hex String is in 1024bit.
for example:
67BD857FB1FDA1AF92FBE2AD43BD82D2
68BC129DBA16176BB4244745831EF09D
46A8182C7546BA6B55A2EC9E86DE036E
91070CD4C1CE1DDFC85F93B3D58EEB1D
B131615A962721E1AD69C866DB88178C
AF2310A44E8942B3020235327334F834
9315E49FFD023F0E2F769AA805D23CEB
1C2716F331FDACB7F0BA68D7EBD70F48
Code:
int main(int argc, char** argv) {
RSA* rsa;
unsigned char* input_string;
unsigned char* encrypt_string;
unsigned char* decrypt_string;
int i;
// check usage
if (argc != 2) {
fprintf(stderr, "%s <plain text>\n", argv[0]);
exit(-1);
}
// set the input string
input_string = (unsigned char*)calloc(strlen(argv[1]) + 1,
sizeof(unsigned char));
if (input_string == NULL) {
fprintf(stderr, "Unable to allocate memory for input_string\n");
exit(-1);
}
strncpy((char*)input_string, argv[1], strlen(argv[1]));
// Generate RSA parameters with 1024 bits (using exponent 3)
rsa = RSA_generate_key(1024, 3, NULL, NULL); // <-----
return 0;
}