I'm having some trouble implementing some security measures over a network for one of my school projects. We already have a full network running using Ruby. We're trying to use AES 256 CBC using the OpenSSL library. We have experimented with using Diffie Hellman, but this is where we're having trouble: node 1 runs:
require 'openssl'
dh1 = OpenSSL::PKey::DH(256)
der = dh1.public_key.to_der
###we would send der to n2 here
Apparently it's alright to send der over to n2, so n2 would have this portion of code:
require 'openssl'
dh2 = OpenSSL::PKey::DH(der)
and now they have each others' information. However wouldn't a node which was listening to traffic be able to pick this message up and be able to have dh1's key? Having trouble wrapping my head around this.