summaryrefslogtreecommitdiff
path: root/src/hashpwd.cpp
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-06-28 14:06:52 -0500
committerJohn Klug <john.klug@multitech.com>2018-06-28 14:06:52 -0500
commit7172a72ac22f4ed7380f603c9519299ded612bb8 (patch)
tree72f3f5bf0d5b10f9efe51891241f4f7dc7f267a7 /src/hashpwd.cpp
parentcfe8af3b0629368eeb61354e52ec12cc3d8637bd (diff)
downloadmts-id-eeprom-7172a72ac22f4ed7380f603c9519299ded612bb8.tar.gz
mts-id-eeprom-7172a72ac22f4ed7380f603c9519299ded612bb8.tar.bz2
mts-id-eeprom-7172a72ac22f4ed7380f603c9519299ded612bb8.zip
mts-ubpasswd to use uuid and device-id rather than MAC by default
Diffstat (limited to 'src/hashpwd.cpp')
-rw-r--r--src/hashpwd.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/hashpwd.cpp b/src/hashpwd.cpp
index 414ffbd..6bc322c 100644
--- a/src/hashpwd.cpp
+++ b/src/hashpwd.cpp
@@ -10,6 +10,8 @@
#include <string.h>
#include <openssl/sha.h>
+#define MYVERSION "1.1"
+
using namespace std;
int v = 0;
@@ -148,28 +150,33 @@ void usage(void)
{
cout << "usage:" << endl <<
" mts-hashpwd [-v] [[-d did] [-m mac] | [-p password]] salt" << endl <<
+ " -V version" << endl <<
" -v verbose" << endl <<
" -d did Device ID (serial #)" << endl <<
" -m mac Ethernet mac address" << endl <<
" -p password" << endl <<
- "Either password must be supplied, or Device-ID and Ethernet Mac address" << endl <<
+ " -u uuid UUID (base 16)" << endl <<
+ "Either password must be supplied, or Device-ID and " << endl
+ << "either Ethernet Mac address or UUID" << endl <<
"salt is required." <<endl;
exit(1);
}
int main(int argc, char **argv) {
- int opt = 0, p = 0, d = 0, m = 0;
+ int opt = 0, p = 0, d = 0, m = 0, u=0;
unsigned long long fudge = 0;
short unsigned int prefix;
- string did, mac, pwd, salt;
+ string did, mac, pwd, salt, uuid;
- while ((opt = getopt(argc,argv,"d:m:p:v")) != EOF)
+ while ((opt = getopt(argc,argv,"Vd:m:p:u:v")) != EOF)
switch(opt)
{
+ case 'V': cout << MYVERSION << endl; exit(0);
case 'v': v = 1; cout << " verbose" <<endl; break;
case 'd': d = 1; did = optarg ; (v==1) && cout << "device-id is " << did << endl; break;
case 'm': m = 1; mac = optarg ; (v==1) && cout << "Ethernet mac is " << mac << endl; break;
case 'p': p = 1; pwd = optarg ; (v==1) && cout << "User defined password is \"" << pwd << "\"" << endl; break;
+ case 'u': u = 1; uuid = optarg ; (v==1) && cout << "UUID is \"" << uuid << "\"" << endl; break;
case '?': usage(); break;
default: cout<<endl; abort();
}
@@ -184,8 +191,8 @@ int main(int argc, char **argv) {
cout << "Must use either a supplied password or Device ID and Ethernet MAC address, but not all three." << endl;
usage();
}
- if ((d && !m) || (m && !d)) {
- cout << "Must have both a Device-ID and an Ethernet MAC address." << endl;
+ if ((d && (!m && !u)) || (m && !d) || (u && !d)) {
+ cout << "Must have both a Device-ID and either a UUID or Ethernet MAC address." << endl;
usage();
}
if (optind != argc-1) {
@@ -212,7 +219,10 @@ int main(int argc, char **argv) {
unsigned char hash[SHA256_DIGEST_LENGTH];
if(!p) {
- passwd0 = did + "|" + mac;
+ if (m)
+ passwd0 = did + "|" + mac;
+ else if (u)
+ passwd0 = did + "|" + uuid;
passwdnew = passwd0;
while (1) {