aboutsummaryrefslogtreecommitdiff
path: root/contrib/wpa_supplicant/wpa_passphrase.c
diff options
context:
space:
mode:
authorSam Leffler <sam@FreeBSD.org>2005-06-05 20:52:14 +0000
committerSam Leffler <sam@FreeBSD.org>2005-06-05 20:52:14 +0000
commitf1fb6907abb279cfabe81d79e2ffac54c4e7aa98 (patch)
tree98be326632e2ea3857ee0d9f831c91ea0823bb0d /contrib/wpa_supplicant/wpa_passphrase.c
downloadsrc-f1fb6907abb279cfabe81d79e2ffac54c4e7aa98.tar.gz
src-f1fb6907abb279cfabe81d79e2ffac54c4e7aa98.zip
Stripped down import of wpa_supplicant v0.3.8vendor/wpa_supplicant/0.3.8
Notes
Notes: svn path=/vendor/wpa_supplicant/dist/; revision=147013 svn path=/vendor/wpa_supplicant/0.3.8/; revision=147015; tag=vendor/wpa_supplicant/0.3.8
Diffstat (limited to 'contrib/wpa_supplicant/wpa_passphrase.c')
-rw-r--r--contrib/wpa_supplicant/wpa_passphrase.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/contrib/wpa_supplicant/wpa_passphrase.c b/contrib/wpa_supplicant/wpa_passphrase.c
new file mode 100644
index 000000000000..5a8203b833f4
--- /dev/null
+++ b/contrib/wpa_supplicant/wpa_passphrase.c
@@ -0,0 +1,53 @@
+/*
+ * WPA Supplicant - ASCII passphrase to WPA PSK tool
+ * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "common.h"
+#include "sha1.h"
+
+
+int main(int argc, char *argv[])
+{
+ unsigned char psk[32];
+ int i;
+ char *ssid, *passphrase;
+
+ if (argc != 3) {
+ printf("usage: wpa_passphrase <ssid> <passphrase>\n");
+ return 1;
+ }
+
+ ssid = argv[1];
+ passphrase = argv[2];
+
+ if (strlen(passphrase) < 8 || strlen(passphrase) > 63) {
+ printf("Passphrase must be 8..63 characters\n");
+ return 1;
+ }
+
+ pbkdf2_sha1(passphrase, ssid, strlen(ssid), 4096, psk, 32);
+
+ printf("network={\n");
+ printf("\tssid=\"%s\"\n", ssid);
+ printf("\t#psk=\"%s\"\n", passphrase);
+ printf("\tpsk=");
+ for (i = 0; i < 32; i++)
+ printf("%02x", psk[i]);
+ printf("\n");
+ printf("}\n");
+
+ return 0;
+}