aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/nt_password_hash.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-05-09 14:06:53 -0700
committerDmitry Shmidt <dimitrysh@google.com>2011-05-09 14:24:08 -0700
commit8d520ff1dc2da35cdca849e982051b86468016d8 (patch)
tree3e33700a20ffe9064c3de3e9efa3a9dfcebb7b03 /hostapd/nt_password_hash.c
parent7acd11a82b3521a1ec0ef3976af4786b02642e7e (diff)
downloadexternal_wpa_supplicant_8-8d520ff1dc2da35cdca849e982051b86468016d8.zip
external_wpa_supplicant_8-8d520ff1dc2da35cdca849e982051b86468016d8.tar.gz
external_wpa_supplicant_8-8d520ff1dc2da35cdca849e982051b86468016d8.tar.bz2
wpa_supplicant: Initial Revision 0.8.X
Based on: commit 0725cc7b7efc434910e89865c42eda7ce61bbf08 Author: Jouni Malinen <j@w1.fi> Date: Thu Apr 21 20:41:01 2011 +0300 Enable CONFIG_DRIVER_NL80211=y in the default configuration nl80211 should be preferred over WEXT with any recent Linux kernel version. Change-Id: I26aec5afbbd4f4a1f5fd900912545b6f5050de64 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'hostapd/nt_password_hash.c')
-rw-r--r--hostapd/nt_password_hash.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/hostapd/nt_password_hash.c b/hostapd/nt_password_hash.c
new file mode 100644
index 0000000..839802a
--- /dev/null
+++ b/hostapd/nt_password_hash.c
@@ -0,0 +1,53 @@
+/*
+ * hostapd - Plaintext password to NtPasswordHash
+ * Copyright (c) 2005, Jouni Malinen <j@w1.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 "includes.h"
+
+#include "common.h"
+#include "crypto/ms_funcs.h"
+
+
+int main(int argc, char *argv[])
+{
+ unsigned char password_hash[16];
+ size_t i;
+ char *password, buf[64], *pos;
+
+ if (argc > 1)
+ password = argv[1];
+ else {
+ if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ printf("Failed to read password\n");
+ return 1;
+ }
+ buf[sizeof(buf) - 1] = '\0';
+ pos = buf;
+ while (*pos != '\0') {
+ if (*pos == '\r' || *pos == '\n') {
+ *pos = '\0';
+ break;
+ }
+ pos++;
+ }
+ password = buf;
+ }
+
+ if (nt_password_hash((u8 *) password, strlen(password), password_hash))
+ return -1;
+ for (i = 0; i < sizeof(password_hash); i++)
+ printf("%02x", password_hash[i]);
+ printf("\n");
+
+ return 0;
+}