mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-19 04:57:55 +00:00
77949c9cff
Fix HOTP verfication failure if LK admin pin/passphrase contains spaces by quoting the variables when passed to functions. Test: set LK admin pin to passphrase with spaces, generate new TOTP/HOTP, verification passes. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
65 lines
2.2 KiB
Diff
65 lines
2.2 KiB
Diff
--- nitrokey-hotp-verification-a/Toolchain-heads.cmake 2018-05-22 09:55:46.907209235 -0700
|
|
+++ nitrokey-hotp-verification-b/Toolchain-heads.cmake 2018-05-22 09:55:26.659371966 -0700
|
|
@@ -0,0 +1,18 @@
|
|
+SET(CMAKE_SYSTEM_NAME Linux)
|
|
+SET(CMAKE_SYSTEM_VERSION 1)
|
|
+
|
|
+# Specify the cross compiler
|
|
+SET(CMAKE_C_COMPILER $ENV{INSTALL}/bin/musl-gcc)
|
|
+SET(CMAKE_CXX_COMPILER $ENV{INSTALL}/bin/musl-gcc)
|
|
+
|
|
+# Where is the target environment
|
|
+SET(CMAKE_FIND_ROOT_PATH $ENV{INSTALL})
|
|
+
|
|
+# Search for programs only in the build host directories
|
|
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
+
|
|
+# Search for libraries and headers only in the target directories
|
|
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
+
|
|
+INCLUDE_DIRECTORIES(hidapi)
|
|
--- libremkey-hotp-verification/device.c 2018-06-20 16:13:36.417804210 -0700
|
|
+++ libremkey-hotp-verification-b/device.c 2018-06-20 16:14:34.532367723 -0700
|
|
@@ -34,7 +34,7 @@
|
|
const unsigned short m_vid = 0x20a0;
|
|
const unsigned short m_pid = 0x4108;
|
|
|
|
-static const int CONNECTION_ATTEMPTS_COUNT = 80;
|
|
+static const int CONNECTION_ATTEMPTS_COUNT = 2;
|
|
|
|
static const int CONNECTION_ATTEMPT_DELAY_MICRO_SECONDS = 1000*1000/2;
|
|
|
|
--- libremkey-hotp-verification/libremkey_hotp_initialize
|
|
+++ libremkey-hotp-verification-b/libremkey_hotp_initialize
|
|
@@ -14,9 +14,9 @@ fi
|
|
PIN=$1
|
|
SECRET=$2
|
|
COUNTER=$3
|
|
-SECRET_B32=$(echo -n $SECRET | base32)
|
|
+SECRET_B32=$(cat $SECRET | base32)
|
|
|
|
-libremkey_hotp_verification set $SECRET_B32 $PIN
|
|
+libremkey_hotp_verification set $SECRET_B32 "$PIN"
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Setting HOTP secret on Librem Key failed!"
|
|
exit 1
|
|
@@ -25,7 +25,7 @@ fi
|
|
i=9
|
|
while [ "$i" -lt "$COUNTER" ]; do
|
|
echo "Updating counter to $i"
|
|
- HOTP_CODE=$(echo $SECRET | hotp $i)
|
|
+ HOTP_CODE=$(hotp $i < $SECRET)
|
|
libremkey_hotp_verification check $HOTP_CODE > /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "HOTP check failed for counter=$i, code=$HOTP_CODE"
|
|
@@ -34,7 +34,7 @@ while [ "$i" -lt "$COUNTER" ]; do
|
|
let "i += 10"
|
|
done
|
|
|
|
-HOTP_CODE=$(echo $SECRET | hotp $COUNTER)
|
|
+HOTP_CODE=$(hotp $COUNTER < $SECRET)
|
|
libremkey_hotp_verification check $HOTP_CODE > /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "HOTP check failed for counter=$COUNTER, code=$HOTP_CODE"
|