Does wpa_passphrase use a hashing algorithm? - linux

The question is pretty clear. I'm wondering if it uses a hashing algorithm, or it is simply an encryption. If it is a hash, then what algorithm is used (md5, sha1, etc)? Also, does the router compare the password in plain text for validation or a hash?

In WPA-PSK, the WPA passphrase and SSID are used to derive the 256 AES key used to encrypt the wireless traffic. The key derivation function is PBKDF2, defined in RFC 2898. If the passphrase for the SSID is correct the encryption will work so that the client can successfully communicate with the AP. Otherwise, the communication will fail. That's how the AP knows the passphrase is correct (the traffic isn't gibberish).

Related

What is the point of encrypting user passwords on the frontend?

I'm working with an API that requires the user's password to be encrypted with the server's public key before sending to the server. If the whole request, including username/password/etc. is being sent through HTTPS, isn't the password encryption redundant?
Depending on the server architecture, this kind of encryption can be helpful. For example, the TLS (HTTPS) connection may be terminated (decrypted) at the perimeter of the network in order to simplify load balancing or to scan the stream for malicious packets. Separately encrypting the password protects the password even from the edge servers, so an attacker who is able to compromise one of those still cannot gain access to the password.
Personally I stretch (i.e. PBDKF2) passwords before sending them. This ensures that the raw password is never seen by the server at all. But even in that configuration, an extra layer of encryption for the hash could be useful when the TLS stream is decrypted early.

Node.js Server Request to HTTPS Enough for Encryption?

After much googling I'm still just as lost as I was when I started. I'm trying to make a secure request from one server to another in Node.js, and I'm unsure if sending the request through https (ex: https://someapi.com) is sufficient. Both servers are owned by me. One server needs to ping the other for verification/authentication by sending an API key + secret to it. Would my request from the requesting server to the authentication server be encrypted? Or would it be vulnerable to man-in-the-middle attacks?
I'm making the request from the main/requesting server like so:
const rpn = require('request-promise-native');
const options = {
method: 'POST',
uri: 'https://authenticationserver.com/api/verification',
json: {
api_key: API_KEY_HERE,
secret: SECRET_HERE
}
}
rpn(options)
.then((responseData) => console.log('successful'))
.catch((err) => console.log('error'));
Yes, using HTTPS is sufficient for this task.
The primary purpose of a secure transport protocol (like HTTPS, SSH, WSS, etc.) is to make man-in-the-middle attacks very hard. Because of the nature of the internet you cannot control the machines that your data travels through, so it's nearly impossible to prevent a man-in-the-middle attack, unless of course you control the entire network of computers like an intranet. Knowing this some very smart people invented Public-key cryptography to combat man-in-the-middle attacks.
Public-key cryptography exploits a feature of advanced number theory where the basic idea is that is very computationally expensive to factor very large prime numbers. Using this feature it is possible to generate two very large prime numbers, then using some complex mathematics you can encrypt data with one of the prime numbers in such a way that the only way to decrypt the data is to do the mathematic operation in reverse using the other prime number. These two prime numbers are referred to as public and private keys.
When two computers establish an HTTPS connection they share their public keys and negotiate an encryption cypher. Once a cipher is determined (like AES) an additional key must be generated by one of the computers and shared with the other, this is the key that will be used to encrypt and decrypt the actual traffic. This key, however, is first encrypted using the public key of the computer that will be receiving the key. The receiving computer then decrypts the key using it's private key and the process known as "handshake" is complete.
During this handshake you'll notice that the private keys are not shared over the network, this is the key to avoiding the man-in-the-middle attack. Because the private key is not shared the man-in-the-middle does not have the ability to decrypt the cipher key and therefor are unable to decrypt the remaining traffic sent over the connection.
If you want to be as secure as possible you should generate sufficiently large public/private keys, update the keys regularly, and disallow the negotiation of insecure cipher suites. You cannot prevent a man-in-the-middle attack, you can only make it more difficult for them.
In theory, in your case, HTTPS should be enough secure.
If you want to increase security, you can play with RSA, AES to encrypt and decrypt your payload before sending it.
If these are cloud servers, and the communication is directly from server1 to server2, arrange the servers in the same VPN and block access from outside the VPN to the authentication server.
In AWS, you can use API Gateway to target specific routes on the authentication server allowing you to selectively expose routes for public (outside the VPN) consumption if you need that still.

HostKeyAlgorithms in centos6.5

Although I mention ssh-dss for HostKeyAlgorithms in /etc/ssh/ssh_config. ssh-rsa key pair can be used to login!
HostKeyAlgorithms ssh-dss
Some useful info on the above issue
In practice, a RSA key will work everywhere. ECDSA support is newer, so some old client or server may have trouble with ECDSA keys. A DSA key used to work everywhere, as per the SSH standard (RFC 4251 and subsequent), but this changed recently: OpenSSH 7.0 and higher no longer accept DSA keys by default.

If I know the password of a WPA2 access point, can I passively eavesdrop to communications?

Suppose there's a WPA2 hotspot with a few stations connected to it, and suppose I know the passphrase to connect to this hotspot. Will it be possible to decrypt everyone's communication by being completely passive? (i.e. just sniffing the packets with a wifi sniffer, and without connecting to the network or sending packets to the air).
For this matter, is there a difference between knowing the alphanumeric passphrase or the hexadecimal PSK?
The passphrase is used to generate a PSK via a password hashing function (PBKDF2) which you can easily do yourself, so knowing either the passphrase or the PSK is sufficient.
Between the AP and any particular station, the PSK is used to create a set of temporal keys that are actually used to encrypt frames.
If you capture the 4-way handshake which takes place after authentication/association between the AP and a station, then you will be able to deduce the temporal keys that were calculated for that session, and use these to decrypt unicast frames between the two, and broadcast frames from the AP.
Wireshark will do this for you if you capture the traffic complete with 4 way handshake, and enter the PSK/passphrase.
So to answer your question - yes, you can theoretically passively decrypt traffic if you know the PSK/passhprase without having to actively inject any extra frames, as long as you capture the initial 4-way handshake.
You only need to start injecting frames if you want to force a station to reauthenticate and perform its 4 way handshake, for example by spoofing a deauth.

Can a man-in-the-middle intercept an SSL packet and duplicate it?

AFAIK, SSL will encrypt the message under secure. But I still have the concern whether or not a man in the middle can catch the packet and duplicate it e.g. 1000 times
Application data is broken into small segments (implementation dependent size, usually <=16kb). Then that segment is
Compressed
Given a sequence number
Added a MAC (sequence number included in MAC calculation)
Encrypted
Given an SSL record header that contains the sequence number
Note the role of sequence number in this process. If the man-in-the-middle duplicates one such segment, the received can detect it using the sequence number. And the attacker cannot forge sequence number since it is included in MAC as well as the record header.
Sequence number gives SSL protection against duplication, deletion, reordering and replay attacks.
SSL is secure from interception, replay, MITM, and truncation attacks. At least.
Sure, a passive man-in-the-middle attacker can catch the encrypted packet - that's why you do encryption. But because each SSL connection uses a unique encryption key the attacker cannot use this sniffed encrypted packet later to inject it into another connection. And as long as the encryption key is not compromised (which means for RSA key exchange that the private key of the certificate is not compromised) the attacker can not decode the sniffed packet.
Apart from that an active man-in-the-middle attacker might put itself in-between the parties, e.g. instead of Alice talking to Bob Alice will talk to Mallory and Mallory to Bob. To make this impossible you need the identification part of SSL, e.g. certificate checking and verification of the host name (one alone is not enough). Only this makes true end-to-end encryption possible.

Resources