-
Notifications
You must be signed in to change notification settings - Fork 19
Add: Qualcomm User Data Encryption test script & Document #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
xbharani
commented
Aug 11, 2025
- Checks for fscryptctl binary presence
- Creates a random sw encryption key
- Applies and verifies encryption policy
- Confirms functionality with a test file
- Checks for fscryptctl binary presence - Creates a random sw encryption key - Applies and verifies encryption policy - Confirms functionality with a test file Signed-off-by: Bharani Bhuvanagiri <[email protected]>
log_info "=== Test Initialization ===" | ||
|
||
log_info "Checking if dependency binary is available" | ||
check_dependencies fscryptctl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root/user -> fscrypt operations usually require root. Add a quick root check and fail early if not root.
|
||
log_info "Checking if dependency binary is available" | ||
check_dependencies fscryptctl | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kernel/filesystem precheck: Add check_kernel_config
CONFIG_FS_ENCRYPTION
(and optional CONFIG_FS_VERITY
if you care) to SKIP gracefully on kernels without fscrypt. Also verify that the mount backing $MOUNT_DIR
is ext4/f2fs
with encryption support (or at least that add_key succeeds on that mountpoint).
check_dependencies fscryptctl | ||
|
||
KEY_FILE="/data/std_key" | ||
MOUNT_DIR="/mnt/testing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You add_key … /mnt but set policy on $MOUNT_DIR (/mnt/testing). That’s okay if $MOUNT_DIR is on the same filesystem, but brittle. Resolve the mountpoint of $MOUNT_DIR (its parent, typically /mnt) and use that consistently for add_key and key_status.
log_info "Checking if dependency binary is available" | ||
check_dependencies fscryptctl | ||
|
||
KEY_FILE="/data/std_key" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use mktemp
for the key path (instead of /data/std_key which may not exist), and set chmod 600
.
if ! mkdir -p "$MOUNT_DIR"; then | ||
log_fail "$TESTNAME : Failed to create mount directory" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
rm -f "$KEY_FILE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure the key file is always removed via a trap on exit.
if [ -z "$key_id" ]; then | ||
log_fail "$TESTNAME : Failed to add encryption key" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
rm -f "$KEY_FILE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can’t “unset” policy trivially, but you can remove the fs key (fscryptctl remove_key). Do that in cleanup so subsequent tests aren’t polluted.
|
||
# Step 3: Add the key to the filesystem | ||
log_info "Adding encryption key to the filesystem" | ||
key_id=$(/data/fscryptctl add_key /mnt < "$KEY_FILE" 2>/dev/null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You call /data/fscryptctl … directly. That will fail on Debian/Yocto where it’s /usr/bin/fscryptctl. Use a single variable (e.g., FSCRYPTCTL="${FSCRYPTCTL:-fscryptctl}") and always call "$FSCRYPTCTL".
|
||
# Step 4: Check key status | ||
log_info "Checking key status" | ||
status=$(/data/fscryptctl key_status "$key_id" / 2>/dev/null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT
|
||
# Step 5: Set encryption policy | ||
log_info "Setting encryption policy on $MOUNT_DIR" | ||
if ! /data/fscryptctl set_policy "$key_id" "$MOUNT_DIR"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT
|
||
# Step 6: Verify policy | ||
log_info "Verifying encryption policy" | ||
policy_output=$(/data/fscryptctl get_policy "$MOUNT_DIR" 2>/dev/null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT
Runner/ | ||
├── suites/ | ||
│ ├── Kernel/ | ||
│ │ ├── FunctionalArea/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This folder is no more available. Please correct the structure accordingly.