Where does openssh decrypt and react to received packets? - cryptography

I am trying to add a second layer of encryption (encrypted on the client side, and decrypted on the server side).
EDIT: I apologize if I wasn't clear. I was looking for the function in the OpenSSH source in C where the ssh connection on the server side responds to activity from the client side. I did end up finding what I was looking for...

Found it! It is in the file channels.c and in the function void channel_input_data(int type, u_int32_t seq, void *ctxt).

Related

Extract public key from a weak client

Let's say we have a client that uses asymmetric cryptography to communicate with a server. This could be SSL or just a custom encryption.
Now if we assume that the client's source code is easy to disassemble, can we extract the public key and hence send bogus messages to the server?
Anyway to avoid this? Consider that it is really hard to keep the client's source code safe.

RSA two-way decryption?

I've been experimenting with RSA encryption in python (cryptography.hazmat.primitives.asymmetric). I have the following setup: On one end is the client with the public key sending encrypted data back to the server, which holds the private key. Right now I've got one-directional encryption working, but I'm wondering how you would (or if you should) securely decrypt a message client-side. I thought about just encrypting the private key and storing it, but then the password would appear in the code and expose the key to compromise. Is there a way to securely implement this with a key exchange? Or--the most likely alternative--is this a misuse of the protocol?
EDIT: Wanted to clarify that the possible concerns here would be that using RSA in this way might expose the private key on the file system or between the server and the client.
The normal way is for the server to encrypt the reply with the client's public key and client decrypt with its private key. This requires TWO RSA keypairs -- one for the client and one for the server, and requires each end to know the other's public key.
This need (along with high cost of PKE compared to symmetric encryption) is why PKE is normally only used for authentication and/or key exchange, and a symmetric cipher is used to actually encrypt traffic.

Send #define line with packets from server to client

I have a game server. He communicates with the client via packet. I want to send line
#define From the server to the client with a packet.
In this way not I be forced to recompile the source to the client always.
Basically I can activate functions that are source directly from server to client.
I just need an example about this. :D Please help.
typedef struct define_packet_send {
BYTE header;
int define_max_len[20];
long data;
}
But how to send the define in a specific file. I hope you guys you understand what i mean.

Which message is used on authenticated ip packets using HMAC-MD5?

This is not a programming question per se, but it is related to a c program that I am trying to make in order to respond the ip sla control messages sent by a cisco router. I know that it uses MD5 using and a key chain in order to authenticate the packet (Could be MD5 or HMAC). I know about the theory about HMAC and MD5 and all about the message and the key and all that stuff that the theory on the book give us... but I have a question that does not seems very simple at least to me that is at the end Which is the "message" that is hashed and added to the packet so the other end could know that he packet is valid?
Thanks for your help...
EDIT:
I have two routers one acting as a ip sla generator and another one as an ip sla responder. The ip sla generator authenticate the data sent by using MD5 and a key.
Capturing the packets that left the ip sla generator interface with Wireshark I found this:
Packet not Authenticated:
IP header
4500005000000000ff1136e3c0a801c3c0a801a6
UDP Header
e2e607af003ccdbd
Payload
01040034000000000004001000000000c0a801a6ea6014500001001c000000000000000000000000000000000000000000000000
Packet Authenticated with key "cisco":
IP Header
4500005000000000ff1136e3c0a801c3c0a801a6
UDP Header
c20107af003cd296
Payload
01040034000000000004001000000000c0a801a6ea6014500001001c00000000*01ff0000b9c0ae94fec238bd43d13129a6625eda*
*where at the end of the payload you could see 0x01ff that is the key number used to authenticate the packet and 0xb9c0ae94fec238bd43d13129a6625ed that is the authentication string
Capturing another Authenticated packet with key "cisco" I got this:
IP Header
4500005000000000ff1136e3c0a801c3c0a801a6
UDP Header
d47607af003cc021
Payload
01040034000000000004001000000000c0a801a6ea6014500001001c00000000*01ff0000b9c0ae94fec238bd43d13129a6625eda*
As you could see the UDP header changes but the authenticated message remains the same, that lead me to infer that the message to hash is just the payload but hashing the following combinations does not produce the authentication needed:
MD5 of the payload not authenticated
MD5 of the payload not authenticated + key in Hex
Hmac-Md5 of the payload not authenticated
Hmac-Md5 of the payload not authenticated + key in Hex
A lot more combinations too long to be listed...
So i think that the message is not as simple as the payload or the Authentication Method used by Cisco is not standard. Am I missing something? or There is something else I could try?
Thanks for your help...
The answer is: yes, it depends on the protocol (which I cannot find). I don't see any mention of HMAC in the documentation though, so it is much more likely that the key is included as last part in the hash calculation, but is not in the package (of course). This is different from appending zero's. The plain MD5 hash is then used as some poor man's authentication scheme.
All this from the confusing docs from Cisco and the relatively hard to read question - and general knowledge of crypto, of course.

SSL security concern

I'm wondering why ssl encrypted data can't be cracked easily once the packets are intercepted. As i understand it when you connect to a site like facebook the browser and site agree on a cipher, what stops the sniffer from seeing what cipher they agreed to?
SSL uses asymmetric encryption, meaning the decryption key is different than the encryption key. So if you as a client encrypt your packets with the server's public key, it can only be decrypted by the private key, which remains on the server. Of course, this is a simplification of everything that happens in an SSL transaction, but that's the basis of the concept.
Imagine sending a box with an open padlock to the other side - when the other side wants to send a message, they put it inside the box, lock the padlock and send it back to you, where you use your (private) key to unlock it. Even if the intercepting party has sees the padlock, they still don't have the key.
There's a lot of ways to describe it. For me, my ah-hah moment was when I figured out that, after information is encrypted multiple times, it can be decrypted in any order.
A encrypts first, passes to B a single encrypted message [A encryption].
B encrypts the message a second time, and passes to A a double encrypted message [A encryption and B encryption]
A removes [A encryption] from the message, leaving only [B encryption], and sends the message to B.
B now has a [B encrypted] message, and knows how to decrypt it.
The sniffer sees the message encrypted three different ways: [A], [AB], and [B].
That's three message passes to exchange one message, but once it's passed and both sides have the unique information to decrypt further communication, future messages only need one trip.
If you want a simple example of how a message could be decrypted in any order, you can use XOR as a sample encryption method. For keys A and B, message M, and XOR is ^, then
M ^ A ^ A = M
M ^ A ^ B ^ A ^ B = M
Facebook signs it's package with a certificate that Facebook got from an certificate authority such as RapidSLL.
As long as you trust the certificate authorities that all certificate they issue for facebook.com do really belong to facebook.com the connection is safe.
Facebook then sends you via a signed message it's public encyrption key which you can use to encrypt your messages to be read by facebook.
Yes, the cipher is public. However, the client asymmetrically encrypts a random session key (or rather a precursor) using Facebook's public key (they verify it's really Facebook's key by checking that it is signed by someone trusted). So only Facebook (who has a private key) should be able to derive the actual symmetric keys that are used to exchange website data.
See this detailed walk-through. In that example, an eavesdropper can tell that the connection uses RSA, RC4, and MD5. But they don't have Amazon's private key, so they can't derive the session keys.
Like Derek H said, there are fundamental differences between symmetric and asymmetric encryption. Look up stuff like DH key exchange protocol and RSA cipher, they are fundamental in SSL/TLS. On the other hand, it's relatively easy to decrypt sniffed data (ROBOT attack).
If you just need to be sure your communication is secure, you can simply use SSL/TLS Server Test, there you can see if you're not using recommended algorithms or see if your SSL/TLS configuration is PCI-DSS/HIPAA/NIST compliant.