0

below is my code

void encrypt(){ 
  //Opening files where text plain text is read and ciphertext stored      
  fp=fopen("input.txt","rb");
  op=fopen("output.txt","wb");
  if (fp==NULL) {fputs ("File error",stderr); exit (1);}   
  if (op==NULL) {fputs ("File error",stderr); exit (1);}      

  //Initializing the encryption KEY
  AES_set_encrypt_key(ckey, 128, &key); 

  //Encrypting Blocks of 16 bytes and writing the output.txt with ciphertext  
 while (1) {     
    init_ctr(&state, iv); //Counter call
    bytes_read = fread(indata, 1, AES_BLOCK_SIZE, fp); 
    AES_ctr128_encrypt(indata, outdata, bytes_read, &key, state.ivec, state.ecount, &state.num);    
    bytes_written = fwrite(outdata, 1, bytes_read, op); 
    if (bytes_read < AES_BLOCK_SIZE) 
    break; 
  }   

  fclose (fp); 
  fclose (op);
  free (buffer); 
}

int main(int argc, char *argv[]){  
  encrypt();  
  //decrypt(); 
  system("PAUSE");  
  return 0;
}

I referenced this link: AES CTR 256 Encryption Mode of operation on OpenSSL

But I found 2 error that explain _AES_set_encrpyt_key and _AES_Crt128-encrpyt weren't found in external symbol error code is LNK2019.

How to deal with this?

Community
  • 1
  • 1
  • Are you in the c programming lang? You should add a tag if that is the case. –  Apr 06 '14 at 08:49
  • is it ok?....i already trie to many ways... – user1829967 Apr 06 '14 at 08:56
  • Not a clue. I've done this in other languages, but not c. That's why I looked and suggested the tag. :) –  Apr 06 '14 at 08:57
  • 2
    you probably failed to link to the proper library - show your linker command line/IDE settings – mfro Apr 06 '14 at 09:10
  • My command to compile http://stackoverflow.com/questions/3141860/aes-ctr-256-encryption-mode-of-operation-on-openssl is `gcc main.c -o main -I /.../include -L /.../lib -lcrypto -lssl` Did you provide the right libraries (`-l`) and the path to them (`-L`) ? In your question, you wrote `_AES_set_encrpyt_key` but in your code it's `AES_set_encrypt_key` : is this typo a part of your code or just a part of your question ? Same for `_AES_Crt128-encrpyt`. – francis Apr 06 '14 at 09:43
  • @owlstead - thanks, you're right. I wish the site would migrate all those OpenSSL command questions from SO to SU. What does user1829967 want help with? encryption/decryption from an existing answer (i.e., the title), or the link error from this question (i.e., the body)? – jww Apr 06 '14 at 15:47
  • 1
    Please show the compile command, the link command and the exact errors output from the compiler and linker. Are you linking to the OpenSSL libraries? Where did you get OpenSSL on the Win32 platform? Did you build it yourself? – jww Apr 06 '14 at 16:04
  • I throw away above setting.......... – user1829967 Apr 06 '14 at 16:49
  • But, My environment is 64 bit , on visual 2008, using http://slproweb.com/products/Win32OpenSSL.html (Win64 OpenSSL v1.0.1f) And look some links..... a later i will try to agaign – user1829967 Apr 06 '14 at 16:52

0 Answers0