Commit 1b0cf447 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

test/nvmf: remove default hash in format_interchange_psk()



Having "01" as the default is arbitrary and makes little sense.  Also,
while here, allow users to specify the hash without leading zeroes.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ifee3faff079315153747aad9ea982a8f0e2dd5f5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22022


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent 75883719
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -12,12 +12,12 @@ get_key() { bperf_cmd keyring_get_keys | jq ".[] | select(.name == \"$1\")"; }
get_refcnt() { get_key "$1" | jq -r '.refcnt'; }

prep_key() {
	local name key path
	local name key digest path

	name="$1" key="$2"
	path="${3-$(mktemp)}"
	name="$1" key="$2" digest="$3"
	path="${4-$(mktemp)}"

	format_interchange_psk "$key" > "$path"
	format_interchange_psk "$key" "$digest" > "$path"
	chmod 0600 "$path"

	echo "$path"
+3 −3
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ cleanup() {

trap cleanup EXIT

key0path=$(prep_key "key0" "$key0")
key1path=$(prep_key "key1" "$key1")
key0path=$(prep_key "key0" "$key0" 0)
key1path=$(prep_key "key1" "$key1" 0)

"$rootdir/build/bin/spdk_tgt" &
tgtpid=$!
@@ -89,7 +89,7 @@ NOT bperf_cmd bdev_nvme_attach_controller -b nvme0 -t tcp -a 127.0.0.1 -s 4420 -
bperf_cmd keyring_file_remove_key key0

# Remove the key while its in use
key0path=$(prep_key "key0" "$key0")
key0path=$(prep_key "key0" "$key0" 0)
bperf_cmd keyring_file_add_key key0 "$key0path"
bperf_cmd bdev_nvme_attach_controller -b nvme0 -t tcp -a 127.0.0.1 -s 4420 -f ipv4 \
	-n $subnqn -q $hostnqn --psk key0
+2 −2
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@ cleanup() {

trap cleanup EXIT

prep_key "key0" "$key0" "/tmp/:spdk-test:key0"
prep_key "key1" "$key1" "/tmp/:spdk-test:key1"
prep_key "key0" "$key0" 0 "/tmp/:spdk-test:key0"
prep_key "key1" "$key1" 0 "/tmp/:spdk-test:key1"

"$rootdir/build/bin/spdk_tgt" &
tgtpid=$!
+1 −1
Original line number Diff line number Diff line
@@ -690,7 +690,7 @@ clean_kernel_target() {
format_interchange_psk() {
	local key hash crc

	key=$1 hash=${2:-01}
	key=$1 hash=$(printf "%02x" $2)
	crc=$(echo -n $key | gzip -1 -c | tail -c8 | head -c 4)

	echo -n "NVMeTLSkey-1:$hash:$(base64 <(echo -n ${key}${crc})):"
+3 −3
Original line number Diff line number Diff line
@@ -115,8 +115,8 @@ if [[ "$ktls" != "false" ]]; then
	exit 1
fi

key=$(format_interchange_psk 00112233445566778899aabbccddeeff)
key_2=$(format_interchange_psk ffeeddccbbaa99887766554433221100)
key=$(format_interchange_psk 00112233445566778899aabbccddeeff 1)
key_2=$(format_interchange_psk ffeeddccbbaa99887766554433221100 1)

key_path=$(mktemp)
key_2_path=$(mktemp)
@@ -156,7 +156,7 @@ NOT run_bdevperf nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spdk:host1 ""

# Test #6 - check connectivity with bdevperf, but with 48 bytes long key
killprocess $nvmfpid
key_long=$(format_interchange_psk 00112233445566778899aabbccddeeff0011223344556677 02)
key_long=$(format_interchange_psk 00112233445566778899aabbccddeeff0011223344556677 2)
key_long_path=$(mktemp)
echo -n "$key_long" > $key_long_path
chmod 0600 $key_long_path