1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2017 Datto, Inc. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib 23 24# 25# DESCRIPTION: 26# 'zfs change-key -o' should change the pbkdf2 iterations. 27# 28# STRATEGY: 29# 1. Create an encryption dataset with 200k PBKDF2 iterations 30# 2. Unmount the dataset 31# 3. Change the PBKDF2 iterations to 150k 32# 4. Verify the PBKDF2 iterations 33# 5. Unload the dataset's key 34# 6. Attempt to load the dataset's key 35# 36 37verify_runnable "both" 38 39function verify_pbkdf2iters 40{ 41 typeset ds=$1 42 typeset iterations=$2 43 typeset iters=$(get_prop pbkdf2iters $ds) 44 45 if [[ "$iters" != "$iterations" ]]; then 46 log_fail "Expected $iterations iterations, got $iters" 47 fi 48 49 return 0 50} 51 52function cleanup 53{ 54 datasetexists $TESTPOOL/$TESTFS1 && \ 55 log_must zfs destroy -f $TESTPOOL/$TESTFS1 56} 57log_onexit cleanup 58 59log_assert "'zfs change-key -o' should change the pbkdf2 iterations" 60 61log_must eval "echo $PASSPHRASE > /$TESTPOOL/pkey" 62log_must zfs create -o encryption=on -o keyformat=passphrase \ 63 -o keylocation=file:///$TESTPOOL/pkey -o pbkdf2iters=200000 \ 64 $TESTPOOL/$TESTFS1 65 66log_must zfs unmount $TESTPOOL/$TESTFS1 67log_must verify_pbkdf2iters $TESTPOOL/$TESTFS1 "200000" 68 69log_must zfs change-key -o pbkdf2iters=150000 $TESTPOOL/$TESTFS1 70log_must verify_pbkdf2iters $TESTPOOL/$TESTFS1 "150000" 71 72log_must zfs unload-key $TESTPOOL/$TESTFS1 73log_must zfs load-key $TESTPOOL/$TESTFS1 74 75log_pass "'zfs change-key -o' changes the pbkdf2 iterations" 76