Encrypted Data over Sockets

Bob Sneidar bobsneidar at iotecdigital.com
Fri Jul 8 19:14:40 EDT 2022

Hi all. 

I'm running into a curious thing. I am sending encrypted data over a socket connection. When I send the data, I am using blocking mode, where the commands look like this:

         if tCurrentConnectionA ["ssl"] is true then
            put slyEncrypt(tSocketData) into tSocketData
         end if
         close socket tSocket -- in case it was left open
         open socket to tSocket
         write tSocketData & linefeed to socket tSocket
         read from socket tSocket until linefeed
         put it into tReceivedData
         if the last char of tReceivedData is linefeed then \
               delete last char of tReceivedData
         close socket tSocket
         if tCurrentConnectionA ["ssl"] is true then
            put slyDecrypt(tReceivedData) into tReceivedData
         end if

Now just to belay questions that might be asked, I know that the read from socket is working because I get a salted hash back, so the server is doing what it is supposed to on the other end. 

However when I go to decrypt the hash I am SOMETIMES getting the dreaded Wrong final block length as an error. Curiously, sometimes it works! 

My suspicion is that the hash contains a linefeed (sometimes). So the question I have is, what character is GUARANTEED to NOT be in an aes256 hash? I need a delimiter. Read from socket until eof fails with a timeout. That is intensly unfortunate by the way, it ought to work. 

Bob S

More information about the use-livecode mailing list