Sign in with
Sign up | Sign in

Understanding WPA/WPA2: Hashes, Salting, And Transformations

Wi-Fi Security: Cracking WPA With CPUs, GPUs, And The Cloud
By

WPA/WPA2, WinZip, WinRAR, Microsoft's native Data Encryption API, Apple's FileVault, TruCrypt, and OpenOffice all use PBKDF2 (Password-Based Key Derivation Function 2.0). The critical element here is that a password won’t directly grant access to whatever it's protecting. You need to generate a key (decryption code) from the password.

This is one of the most critical differentiators separating WEP and WPA. WEP doesn't obscure your password in an effective way. That is a huge security risk because hackers can directly extract it from packets sent during authentication. This makes it easy for those same folks to sit in parking lot or lounge around in a mall and break into networks. Once enough packets are gathered, extracting the key and connecting to the network is easy. WPA is different because the password is hidden in a code (in other words, it's hashed), forcing hackers to adopt a different tactic: brute-force cracking. 

In one of our last security-oriented pieces, we noticed some confusion in the comments section where readers were asking for more clarification on concepts like rainbow tables, hashes, salting, and transformations.

There are two major parts to converting a password value to a decryption key. The first is called salting. It's possible you've heard this term used once or twice. This is a method in cryptography that prevents two systems from using the same key, even though they may share the same password. Without salting, a pair of machines using the same password, even coincidentally, end up with the same key. This is a vulnerability for rainbow tables, which are huge spreadsheets that allow you to look up the original password (provided you know the key). Salting largely nullifies the use of rainbow tables, because every password uses a random value to generate a different key. It also effectively renders password derivation a one-way function, because you can't backwards-generate passwords from keys. For example, SSIDs are used to salt WPA passwords. So, even if your neighbor uses the same password, he's going to have a different key if his router has a different name.

PBKDF2 takes things one step further by using a key derivation function (KDF). The idea itself is pretty simple, but it's a little math-heavy. There are two steps:

  1. Generate data1 & data2 from password and salt.
  2. Calculate key using transformation invocations using a loop, which looks like:

        for (int i=0; i<iteration_count; i++)
                {
                data1 = SHA1_Transform(data1, data2);
                data2 = SHA1_Transform(data2, data1);
                  }

Basically, you input the password and salt (the random bits) in order to generate the first data parameter. This represents the key in it's non-final form. From there, the key is continuously hashed in a cycle, where the next calculation relies on the previous one in order to continue. For every interval, the value of the key changes. Repeat this a couple thousand times and you have the final decryption key. And because you can't go backwards, brute-force cracking requires you to "recreate" the key on every password attempt.

This process accounts for 99% of the computational overhead required in brute-force cracking, so throwing copious compute muscle at that wall is really the only way to chisel it down. Hash cracking lets you to try multiple passwords at a time because the process doesn't employ a key derivation function or salt, making it magnitudes faster. As a practical matter, the impressive speeds you see from hash cracking shouldn't scare you. This form of brute-force hacking is limited in scope, since just about everything secure utilizes salting and a key derivation function. 

To give you a sense of scale, WinZip uses 2002 SHA-1 transformation invocations to generate a key. This value is constant for any password length, up to 64 characters. That's why a 10-character password is just as easy to defeat with AES-256 as it is with AES-128. WPA, on the other hand, uses 16 388 transformations to convert a master key (MK) into what's known as a Pairwise Master Key (PMK). That makes brute-force cracking in WPA 8x slower than it does with WinZip/AES.

WPA relies on a Pre-Shared Key (PSK) scheme. You may enter in a master key (the value that you see in the password field on the router), but you can only "sniff out" the Pairwise Transient Key (PTK) during what is known as a "four-way handshake."

Authentication relies on deriving the PTK from a Pairwise Master Key, which is in turn derived from a master key. It takes about five or six more transformations to go from the PMK to PTK, but WPA cracking speeds are often presented in PMK units, the most computationally-intensive portion of the brute-force attack.

