Page 1 of 1

Encryption woes

Posted: Thu Jul 25, 2013 5:37 am
by trenatos
I'm trying to figure out how to transfer encrypted data to my server, have the server decrypt it and then respond.
I'm using sockets and it's working fine, but I don't understand the encryption system.

Code: Select all

get "textheres"
encrypt it using "aes256" with "passhere"
write it & return to socket "127.0.0.1:2001"
I'm getting random values, which I understand is due to the random salt being added, how can I extract the salt? If the server is to decrypt it, it'll need the salt.
If I specify the salt as below, it uses that salt, and it seems partially visible in cleartext, but again I'm not sure because it's only partially visible, the server still needs to be provided with the salt somehow.

Code: Select all

get "textheres"
encrypt it using "aes256" with "passhere" and salt "saltedhere"
write it & return to socket "127.0.0.1:2001"
The resulting string is this: Salted__saltedheÍ?°ÒôÛOªãßèü´ D
Now, it seems that sometimes the string also contains other characters such as carriage returns and EOL's, and this too has me confused, and that part IS messing with the socket, when it drops a return in the string.

Can someone explain to me what's going on?

Re: Encryption woes

Posted: Thu Jul 25, 2013 6:54 pm
by trenatos
Reading up on this, it has to do with OpenSSL encrypting with a header.
The first 16 bytes include the header and salt.
The salt is the second set of 8 bytes in the header.

Slowly getting somewhere :)

Re: Encryption woes

Posted: Fri Jul 26, 2013 1:56 am
by trenatos
I think I'm actually just going to write my server in LiveCode as well.

It'll use a MySQL database anyway, so I can easily create a web-based interface if I want to, later on, rather than using the web server by default.

It will also make it easier to distribute the client and server.