keygen enhancements.

This commit is contained in:
solomon 2002-10-17 13:10:18 +00:00
parent 27e6b87cdc
commit 635176d271
3 changed files with 35 additions and 7 deletions

View File

@ -41,6 +41,7 @@
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
- Patch from Tom Prado to make 'keygen' more user-friendly.
- bap_timeout parameter only valid on non-usb platforms
-pre3
- Added Ident info for the USB Compaq/Intel W200 widget

1
THANKS
View File

@ -93,6 +93,7 @@ Michael Beattie <mjb@debian.org>
Joey Hess <joey@kitenet.net>
Clay Jones <cjones1@email.com>
Matthew Rush <matthew@42.co.nz>
Tom Prado <tprado@charter.net>
[Many, many more. If I've overlooked you and you want to be listed here,
send me e-mail and I'll fix it. I _know_ a bunch of linux-wlan contributors

View File

@ -22,6 +22,7 @@
#define WEPSTRONGKEYSIZE 13
#define WEPKEYS 4
#define WEPKEYSTORE (WEPKEYSIZE * WEPKEYS)
#define WEPSTRONGKEYSTORE (WEPSTRONGKEYSIZE * WEPKEYS)
/*
* generate four subkeys from a seed using the defacto standard
@ -67,11 +68,11 @@ wep_keygen128(char *str, u_char *keys)
MD5_Update(&ctx, buf, sizeof buf);
MD5_Final(buf, &ctx);
memcpy(keys, buf, WEPKEYSTORE);
memcpy(keys, buf, WEPSTRONGKEYSTORE);
for(i = 0; i < WEPSTRONGKEYSIZE; i++) {
keys[i] = buf[i];
}
for(; i < WEPKEYSTORE; i++) {
for(; i < WEPSTRONGKEYSTORE; i++) {
keys[i] = 0;
}
return;
@ -103,7 +104,7 @@ wep_keygen40(char *str, u_char *keys)
}
void
wep_keyprint(u_char *keys)
wep_keyprint40(u_char *keys)
{
int i;
char sepchar;
@ -115,10 +116,22 @@ wep_keyprint(u_char *keys)
return;
}
void
wep_keyprint128(u_char *keys)
{
int i;
char sepchar;
for(i = 0; i < WEPSTRONGKEYSTORE; i++) {
sepchar = (i % WEPSTRONGKEYSIZE == WEPSTRONGKEYSIZE - 1) ? '\n' : ':';
printf("%02x%c", keys[i], sepchar);
}
return;
}
void
usage(char *prog)
{
printf("Usage: %s [-s] keystring\n", prog);
printf("Usage: %s keystring [-s || 5 || 13]\n", prog);
exit(1);
}
@ -126,6 +139,7 @@ int
main(int argc, char **argv)
{
u_char keys[WEPKEYSTORE];
u_char strongkeys[WEPSTRONGKEYSTORE];
char *prog, *genstr;
int strong, ch;
@ -143,15 +157,27 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
if(argc==2)
if(!strcmp(argv[1],"13"))
{
strong++;
argc--;
}
else argc--;
if(argc != 1)
usage(prog);
genstr = argv[0];
if(strong)
wep_keygen128(genstr, keys);
{
wep_keygen128(genstr, strongkeys);
wep_keyprint128(strongkeys);
}
else
{
wep_keygen40(genstr, keys);
wep_keyprint(keys);
wep_keyprint40(keys);
}
return 0;
}