From 6b8b25a1deee13794ba612d7d6fabe6206d98b7c Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Thu, 7 Mar 2024 22:16:42 +0100 Subject: [PATCH] Fix handling of prefix type in login CLI Key index is the common case we want to support here: If the MSB is set, the low bits are interpreted as a 7 bit integer, which the server should interpret as the index of the key its supposed to use. --- cli/commands.c | 2 +- cli/test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/commands.c b/cli/commands.c index eabc9d3..cdd8f58 100644 --- a/cli/commands.c +++ b/cli/commands.c @@ -359,7 +359,7 @@ int login(int argc, char **argv) { fprintf(stderr, "handshake size is invalid in path %s\n", path); goto out; } - if ((handshake[0] & 0x80) != 0) { + if ((handshake[0] & 0x80) == 0) { fprintf(stderr, "only \"service-key-indicator\" prefix type is supported\n"); goto out; diff --git a/cli/test.sh b/cli/test.sh index a0152f9..9e03dad 100755 --- a/cli/test.sh +++ b/cli/test.sh @@ -69,7 +69,7 @@ for n in 1 2; do done key="$t/vector-2/a" -path="v2/R4cvQ1u4uJ0OOtYqouURB07hleHDnvaogAFBi-ZW48N2/myhost/exec=%2Fbin%2Fsh/" +path="v2/x4cvQ1u4uJ0OOtYqouURB07hleHDnvaogAFBi-ZW48N2/myhost/exec=%2Fbin%2Fsh/" expected_tag="ZmxczN4x3g4goXu-A2AuuEEVftgS6xM-6gYj-dRrlis=" tag=$("$binary" login --key "$key" "$path") if [ "$tag" != "$expected_tag" ]; then