Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sign_file(char file_name[], RSA* rsa)
- {
- FILE *f, *fsig;
- f = fopen(file_name, "r+"); //file I want to sign
- fsig = fopen("file.sig", "w+"); //hash value of 'file_name'
- calc_sha256(file_name, "file.sig"); //hash value now inside of file.sig, lets now sign that hash
- fclose(fsig);
- int fsize=0;
- fsig = fopen("file.sig", "r+"); //read the hash inside that file
- fseek(fsig, 0L, SEEK_END);
- fsize = ftell(fsig);
- fseek(fsig, 0L, SEEK_SET);
- unsigned char *m = malloc(fsize);
- unsigned char *sigret = malloc(1024); //i guess its 1024 because my ksize if 1024...
- unsigned int *sigret_len = 0;
- sigret_len = sizeof(sigret);
- printf("teste:%d\n", sigret_len);
- BIO *b=NULL;
- RSA *rsaPrivateKey=NULL;
- fread(m, fsize, 1, fsig); //printed *m and it was loaded correctly
- // RSA_sign(NID_sha256, m, strlen(m), sigret, strlen(sigret), rsa);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement