xref: /spdk/test/keyring/common.sh (revision 1b0cf447842d86bdb2cd118b7f52d51423f5acb9)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2024 Intel Corporation.  All rights reserved.
3
4source "$rootdir/test/nvmf/common.sh"
5
6bperfsock="/var/tmp/bperf.sock"
7
8bperf_cmd() { "$rootdir/scripts/rpc.py" -s "$bperfsock" "$@"; }
9
10get_key() { bperf_cmd keyring_get_keys | jq ".[] | select(.name == \"$1\")"; }
11
12get_refcnt() { get_key "$1" | jq -r '.refcnt'; }
13
14prep_key() {
15	local name key digest path
16
17	name="$1" key="$2" digest="$3"
18	path="${4-$(mktemp)}"
19
20	format_interchange_psk "$key" "$digest" > "$path"
21	chmod 0600 "$path"
22
23	echo "$path"
24}
25