Commit 3b3dbd7e authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

test/nvmf: use python for formatting TLS PSKs



The previous implementation was broken for crc32 values that had one of
its bytes set to zero.  Instead of trying to fix that, simply rewrite
this function in python, which fixes this issue and also makes it a lot
more readable.

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


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJohn Kariuki <John.Kariuki@amd.com>
parent 1b0cf447
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -688,12 +688,16 @@ clean_kernel_target() {
}

format_interchange_psk() {
	local key hash crc
	local key digest

	key=$1 hash=$(printf "%02x" $2)
	crc=$(echo -n $key | gzip -1 -c | tail -c8 | head -c 4)
	key="$1" digest="$2"
	python - <<- EOF
		import base64, zlib

	echo -n "NVMeTLSkey-1:$hash:$(base64 <(echo -n ${key}${crc})):"
		crc = zlib.crc32(b"$key").to_bytes(4, byteorder="little")
		b64 = base64.b64encode(b"$key" + crc).decode("utf-8")
		print("NVMeTLSkey-1:{:02x}:{}:".format($digest, b64), end="")
	EOF
}

get_main_ns_ip() {