tools/testing/selftests/dm-verity/test-dm-verity-keyring.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/dm-verity/test-dm-verity-keyring.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/dm-verity/test-dm-verity-keyring.sh
Extension
.sh
Size
25396 bytes
Lines
874
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Test script for dm-verity keyring functionality
#
# This script has two modes depending on kernel configuration:
#
# 1. keyring_unsealed=1 AND require_signatures=1:
#    - Upload a test key to the .dm-verity keyring
#    - Seal the keyring
#    - Create a dm-verity device with a signed root hash
#    - Verify signature verification works
#
# 2. keyring_unsealed=0 (default) OR require_signatures=0:
#    - Verify the keyring is already sealed (if unsealed=0)
#    - Verify keys cannot be added to a sealed keyring
#    - Verify the keyring is inactive (not used for verification)
#
# Requirements:
# - Root privileges
# - openssl
# - veritysetup (cryptsetup)
# - keyctl (keyutils)

set -e

WORK_DIR=""
DATA_DEV=""
HASH_DEV=""
DM_NAME="verity-test-$$"
CLEANUP_DONE=0

# Module parameters (detected at runtime)
KEYRING_UNSEALED=""
REQUIRE_SIGNATURES=""

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

log_info() {
    echo -e "${GREEN}[INFO]${NC} $*"
}

log_warn() {
    echo -e "${YELLOW}[WARN]${NC} $*"
}

log_error() {
    echo -e "${RED}[ERROR]${NC} $*" >&2
}

log_pass() {
    echo -e "${GREEN}[PASS]${NC} $*"
}

log_fail() {
    echo -e "${RED}[FAIL]${NC} $*" >&2
}

log_skip() {
    echo -e "${YELLOW}[SKIP]${NC} $*"
}

cleanup() {
    if [ "$CLEANUP_DONE" -eq 1 ]; then
        return
    fi

Annotation

Implementation Notes