Commit 0d0701cb authored by Vojtech Myslivec's avatar Vojtech Myslivec 🚀

Add support to query mac-address

parent aa8db908
......@@ -29,6 +29,9 @@ USAGE="USAGE
$SCRIPTNAME serial-number
Print serial number of the device
$SCRIPTNAME mac-address
Print MAC address of the device
$SCRIPTNAME sign [file]
\"Sign\" given file or standard input if no file is given.
Signing on atsha-equipped device is realized via HMAC
......@@ -280,6 +283,11 @@ cached_atsha_serial() {
}
cached_atsha_mac() {
cached_command string 'mac' 'atsha204cmd' 'mac' '1'
}
# 64-bytes hex string from stdin
cached_atsha_challenge_response() {
local hash="$1"
......@@ -305,6 +313,11 @@ cached_otp_serial() {
}
cached_otp_mac() {
cached_command string 'mac' 'mox-otp' 'mac-address'
}
# 128-bytes hex string from stdin
cached_otp_sign_hash() {
local hash="$1"
......@@ -381,6 +394,26 @@ do_serial() {
}
do_mac() {
local device_type
cache_init
device_type=$(get_device_type)
if [ "$device_type" = "$TYPE_ATSHA" ]; then
debug "Call atsha mac"
cached_atsha_mac
elif [ "$device_type" = "$TYPE_OTP" ]; then
debug "Call otp mac-address"
cached_otp_mac
else
error "Unsupported device_type '$device_type'"
return 2
fi
}
do_sign() {
local file="$1"
local tmp=''
......@@ -478,6 +511,15 @@ main() {
fi
;;
'mac'|'mac-address')
if [ $# -eq 1 ]; then
do_mac
else
error 'Too many arguments for `mac-address` command'
return 1
fi
;;
'sign'|'file-challenge-response')
if [ $# -eq 1 ]; then
# sign the stdin
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment