For upcoming changes to the installer.
PRE: # ifconfig wpi0 nwid mynet wpa wpapsk `wpa-psk mynet "my secret
passphrase"`
POST: # ifconfig wpi0 nwid mynet wpa wpapsk "my secret passphrase"
A few conflicts arises;
1. You cannot have a passphrase starting with "0x"
2. You cannot, as in -current, enter a 32-char string as the key (for
those of you even aware of that possibility, I sure wasn't :)
3. An nwid is required prior to supplying a passphrase to wpapsk.
4. If the nwid is changed afterwards, the passphrase is not adjusted.
1 and 2) These can be taken care of by breaking this out into a new
"wpapass" option or so, if seen as real problems.
3 and 4) I don't see these as real problems.
I don't know yet if the size increase affects any bsd.rd's or so.
$0.02 for your thoughts...?
/Alexander
Index: sbin/ifconfig/Makefile
===================================================================
RCS file: /cvs/src/sbin/ifconfig/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- sbin/ifconfig/Makefile 22 Nov 2009 22:00:24 -0000 1.10
+++ sbin/ifconfig/Makefile 12 Sep 2010 01:14:21 -0000
@@ -1,7 +1,10 @@
# $OpenBSD: Makefile,v 1.10 2009/11/22 22:00:24 claudio Exp $
+.PATH: ${.CURDIR}/../bioctl
+CFLAGS+=-I${.CURDIR}/../bioctl
+
PROG= ifconfig
-SRCS= ifconfig.c brconfig.c
+SRCS= ifconfig.c brconfig.c pbkdf2.c
MAN= ifconfig.8
CPPFLAGS+=-DINET6
Index: sbin/ifconfig/ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.239
diff -u -p -r1.239 ifconfig.c
--- sbin/ifconfig/ifconfig.c 3 Jul 2010 04:44:51 -0000 1.239
+++ sbin/ifconfig/ifconfig.c 12 Sep 2010 01:14:23 -0000
@@ -105,6 +105,7 @@
#include <ifaddrs.h>
#include "brconfig.h"
+#include "pbkdf2.h"
struct ifreq ifr, ridreq;
struct in_aliasreq in_addreq;
@@ -1706,18 +1707,43 @@ void
setifwpapsk(const char *val, int d)
{
struct ieee80211_wpapsk psk;
- int len;
+ struct ieee80211_nwid nwid;
+ int len, passlen, nwid_len;
+ u_int8_t keybuf[32];
if (d != -1) {
len = sizeof(psk.i_psk);
- val = get_string(val, NULL, psk.i_psk, &len);
- if (val == NULL)
- errx(1, "wpapsk: invalid pre-shared key");
- if (len != sizeof(psk.i_psk))
- errx(1, "wpapsk: bad pre-shared key length");
+ if (val[0] == '0' && val[1] == 'x') {
+ val = get_string(val, NULL, psk.i_psk, &len);
+ if (val == NULL)
+ errx(1, "wpapsk: invalid pre-shared key");
+ if (len != sizeof(psk.i_psk))
+ errx(1, "wpapsk: bad pre-shared key length");
+ } else {
+ passlen = strlen(val);
+ if (passlen < 8 || passlen > 63)
+ errx(1, "wpapsk: passphrase must be between "
+ "8 and 63 characters");
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_data = (caddr_t)&nwid;
+ strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCG80211NWID, (caddr_t)&ifr))
+ err(1, "SIOCG80211NWID");
+ nwid_len = nwid.i_len;
+ if (nwid_len == 0)
+ errx(1, "wpapsk: nwid not set");
+ else if (nwid_len > IEEE80211_NWID_LEN) {
+ nwid_len = IEEE80211_NWID_LEN;
+ warnx("truncating nwid to its first %d "
+ "characters", nwid_len);
+ }
+ pkcs5_pbkdf2(val, passlen, nwid.i_nwid, nwid_len,
+ psk.i_psk, len, 4096);
+ }
psk.i_enabled = 1;
} else
psk.i_enabled = 0;
+
(void)strlcpy(psk.i_name, name, sizeof(psk.i_name));
if (ioctl(s, SIOCS80211WPAPSK, (caddr_t)&psk) < 0)
Index: distrib/special/ifconfig/Makefile
===================================================================
RCS file: /cvs/src/distrib/special/ifconfig/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- distrib/special/ifconfig/Makefile 28 Oct 2009 07:36:49 -0000 1.2
+++ distrib/special/ifconfig/Makefile 12 Sep 2010 01:14:23 -0000
@@ -1,8 +1,10 @@
# $OpenBSD: Makefile,v 1.2 2009/10/28 07:36:49 deraadt Exp $
PROG= ifconfig
+SRCS= ifconfig.c pbkdf2.c
COPTS+= -DSMALL
-.PATH: ${.CURDIR}/../../../sbin/ifconfig
+.PATH: ${.CURDIR}/../../../sbin/ifconfig ${.CURDIR}/../../../sbin/bioctl
+CFLAGS+=-I${.CURDIR}/../../../sbin/bioctl
CPPFLAGS+=-DINET6