# HSM Setup and Configuration Runbook This runbook provides step-by-step procedures for configuring Hardware Security Module (HSM) integration with Stella Ops. ## Overview Stella Ops supports PKCS#11-compatible HSMs for cryptographic key storage and signing operations. This includes: - YubiHSM 2 - Thales Luna Network HSM - AWS CloudHSM - SoftHSM2 (development/testing) ## Prerequisites ### Hardware Requirements | Component | Requirement | |-----------|-------------| | HSM Device | PKCS#11 compatible | | Network | HSM accessible from Stella Ops services | | Backup | Secondary HSM for key backup | ### Software Requirements ```bash # PKCS#11 library for your HSM # Example for SoftHSM2 (development) apt-get install softhsm2 opensc # Verify installation softhsm2-util --version pkcs11-tool --version ``` ## SoftHSM2 Setup (Development) ### Step 1: Initialize SoftHSM ```bash # Create token directory mkdir -p /var/lib/softhsm/tokens chmod 700 /var/lib/softhsm/tokens # Initialize token softhsm2-util --init-token \ --slot 0 \ --label "StellaOps-Dev" \ --so-pin 12345678 \ --pin 87654321 # Verify token softhsm2-util --show-slots ``` ### Step 2: Generate Signing Key ```bash # Generate ECDSA P-256 key pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so \ --login --pin 87654321 \ --keypairgen \ --key-type EC:prime256v1 \ --id 01 \ --label "stellaops-signing-2026" # List keys pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so \ --login --pin 87654321 \ --list-objects ``` ### Step 3: Export Public Key ```bash # Export public key for distribution pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so \ --login --pin 87654321 \ --read-object \ --type pubkey \ --id 01 \ --output-file stellaops-signing-2026.pub.der # Convert to PEM openssl ec -pubin -inform DER \ -in stellaops-signing-2026.pub.der \ -outform PEM \ -out stellaops-signing-2026.pub.pem ``` ## YubiHSM 2 Setup ### Step 1: Install YubiHSM SDK ```bash # Download YubiHSM SDK wget https://developers.yubico.com/YubiHSM2/Releases/yubihsm2-sdk-2023.01-ubuntu2204-amd64.tar.gz tar xzf yubihsm2-sdk-*.tar.gz cd yubihsm2-sdk sudo ./install.sh # Start connector sudo systemctl enable yubihsm-connector sudo systemctl start yubihsm-connector ``` ### Step 2: Initialize YubiHSM ```bash # Connect to YubiHSM shell yubihsm-shell # Authenticate with default auth key connect session open 1 password # Create authentication key for Stella Ops generate authkey 0 100 "StellaOps-Auth" 1 generate-asymmetric-key:sign-ecdsa:delete-asymmetric-key # Generate signing key generate asymmetric 0 200 "StellaOps-Signing" 1 sign-ecdsa ecp256 # Export public key get public key 0 200 stellaops-yubihsm.pub session close 0 quit ``` ### Step 3: Configure PKCS#11 ```bash # Create PKCS#11 configuration cat > /etc/yubihsm_pkcs11.conf <