R
R
rustem_ck2017-03-05 09:39:52
PHP
rustem_ck, 2017-03-05 09:39:52

Is it possible to transfer over OpenSSL encrypt/decrype network?

There are two computers, physically in different places.
Computer A encodes the password string (1234) and sends the encrypted string to computer B.
Computer B will be able to decrypt the string given this password: 1234?
The openssl encrypt/decrypt function raises doubts - they encode/decode only on the basis of a salt or some other data specific to the hardware, for example? :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Ne-Lexa, 2017-03-05
@rustem_ck

Is it possible to transfer over OpenSSL encrypt/decrype network?

Sure you can. The main thing is that the password and IV match.
Block ciphers usually use AES-256-CBC.
If you plan to always use different passwords, you can think over a scheme for exchanging client-server keys using the Diffie-Hellman algorithm and, based on them, create a password and IV according to a certain algorithm.
For example, Telegram uses the following algorithm to generate a key and a vector:
// псевдокод
x = 0 for messages from client to server 
// or
x = 8 for those from server to client.

data = данные для шифрования или расшифрования
auth_key = ключ аутенификации 256 байт (зашить в клиент и сервер или получать при обмене ключами при помощи DH)
msg_key = substr(SHA1(data), 0, 16)

sha1_a = SHA1 (msg_key + substr (auth_key, x, 32));
sha1_b = SHA1 (substr (auth_key, 32+x, 16) + msg_key + substr (auth_key, 48+x, 16));
sha1_с = SHA1 (substr (auth_key, 64+x, 32) + msg_key);
sha1_d = SHA1 (msg_key + substr (auth_key, 96+x, 32));
aes_key = substr (sha1_a, 0, 8) + substr (sha1_b, 8, 12) + substr (sha1_c, 4, 12);
aes_iv = substr (sha1_a, 8, 12) + substr (sha1_b, 0, 8) + substr (sha1_c, 16, 4) + substr (sha1_d, 0, 8);

To protect against MITM, in the case of a key exchange, you can sew your own certificate into the client and server and reject requests not signed by it.
No, everything is clear. It's not random.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question