[cs631apue] EVP_EncryptFinal_ex

tparisi tparisi at stevens.edu
Wed Nov 28 13:39:27 EST 2012


I wasn't able to answer your question before but I think I have a 
handle on it now.  Your supposed to you read in data from where ever you 
are (in our case stdin).  The read function will give you the number of 
bytes that was read.  This is the part that goes into inl.  The function 
will only encrypt that much data (in case the buffer is not all the way 
used).  This buffer is continually reused to to read in information from 
the input.  You have to explicitly call the EVP_EncryptFinal_ex function 
to get the last few bits of information from the structure only after 
there is nothing to be read in.  It should be the last thing that you do 
before writing the last bit of ciphertext.  To summarize read in the 
size of the buffer, then call the encrypt function with inl being the 
number of bytes you were able to read.  Then call the 
EVP_EncryptFinal_ex function when there is nothing left to read.

Hope this helps,
Tom


More information about the cs631apue mailing list