bug fix for automatically finding deviceid and keys
This commit is contained in:
parent
90246b0292
commit
b0fd35157d
|
|
@ -80,10 +80,10 @@ OFFSET_DATA=$((OFFSET_DATA + DATAKEY_E_SIZE + 4))
|
||||||
echo "* sign w/ private key $SIGKEY"
|
echo "* sign w/ private key $SIGKEY"
|
||||||
openssl dgst -sha256 -sign $SIGKEY -out $TMPDIR/tmp.step4.1 $TMPDIR/tmp.step1
|
openssl dgst -sha256 -sign $SIGKEY -out $TMPDIR/tmp.step4.1 $TMPDIR/tmp.step1
|
||||||
openssl dgst -sha256 -verify $SHA256KEY -signature $TMPDIR/tmp.step4.1 $TMPDIR/tmp.step1
|
openssl dgst -sha256 -verify $SHA256KEY -signature $TMPDIR/tmp.step4.1 $TMPDIR/tmp.step1
|
||||||
# if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
# echo "! Err: failed to verify sha256 - highly likely $SIGKEY is wrong"
|
echo "! Warning: failed to verify sha256 - highly likely $SIGKEY is not an nofficial one. Ignore this and proceed."
|
||||||
# exit 0
|
# exit 0
|
||||||
# fi
|
fi
|
||||||
SIG_SIZE=$(wc -c < $TMPDIR/tmp.step4.1)
|
SIG_SIZE=$(wc -c < $TMPDIR/tmp.step4.1)
|
||||||
if [ $(((-(SIG_SIZE % 16)) % 16)) -gt 0 ]; then
|
if [ $(((-(SIG_SIZE % 16)) % 16)) -gt 0 ]; then
|
||||||
echo "! Err: not supported for SIG_SIZE not mutiple of 16"
|
echo "! Err: not supported for SIG_SIZE not mutiple of 16"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
# built-ins
|
# built-ins
|
||||||
import os
|
import os
|
||||||
|
import glob
|
||||||
import time
|
import time
|
||||||
import serial
|
import serial
|
||||||
import base64
|
import base64
|
||||||
|
|
@ -591,6 +592,8 @@ class DPT():
|
||||||
'''
|
'''
|
||||||
return the stored client key file paths
|
return the stored client key file paths
|
||||||
'''
|
'''
|
||||||
|
self.dbg_print("self.client_id_fp = {}".format(self.client_id_fp))
|
||||||
|
self.dbg_print("self.key_fp = {}".format(self.key_fp))
|
||||||
return self.client_id_fp, self.key_fp
|
return self.client_id_fp, self.key_fp
|
||||||
|
|
||||||
def set_client_key_fps(self, client_id_fp, key_fp):
|
def set_client_key_fps(self, client_id_fp, key_fp):
|
||||||
|
|
@ -627,8 +630,18 @@ class DPT():
|
||||||
tmp_dpa_path = "{}/.dpapp".format(home_path)
|
tmp_dpa_path = "{}/.dpapp".format(home_path)
|
||||||
if os.path.isdir(tmp_dpa_path):
|
if os.path.isdir(tmp_dpa_path):
|
||||||
dpa_path = tmp_dpa_path
|
dpa_path = tmp_dpa_path
|
||||||
tmp_client_fp = "{}/deviceid.dat".format(dpa_path)
|
self.dbg_print("dpa_path = {}".format(dpa_path))
|
||||||
tmp_key_fp = "{}/privatekey.dat".format(dpa_path)
|
# search for desired files
|
||||||
|
tmp_client_fp = tmp_key_fp = ''
|
||||||
|
level3files = glob.glob(dpa_path + '/*/*/*.dat')
|
||||||
|
level2files = glob.glob(dpa_path + '/*/*.dat')
|
||||||
|
level1files = glob.glob(dpa_path + '/*.dat')
|
||||||
|
for tmp_fp in level3files + level2files + level1files:
|
||||||
|
self.dbg_print("looking at: {}".format(tmp_fp))
|
||||||
|
if 'deviceid.dat' in tmp_fp:
|
||||||
|
tmp_client_fp = tmp_fp
|
||||||
|
elif 'privatekey.dat' in tmp_fp:
|
||||||
|
tmp_key_fp = tmp_fp
|
||||||
if os.path.isfile(tmp_client_fp) and os.path.isfile(tmp_key_fp):
|
if os.path.isfile(tmp_client_fp) and os.path.isfile(tmp_key_fp):
|
||||||
default_client_fp = tmp_client_fp
|
default_client_fp = tmp_client_fp
|
||||||
default_key_fp = tmp_key_fp
|
default_key_fp = tmp_key_fp
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue