configuring-hsm-for-key-storage

Configure HSMs via PKCS#11 for key generation, signing, and encryption.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill configuring-hsm-for-key-storage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configuring-hsm-for-key-storage
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/cryptography/configuring-hsm-for-key-storage
Command: npx skills add https://github.com/xalgord/xalgorix --skill configuring-hsm-for-key-storage

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cryptographic keys stored in software are vulnerable to theft and extraction. This Skill guides the configuration of Hardware Security Modules (HSMs) so that keys are generated, stored, and used inside a tamper-resistant device boundary where they can never be exported.

Core Features & Use Cases

  • PKCS#11 Key Management: Generate and manage AES, RSA, and EC keys directly inside the HSM using the standard PKCS#11 interface.
  • SoftHSM2 Development Setup: Configure SoftHSM2 as a software-based HSM provider for development and testing before deploying physical hardware.
  • HSM-Backed Operations: Perform signing, verification, encryption, and decryption with HSM-resident keys, including certificate authority operations and cloud HSM integration (AWS CloudHSM, Azure).
  • Use Case: A security engineer needs to protect a CA root key. Use this Skill to generate the key on-device with non-extractable attributes, enforce M-of-N quorum authentication, and verify that export attempts are rejected.

Quick Start

Set up SoftHSM2 and generate a non-extractable RSA key pair inside the HSM, then verify the key cannot be exported.

Frequently Asked Questions about configuring-hsm-for-key-storage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate keys inside an HSM using PKCS#11?

Use C_GenerateKeyPair through the PKCS#11 API so the key is created on-device and never exists in plaintext outside the HSM. Set CKA_EXTRACTABLE=False, CKA_SENSITIVE=True, and CKA_TOKEN=True, then confirm CKA_LOCAL=True to prove on-device generation.

What is SoftHSM2 and when should I use it?

SoftHSM2 is a software implementation of an HSM that speaks the PKCS#11 interface, intended for development and testing. Use it to build and validate HSM-integrated applications before deploying against physical FIPS-certified hardware in production.

How do I verify HSM keys cannot be exported?

Run pkcs11-tool --list-objects --type privkey and confirm the key shows Access: sensitive, always sensitive, never extractable. A sign/verify round-trip must succeed while any key-export attempt via C_GetAttributeValue or pkcs11-tool --read-object is rejected by the token.

Does this work with cloud HSM services like AWS CloudHSM?

Yes, the Skill covers interfacing with cloud HSM services including AWS CloudHSM and Azure. These services expose PKCS#11-compatible interfaces, so the same key generation and cryptographic operation patterns apply.

What FIPS 140-2 level do I need for my HSM?

Level 1 suits development, Level 2 adds tamper evidence and role-based authentication for general production, Level 3 provides tamper resistance and identity-based authentication for financial or government use, and Level 4 adds physical tamper response for classified environments.

Why is importing a software-generated key into an HSM a problem?

Importing means the plaintext key existed outside the HSM boundary, defeating its protection guarantees. Always generate keys on-device with C_GenerateKeyPair and verify CKA_LOCAL=True to confirm the key was created inside the HSM.