mirror of
https://github.com/adulau/netbeacon.git
synced 2024-11-21 17:47:07 +00:00
PSK option added
This commit is contained in:
parent
785d3b66b1
commit
dba349091c
1 changed files with 7 additions and 1 deletions
|
@ -55,9 +55,15 @@ parser = OptionParser(usage)
|
||||||
#parser.add_option("-i","--id", dest="id", help="id of the netbeacon message processed")
|
#parser.add_option("-i","--id", dest="id", help="id of the netbeacon message processed")
|
||||||
parser.add_option("-t","--timedelta",dest="timedelta", action='store_true', help="show timedelta")
|
parser.add_option("-t","--timedelta",dest="timedelta", action='store_true', help="show timedelta")
|
||||||
parser.add_option("-s","--storeseq", dest="storeseq", action='store_true', help="store sequence and validate sequence")
|
parser.add_option("-s","--storeseq", dest="storeseq", action='store_true', help="store sequence and validate sequence")
|
||||||
|
parser.add_option("-p","--psk", dest="psk", help="pre-shared key used by the HMAC-SHA1 (default: netbeacon)")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
if options.psk:
|
||||||
|
psk = options.psk
|
||||||
|
else:
|
||||||
|
psk = "netbeacon"
|
||||||
|
|
||||||
if options.storeseq:
|
if options.storeseq:
|
||||||
import shelve
|
import shelve
|
||||||
s = shelve.open("netbeacon.seq")
|
s = shelve.open("netbeacon.seq")
|
||||||
|
@ -68,7 +74,7 @@ for line in sys.stdin:
|
||||||
m = nbparse(message=line)
|
m = nbparse(message=line)
|
||||||
print m['hmac']
|
print m['hmac']
|
||||||
message = m['header']+";"+str(m['epoch'])+";"+str(m['sequence'])+";"
|
message = m['header']+";"+str(m['epoch'])+";"+str(m['sequence'])+";"
|
||||||
if m['hmac'] == nbsign(message=message):
|
if m['hmac'] == nbsign(message=message, psk=psk):
|
||||||
print "valid signature for "+message
|
print "valid signature for "+message
|
||||||
if options.timedelta:
|
if options.timedelta:
|
||||||
timedelta = deltafromnow(epoch=m['epoch'])
|
timedelta = deltafromnow(epoch=m['epoch'])
|
||||||
|
|
Loading…
Reference in a new issue