Skip to content

Commit

Permalink
fix command wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Jan 4, 2024
1 parent b945ca1 commit ba7519d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test-real/test-libfido2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ oneTimeSetUp() {
export RDID=$(fido2-token -L | grep -Po '^(pcsc:|/dev).*(?=: )' | tail -n 1)
}

ToolHelper() {
ToolHelperRaw() {
# echo "CMD: $NON_TTY $*"
# echo "PIN is $PIN"
echo $PIN | $NON_TTY $* "$RDID" 2>"$TEST_TMP_DIR/stderr"
echo $PIN | $NON_TTY $* 2>"$TEST_TMP_DIR/stderr"
local res=$?
sed -i -E 's/Enter.*PIN for \S+ *//g' "$TEST_TMP_DIR/stderr"
cat "$TEST_TMP_DIR/stderr" 1>&2
return $res
}

ToolHelper() {
ToolHelperRaw $* "$RDID"
}

ToolHelperWithAlgo() {
algo=$1
shift
ToolHelperRaw $* "$RDID" $algo
}

FIDO2MakeCred() {
local rpid=$1
local username=$2
Expand All @@ -35,7 +46,7 @@ FIDO2MakeCred() {
echo "$rpid" >>"$TEST_TMP_DIR/cred_param"
echo "$username" >>"$TEST_TMP_DIR/cred_param"
echo "$userid" >>"$TEST_TMP_DIR/cred_param" # user id
ToolHelper fido2-cred -M -r -b -i "$TEST_TMP_DIR/cred_param" $algo >"$TEST_TMP_DIR/mc"
ToolHelperWithAlgo $algo fido2-cred -M -r -b -i "$TEST_TMP_DIR/cred_param" >"$TEST_TMP_DIR/mc"
assertTrue "fido2-cred -M failed" $?
local largeBlobKey=$(tail -n 1 "$TEST_TMP_DIR/mc")
head -n -1 "$TEST_TMP_DIR/mc" | fido2-cred -V -o "$TEST_TMP_DIR/verified" $algo
Expand All @@ -56,7 +67,7 @@ FIDO2GetAssert() {
openssl rand -base64 32 >"$TEST_TMP_DIR/assert_param" # client data hash
echo "$rpid" >>"$TEST_TMP_DIR/assert_param"
echo "$credid" >>"$TEST_TMP_DIR/assert_param"
ToolHelper fido2-assert -G -b -i "$TEST_TMP_DIR/assert_param" $algo >"$TEST_TMP_DIR/assert"
ToolHelperWithAlgo $algo fido2-assert -G -b -i "$TEST_TMP_DIR/assert_param" >"$TEST_TMP_DIR/assert"
assertTrue "fido2-assert -G failed" $?
local largeBlobKey=$(tail -n 1 "$TEST_TMP_DIR/assert")
echo $largeBlobKey
Expand Down

0 comments on commit ba7519d

Please sign in to comment.