Display all 80 comments.
This thread is closed for comments
Top Comments
Other Comments
  • 6 Hide
    fstrthnu , August 15, 2011 4:50 AM
    Well it's good to see that WPA(2) is still going to hold out as a reliable security measure for years to come.
  • 9 Hide
    runswindows95 , August 15, 2011 4:52 AM
    The 12 pack of Newcastles works for me! Give that to me, and I will set you up on my wifi! Free beer for free wifi!
  • 9 Hide
    Soma42 , August 15, 2011 4:59 AM
    I think I'm going to go change my password right now...
  • 3 Hide
    Pyree , August 15, 2011 5:10 AM
    runswindows95The 12 pack of Newcastles works for me! Give that to me, and I will set you up on my wifi! Free beer for free wifi!


    Then either beer at your place is really expensive or internet is really cheap. Need 6x12 pack for me.
  • 14 Hide
    compton , August 15, 2011 8:01 AM
    Thanks for another article that obviously took a lot of work to put together. The last couple of articles on WiFi and archive cracking were all excellent reads, and this is a welcome addition.
  • 4 Hide
    Anonymous , August 15, 2011 9:38 AM
    What about the permutations of the words?
    i.e ape can be written:
    ape, Ape, aPe, apE, APe, aPE, ApE, APE.
    Thats 2^3=8 permutations. Add a number after and you get (2^3)*(10^1)=80 permutations.
    You can write PasswordPassword in 2^16=65536 ways.
    How about using a long sentence as a password?
    i.e MyCatIsSuperCuteAndCuddly, thats 2^25 permutations :) 
  • 7 Hide
    molo9000 , August 15, 2011 9:57 AM
    Any word on MAC address filtering?
    Can you scan for the MAC addresses? It's probably easy to get and fake MAC adresses, or it would have been mentioned.


    *scans networks*
    12 networks here,
    1 still using WEP
    10 allowing WPA with TKIP
    only 1 using WPA2 with AES only (my network)
  • 5 Hide
    agnickolov , August 15, 2011 10:50 AM
    Considering my WPA password is over 20 characters long I should be safe for the foreseeable future...
  • 10 Hide
    aaron88_7 , August 15, 2011 11:05 AM
  • 2 Hide
    ojas , August 15, 2011 12:24 PM
    Interesting article, i see that my fortress is safe :) 
  • 3 Hide
    dickcheney , August 15, 2011 1:40 PM
    molo9000Any word on MAC address filtering?Can you scan for the MAC addresses? It's probably easy to get and fake MAC adresses, or it would have been mentioned.*scans networks*12 networks here,1 still using WEP10 allowing WPA with TKIPonly 1 using WPA2 with AES only (my network)


    Same over here. I have a guest though, its a bit weaker than my main network. The guest is a 20 alphanumerical character long WPA2 AES-256bit. My main is 40 character long... Guess I went a bit overboard.
  • 0 Hide
    gokanis , August 15, 2011 1:43 PM
    aaron88_7"12345, that's amazing, I've got the same combination on my luggage!"Still makes me laugh every time!


    One of the best lines in the movie...
  • 1 Hide
    fausto , August 15, 2011 1:46 PM
    i better check on security when i get home
  • 3 Hide
    banthracis , August 15, 2011 1:50 PM
    molo9000Any word on MAC address filtering?Can you scan for the MAC addresses? It's probably easy to get and fake MAC adresses, or it would have been mentioned.*scans networks*12 networks here,1 still using WEP10 allowing WPA with TKIPonly 1 using WPA2 with AES only (my network)


    MAC address filtering is a joke, especially if the network actively broadcasts its SSID. Simple reason, MAC address and IP info is not even encrypted when sent over the air. So, wait for legit user to connect, grab his MAC, spoof MAC address and enjoy.
  • 6 Hide
    acku , August 15, 2011 2:11 PM
    Quote:
    "Why? Because an entire word is functionally the same as a single letter, like "a." So searching for "thematrix" is treated the same as "12" in a brute-force attack."

    This is an extremely wrong conclusion. Extremely wrong.



    If you truly understand programming, then you know that my statement is a comparison of dictionary vs. brute-force attacks. In a dictionary attack, you provide a wordlist, which is used to make unique combination. For a brute-force attack, each letter is randomly selected and joined together in a string. The length of a password has no bearing on the number of KDFs. I suggest that you read Ivan Golubev's blog post and hit up the BackTrack forums if you need help understanding why this is the case.

    Quote:
    "Next Big Bang" do you known what moore's law is? that "All (Printable) ASCII characters" 12 character password will be cracked in your lifetime, possibly with the cpu power of your cell phone.
    in 1982 we had spectrum zx with a z80 cpu running @3.5mhz. now I've an intel E7-8870 with 10cores running @E7-8870. not to mention like you demonstrated that gpu's are far more powerful cracking passwords. Also you can use other programs, pyrit is not the best for cracking with gpu's. Also you can use rainbow tables.
    Your assumption that a WPA2 with 12 characters is safe forever is very wrong and missleading and dangerous. It's the same assumptions that made people believe WEP was ok to use forever. now we can crack wep under 1 minute.


    RISC? That better be distributed if we're going to walk down that path. And as I've explained time and time again, rainbow tables are not valid for this type of attack. I purposely explained why under "Understanding WPA/WPA2."

    Second, I'm not sure what you're using but Pyrit is considered the standard by which other brute-force crackers are measured for WPA/WPA2. It's what's used at DEFCON. Our version has some optimizations, but again, it you go to any of the major security conferences, you'll find that it's what people use.

    Third, WEP is can be broken with relative ease because it's not a brute-force attack that renders it ineffective. It's a related key attack. Any nondirect attack leverages weaknesses in order to compromise a system. That's a different ballpark. We're dealing with cracking at the lowest common denominator.

    Quote:
    What about the permutations of the words?
    i.e ape can be written:
    ape, Ape, aPe, apE, APe, aPE, ApE, APE.
    Thats 2^3=8 permutations. Add a number after and you get (2^3)*(10^1)=80 permutations.
    You can write PasswordPassword in 2^16=65536 ways.
    How about using a long sentence as a password?
    i.e MyCatIsSuperCuteAndCuddly, thats 2^25 permutations :) 


    Permutations of words don't count in a dictionary based attack. I mean com'on. :)  Let's be reasonable. You're either paranoid at this point or too smart. Though, I'd argue that caps on the first letter is easily defeatable.

    Cheers,
    Andrew Ku
    TomsHardware.com
  • 2 Hide
    custodian-1 , August 15, 2011 2:28 PM
    All through history people have tried to lock things if someone locks it someone else will figure how to unlock it. It may me mathematically impossible but it's not the only way. Someone will have to know the password and we are fallible.
  • 0 Hide
    WyomingKnott , August 15, 2011 4:03 PM
    Quote:
    or amateur script kiddies testing their meddle.

    I try to avoid picking on grammar or word errors, since it seems that many of these articles are translated from German. But this is a beauty.

    The phrase is usually "testing their mettle," which the dictionary on Yahoo! defines as "Courage and fortitude; spirit." The usual error on this phrase is the substitution of the word "metal" by spell checkers, dictation software, or people who don't know the origin of the phrase.

    But since these kiddies do indeed "meddle" with out networks, our data, and our lives, the substitution works elegantly.
  • -2 Hide
    jamie_1318 , August 15, 2011 4:17 PM
    Man sucks for all you people who live close enough to there neighbor to worry about their password being hacked. My nearest neighbor is more than 200m away, and than I live in a brick house, so it barely goes out the windows. It would be pretty obvious if some dude was standing outside my house accessing my files.
  • 3 Hide
    djridonkulus , August 15, 2011 4:17 PM
    Why don't they limit the number of authentication attempts like you said in the article like banks? Wouldn't that kill all attempts at brute force hacking?
Display more comments