Five Pounds of Flax

Every culture has a burrito.

Windows XP Service Pack 2 (SP2) - "Limited or no connectivity"

Sunday, January 02, 2005posted by Michael Rothwell @ 8:22 PM

Microsoft broke the passphrase hashing in WinXP SP2. Prior to SP2, you could type in a 13-character passphrase and Windows would hash it into a 128-bit WEP key for you. The tooltip-help still indicates this is the case; however, it doesn't work. You have to put in the full hex key. You can generate a full hex key by using the java program below. I have also written a web-based version of this WEP key generator.


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class WEPKey {
public static void main(String[] args) throws NoSuchAlgorithmException {
printKeys(generateKeys("your13letterkeyhere"));
}
private static void printKeys(byte[] key) {
for(int i=0; i < 13; i++) {
int val = key[i] < 0 ? 256 + key[i] : key[i];
if (val < 15)
System.out.print('0');
System.out.print(Integer.toHexString(val).toUpperCase());
System.out.print(" ");
}
for(int i=0; i < 13; i++) {
int val = key[i] < 0 ? 256 + key[i] : key[i];
if (val < 15)
System.out.print('0');
System.out.print(Integer.toHexString(val).toUpperCase());
}
System.out.println();
}
private static byte[] generateKeys(final String passphrase) throws NoSuchAlgorithmException {
byte[] passbytes = passphrase.getBytes();
byte[] hasInput = new byte[64];
int fullRepetitions = 64 / passbytes.length;
int partialRepetitions = 64 % passbytes.length;
for(int i = 0; i < fullRepetitions; i++)
System.arraycopy(passbytes, 0, hasInput, i * passbytes.length, passbytes.length);
System.arraycopy(passbytes, 0, hasInput, hasInput.length - partialRepetitions, partialRepetitions);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] keys = md.digest(hasInput);
return keys;
}
}

Save it in a file named "WEPKeys.java".
Run "javac WEPKeys.java"
Run "java WEPKeys" and it will spit out your hex key.