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
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.
18 # Copyright (c) 2017, Datto, Inc. All rights reserved.
19 # Copyright (c) 2019, DilOS
22 . $STF_SUITE/include/libtest.shlib
23 . $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib
24 . $STF_SUITE/tests/functional/cli_root/zfs_create/properties.kshlib
28 # 'zfs create' should create an encrypted dataset with a valid encryption
29 # algorithm, key format, key location, and key.
32 # 1. Create a filesystem for each combination of encryption type and key format
33 # 2. Verify that each filesystem has the correct properties set
36 verify_runnable "both"
40 datasetexists $TESTPOOL/$TESTFS1 && \
41 log_must zfs destroy -f $TESTPOOL/$TESTFS1
46 set -A ENCRYPTION_ALGS \
48 "encryption=aes-128-ccm" \
49 "encryption=aes-192-ccm" \
50 "encryption=aes-256-ccm" \
51 "encryption=aes-128-gcm" \
52 "encryption=aes-192-gcm" \
53 "encryption=aes-256-gcm"
55 set -A ENCRYPTION_PROPS \
56 "encryption=aes-256-gcm" \
57 "encryption=aes-128-ccm" \
58 "encryption=aes-192-ccm" \
59 "encryption=aes-256-ccm" \
60 "encryption=aes-128-gcm" \
61 "encryption=aes-192-gcm" \
62 "encryption=aes-256-gcm"
64 set -A KEYFORMATS "keyformat=raw" \
66 "keyformat=passphrase"
68 set -A USER_KEYS "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" \
69 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" \
72 log_assert "'zfs create' should create encrypted datasets using all" \
73 "combinations of supported properties"
76 while (( i < ${#ENCRYPTION_ALGS[*]} )); do
78 while (( j < ${#KEYFORMATS[*]} )); do
79 log_must eval "printf '%s' ${USER_KEYS[j]} | zfs create" \
80 "-o ${ENCRYPTION_ALGS[i]} -o ${KEYFORMATS[j]}" \
83 datasetexists $TESTPOOL/$TESTFS1 || \
84 log_fail "Failed to create dataset using" \
85 "${ENCRYPTION_ALGS[i]} and ${KEYFORMATS[j]}"
87 propertycheck $TESTPOOL/$TESTFS1 ${ENCRYPTION_PROPS[i]} || \
88 log_fail "failed to set ${ENCRYPTION_ALGS[i]}"
89 propertycheck $TESTPOOL/$TESTFS1 ${KEYFORMATS[j]} || \
90 log_fail "failed to set ${KEYFORMATS[j]}"
92 log_must zfs destroy -f $TESTPOOL/$TESTFS1
98 log_pass "'zfs create' creates encrypted datasets using all combinations of" \
99 "supported properties"