Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. void sign_file(char file_name[], RSA* rsa)
  2. {
  3.   FILE *f, *fsig;
  4.  
  5.   f = fopen(file_name, "r+"); //file I want to sign
  6.   fsig = fopen("file.sig", "w+"); //hash value of 'file_name'
  7.   calc_sha256(file_name, "file.sig"); //hash value now inside of file.sig, lets now sign that hash
  8.   fclose(fsig);
  9.  
  10.   int fsize=0;
  11.  
  12.   fsig = fopen("file.sig", "r+"); //read the hash inside that file  
  13.  
  14.   fseek(fsig, 0L, SEEK_END);
  15.   fsize = ftell(fsig);  
  16.   fseek(fsig, 0L, SEEK_SET);
  17.  
  18.   unsigned char *m = malloc(fsize);
  19.   unsigned char *sigret = malloc(1024); //i guess its 1024 because my ksize if 1024...
  20.   unsigned int *sigret_len = 0;
  21.   sigret_len = sizeof(sigret);
  22.   printf("teste:%d\n", sigret_len);
  23.   BIO *b=NULL;
  24.   RSA *rsaPrivateKey=NULL;
  25.  
  26.  
  27.   fread(m, fsize, 1, fsig); //printed *m and it was loaded correctly
  28.  
  29. //  RSA_sign(NID_sha256, m, strlen(m), sigret, strlen(sigret), rsa);
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement