Craton HSM

Craton HSM FIPS 140-3 Security Policy and Certification Document

DISCLAIMER: Craton HSM is NOT FIPS 140-3 certified. This document describes the technical implementation of FIPS 140-3 Level 1 requirements. It has not been reviewed or validated by a CMVP-accredited laboratory. Do not rely on this software for FIPS compliance without independent certification.


Document Information

FieldValue
Module NameCraton HSM
Module Version0.9.1
Module TypeSoftware
FIPS 140-3 Overall Security Level1 (target, not certified)
PKCS#11 Compliancev3.0 (OASIS Standard)
Document Version1.1
Date2026-03-17
PurposeTechnical reference for FIPS 140-3 Level 1 requirements
AuthorCraton HSM Project

Revision History

VersionDateDescription
1.12026-03-17Security audit hardening: DRBG routing, per-key GCM counters, genuine KATs, RSA KAT, 46 conformance tests
1.02026-03-08Initial certification document

Acronyms and Abbreviations

AcronymDefinition
AESAdvanced Encryption Standard (FIPS 197)
APIApplication Programming Interface
CBCCipher Block Chaining (SP 800-38A)
CMVPCryptographic Module Validation Program
COCrypto Officer (PKCS#11 Security Officer role)
CSPCritical Security Parameter
CTRCounter mode (SP 800-38A)
DRBGDeterministic Random Bit Generator
ECDHElliptic Curve Diffie-Hellman (SP 800-56A)
ECDSAElliptic Curve Digital Signature Algorithm (FIPS 186-5)
GCMGalois/Counter Mode (SP 800-38D)
HMACHash-based Message Authentication Code (FIPS 198-1)
HSMHardware Security Module
KATKnown Answer Test
KDFKey Derivation Function
KEMKey Encapsulation Mechanism
ML-DSAModule-Lattice Digital Signature Algorithm (FIPS 204)
ML-KEMModule-Lattice Key Encapsulation Mechanism (FIPS 203)
OAEPOptimal Asymmetric Encryption Padding
PBKDF2Password-Based Key Derivation Function 2 (SP 800-132)
PKCSPublic-Key Cryptography Standards
POSTPower-On Self-Test
PQCPost-Quantum Cryptography
PSSProbabilistic Signature Scheme
RNGRandom Number Generator
RSARivest-Shamir-Adleman
SLH-DSAStateless Hash-based Digital Signature Algorithm (FIPS 205)
SOSecurity Officer (PKCS#11 Crypto Officer role)
SPSpecial Publication (NIST)
SSPSensitive Security Parameter

Normative References

ReferenceTitle
FIPS 140-3Security Requirements for Cryptographic Modules
ISO 19790:2012Security requirements for cryptographic modules
FIPS 180-4Secure Hash Standard (SHS)
FIPS 186-5Digital Signature Standard (DSS)
FIPS 197Advanced Encryption Standard (AES)
FIPS 198-1The Keyed-Hash Message Authentication Code (HMAC)
FIPS 202SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions
FIPS 203Module-Lattice-Based Key-Encapsulation Mechanism Standard
FIPS 204Module-Lattice-Based Digital Signature Standard
FIPS 205Stateless Hash-Based Digital Signature Standard
SP 800-38ARecommendation for Block Cipher Modes of Operation
SP 800-38DRecommendation for Block Cipher Modes of Operation: GCM
SP 800-38FRecommendation for Block Cipher Modes of Operation: Key Wrapping
SP 800-56ARecommendation for Pair-Wise Key-Establishment Schemes Using Discrete Logarithm Cryptography
SP 800-57 Part 1Recommendation for Key Management: General
SP 800-90A Rev.1Recommendation for Random Number Generation Using Deterministic Random Bit Generators
SP 800-90BRecommendation for the Entropy Sources Used for Random Bit Generation
SP 800-131A Rev.2Transitioning the Use of Cryptographic Algorithms and Key Lengths
SP 800-132Recommendation for Password-Based Key Derivation
PKCS#11 v3.0OASIS PKCS#11 Cryptographic Token Interface Base Specification

1. Cryptographic Module Specification

1.1 Module Identification

PropertyValue
Module NameCraton HSM
Version0.9.0
TypeSoftware module
LanguageRust (Edition 2021)
Output ArtifactShared library: libcraton_hsm.so (Linux), craton_hsm.dll (Windows), libcraton_hsm.dylib (macOS)
SourceCargo.toml line 5: name = "craton_hsm"

1.2 Security Level Claim

FIPS 140-3 AreaSecurity Level
1. Cryptographic Module Specification1
2. Cryptographic Module Interfaces1
3. Roles, Services, and Authentication1 (identity-based)
4. Software/Firmware Security1
5. Operational Environment1 (modifiable)
6. Physical SecurityN/A (software module)
7. Non-Invasive SecurityN/A
8. Sensitive Security Parameter Management1
9. Self-Tests1
10. Life-Cycle Assurance1
11. Mitigation of Other AttacksN/A
Overall1

1.3 Module Description

Craton HSM is a PKCS#11 v3.0-compliant software cryptographic module implemented entirely in the Rust programming language. The module provides cryptographic key management, digital signature, encryption, hashing, key derivation, and key wrapping services through the industry-standard PKCS#11 C API.

The module is compiled as a dynamically loadable shared library (cdylib) that applications load at runtime via dlopen (Unix) or LoadLibrary (Windows). All cryptographic operations, key storage, authentication, and self-tests are contained within the single shared library binary.

The module supports 41 cryptographic mechanisms including post-quantum algorithms (ML-DSA, ML-KEM, SLH-DSA) and offers dual cryptographic backends: RustCrypto (default, pure Rust) and aws-lc-rs (optional, FIPS 140-3 validated).

1.4 Module Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    CRYPTOGRAPHIC MODULE BOUNDARY                 │
│                                                                  │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              PKCS#11 C ABI Layer (68+ functions)          │   │
│  │              src/pkcs11_abi/functions.rs                   │   │
│  │       Input validation, catch_unwind, CK_RV mapping       │   │
│  └────────┬──────────┬──────────┬──────────┬────────────────┘   │
│           │          │          │          │                     │
│  ┌────────▼──┐ ┌─────▼─────┐ ┌─▼────────┐ ┌▼──────────────┐   │
│  │ SessionMgr│ │ ObjectStore│ │ AuditLog │ │  CryptoBackend│   │
│  │ DashMap   │ │ DashMap +  │ │ chained  │ │  trait (26    │   │
│  │ sessions  │ │ redb+AES  │ │ SHA-256   │ │  methods)     │   │
│  └───────────┘ └───────────┘ └──────────┘ └──────┬────────┘   │
│                      │                            │             │
│              ┌───────▼───────┐          ┌─────────▼─────────┐  │
│              │ RawKeyMaterial│          │  RustCryptoBackend │  │
│              │ mlock+zeroize │          │  --- OR ---        │  │
│              └───────────────┘          │  AwsLcBackend      │  │
│                                         │  (FIPS validated)  │  │
│  ┌──────────────────┐                  └────────────────────┘  │
│  │  HMAC_DRBG       │  ┌──────────────────┐                    │
│  │  SP 800-90A      │  │  POST/KAT Engine │                    │
│  │  (prediction     │  │  15 KATs +       │                    │
│  │   resistance)    │  │  integrity test   │                    │
│  └──────────────────┘  └──────────────────┘                    │
│                                                                  │
│                         HsmCore (src/core.rs)                   │
│                    OnceLock<Arc<HsmCore>> singleton              │
└─────────────────────────────────────────────────────────────────┘

1.5 Module Boundary

Components inside the cryptographic boundary:

ComponentSource PathDescription
PKCS#11 C ABIsrc/pkcs11_abi/68+ exported C functions, types, constants
Cryptographic algorithmssrc/crypto/Sign, encrypt, digest, keygen, PQC, DRBG
Self-testssrc/crypto/self_test.rs15 POST KATs + software integrity test
Pairwise consistencysrc/crypto/pairwise_test.rs7 conditional self-tests
Key material protectionsrc/store/key_material.rsRawKeyMaterial with mlock + zeroize
Object storagesrc/store/ObjectStore, EncryptedStore (redb + AES-256-GCM)
Session managementsrc/session/SessionManager, Session state machine
Token/PIN managementsrc/token/Token initialization, PIN hashing, login state
Audit loggingsrc/audit/Tamper-evident append-only log
Module coresrc/core.rsHsmCore coordinator struct
Error mappingsrc/error.rsHsmError enum to CK_RV conversion

Components outside the cryptographic boundary:

ComponentPathDescription
gRPC daemoncraton-hsm-daemon/Network transport layer
Admin CLItools/craton-hsm-admin/Command-line token management
Spy wrappertools/pkcs11-spy/Debug/logging interceptor
Deploymentdeploy/Dockerfile, Helm chart
Third-party cratesCargo.lockEvaluated separately for FIPS compliance

1.6 Modes of Operation

The module operates in one of two modes:

FIPS Approved Mode (configuration: fips_approved_only = true, crypto_backend = "awslc"):

  • Only FIPS-approved algorithms are available
  • Non-approved mechanisms return CKR_MECHANISM_INVALID
  • PQC mechanisms are blocked
  • Ed25519 is blocked
  • SHA-1 for signing is blocked
  • All operations are performed through the FIPS-validated aws-lc-rs backend
  • Source: src/crypto/mechanisms.rs:165 (is_fips_approved())

Non-Approved Mode (default configuration):

  • All 41 mechanisms are available including PQC and Ed25519
  • Algorithm indicator (IG 2.4.C) marks each operation as approved or non-approved
  • Uses the RustCrypto backend (not FIPS-validated)

2. Cryptographic Module Interfaces

2.1 Logical Interface Mapping

Per FIPS 140-3 §7.2, all module interfaces are mapped to the four logical interface types:

FIPS 140-3 InterfacePKCS#11 MappingDirection
Data InputPlaintext data in C_Encrypt, C_Sign, C_Digest, C_DigestUpdate; key material in C_CreateObject, C_UnwrapKey templates; PIN values in C_Login, C_InitPIN, C_SetPINInput
Data OutputCiphertext from C_Encrypt; signatures from C_Sign; digests from C_Digest; key material from C_GetAttributeValue; wrapped keys from C_WrapKey; random bytes from C_GenerateRandomOutput
Control InputC_Initialize, C_Finalize, C_InitToken, C_Login, C_Logout, C_OpenSession, C_CloseSession, mechanism selection in *Init functions, template attributes in C_GenerateKey/C_GenerateKeyPairInput
Status OutputCK_RV return codes from all functions; CK_INFO from C_GetInfo; CK_SLOT_INFO from C_GetSlotInfo; CK_TOKEN_INFO from C_GetTokenInfo; CK_SESSION_INFO from C_GetSessionInfo; CK_MECHANISM_INFO from C_GetMechanismInfoOutput

2.2 Exported API Functions

The module exports the following 68 C functions through C_GetFunctionList. All functions are #[no_mangle] pub extern "C" with catch_unwind to prevent panic propagation across the FFI boundary.

Source: src/pkcs11_abi/functions.rs

General-Purpose Functions:

FunctionInterfaceDescription
C_InitializeControlInitialize the module, run POST
C_FinalizeControlShut down the module
C_GetInfoStatusReturn library info (version, manufacturer)
C_GetFunctionListStatusReturn function pointer table

Slot and Token Management:

FunctionInterfaceDescription
C_GetSlotListStatusEnumerate available slots
C_GetSlotInfoStatusReturn slot description
C_GetTokenInfoStatusReturn token status and capabilities
C_GetMechanismListStatusEnumerate supported mechanisms
C_GetMechanismInfoStatusReturn mechanism capabilities
C_InitTokenControlInitialize/reinitialize the token (CO role)
C_InitPINControlSet user PIN (CO role)
C_SetPINControlChange PIN (CO or User role)

Session Management:

FunctionInterfaceDescription
C_OpenSessionControlOpen a new session (RO or RW)
C_CloseSessionControlClose a session
C_CloseAllSessionsControlClose all sessions on a slot
C_GetSessionInfoStatusReturn session state
C_LoginControlAuthenticate as CO or User
C_LogoutControlEnd authenticated session

Object Management:

FunctionInterfaceDescription
C_CreateObjectControl/DataImport a key or data object
C_CopyObjectControlDuplicate an object
C_DestroyObjectControlDestroy an object (zeroize key material)
C_GetObjectSizeStatusReturn approximate object size
C_GetAttributeValueData OutputRead object attributes
C_SetAttributeValueControlModify object attributes
C_FindObjectsInitControlBegin object search
C_FindObjectsData OutputReturn matching object handles
C_FindObjectsFinalControlEnd object search

Encryption/Decryption:

FunctionInterfaceDescription
C_EncryptInitControlInitialize encryption operation
C_EncryptData I/OSingle-part encryption
C_EncryptUpdateData I/OMulti-part encryption
C_EncryptFinalData OutputFinalize multi-part encryption
C_DecryptInitControlInitialize decryption operation
C_DecryptData I/OSingle-part decryption
C_DecryptUpdateData I/OMulti-part decryption
C_DecryptFinalData OutputFinalize multi-part decryption

Signing/Verification:

FunctionInterfaceDescription
C_SignInitControlInitialize signing operation
C_SignData I/OSingle-part signing
C_SignUpdateData InputMulti-part signing
C_SignFinalData OutputFinalize multi-part signing
C_VerifyInitControlInitialize verification operation
C_VerifyData I/OSingle-part verification
C_VerifyUpdateData InputMulti-part verification
C_VerifyFinalStatusFinalize multi-part verification

Message Digest:

FunctionInterfaceDescription
C_DigestInitControlInitialize digest operation
C_DigestData I/OSingle-part digest
C_DigestUpdateData InputMulti-part digest
C_DigestKeyData InputHash key material into digest
C_DigestFinalData OutputFinalize multi-part digest

Key Management:

FunctionInterfaceDescription
C_GenerateKeyControlGenerate symmetric key
C_GenerateKeyPairControlGenerate asymmetric key pair
C_WrapKeyData OutputExport key in wrapped form
C_UnwrapKeyData InputImport wrapped key
C_DeriveKeyControlDerive key from base key

Random Number Generation:

FunctionInterfaceDescription
C_SeedRandomControlAdd entropy (returns CKR_RANDOM_SEED_NOT_SUPPORTED)
C_GenerateRandomData OutputGenerate random bytes via HMAC_DRBG

Not Implemented (return CKR_FUNCTION_NOT_SUPPORTED):

C_GetOperationState, C_SetOperationState, C_SignRecoverInit, C_SignRecover, C_VerifyRecoverInit, C_VerifyRecover, C_DigestEncryptUpdate, C_DecryptDigestUpdate, C_SignEncryptUpdate, C_DecryptVerifyUpdate, C_GetFunctionStatus, C_CancelFunction, C_WaitForSlotEvent

2.3 Interface Separation

The module maintains strict separation between interface types:

  • Control inputs (PINs, mechanism selections) are never emitted as data outputs
  • Status outputs (CK_RV codes) do not leak internal state — error codes are generic per PKCS#11 specification
  • Data outputs (ciphertext, signatures, digests) flow only through designated output parameters
  • The error mapping at src/error.rs:104-157 converts internal HsmError variants to standardized CK_RV codes, preventing information leakage through error specificity

3. Roles, Services, and Authentication

3.1 Roles

The module implements three roles per the PKCS#11 specification:

RolePKCS#11 User TypeDescriptionAuthentication
Crypto Officer (CO)CKU_SO (0)Token initialization, user PIN managementPIN-based (PBKDF2-HMAC-SHA256)
UserCKU_USER (1)Cryptographic operations, object managementPIN-based (PBKDF2-HMAC-SHA256)
Unauthenticated(none)Limited services: digest, random, public infoNone

Source: src/session/session.rs:7-13 (SessionState enum), src/token/token.rs (login handling)

3.2 Services-to-Roles Mapping

The following table maps all module services to the roles authorized to access them, the CSPs accessed, and the FIPS approval status.

Token Management Services:

ServiceAPI FunctionCOUserUnauthCSP Access
Initialize tokenC_InitTokenYesNoNoSO PIN hash (output)
Initialize user PINC_InitPINYesNoNoUser PIN hash (output)
Change own PINC_SetPINYesYesNoPIN hash (input/output)
LoginC_LoginYesYesNoPIN hash (input)
LogoutC_LogoutYesYesNoNone

Symmetric Key Generation (Approved):

ServiceMechanismCOUserUnauthCSP Access
AES key generationCKM_AES_KEY_GENNoYesNoAES key (output), DRBG state (input)

Asymmetric Key Pair Generation:

ServiceMechanismCOUserUnauthFIPS ApprovedCSP Access
RSA keygenCKM_RSA_PKCS_KEY_PAIR_GENNoYesNoYesRSA private key (output), DRBG state
EC P-256/P-384 keygenCKM_EC_KEY_PAIR_GENNoYesNoYesEC private key (output), DRBG state
Ed25519 keygenCKM_EDDSANoYesNoNoEd25519 key (output), DRBG state
ML-DSA keygenCKM_ML_DSA_44/65/87NoYesNoNoML-DSA key (output), DRBG state
ML-KEM keygenCKM_ML_KEM_512/768/1024NoYesNoNoML-KEM key (output), DRBG state
SLH-DSA keygenCKM_SLH_DSA_SHA2_128S/256SNoYesNoNoSLH-DSA key (output), DRBG state

Digital Signature Services:

ServiceMechanismFIPS ApprovedCSP Access
RSA PKCS#1 v1.5 signCKM_RSA_PKCSYesRSA private key (input)
RSA PKCS#1 v1.5 sign (hashed)CKM_SHA256/384/512_RSA_PKCSYesRSA private key (input)
RSA-PSS signCKM_RSA_PKCS_PSSYesRSA private key (input)
RSA-PSS sign (hashed)CKM_SHA256/384/512_RSA_PKCS_PSSYesRSA private key (input)
ECDSA signCKM_ECDSAYesEC private key (input)
ECDSA sign (hashed)CKM_ECDSA_SHA256/384/512YesEC private key (input)
Ed25519 signCKM_EDDSANoEd25519 private key (input)
ML-DSA signCKM_ML_DSA_44/65/87NoML-DSA private key (input)
SLH-DSA signCKM_SLH_DSA_SHA2_128S/256SNoSLH-DSA private key (input)

All signing services require User authentication. Corresponding verify services use public key components and also require User authentication.

Encryption/Decryption Services:

ServiceMechanismFIPS ApprovedCSP Access
AES-GCM encrypt/decryptCKM_AES_GCMYesAES key (input)
AES-CBC encrypt/decryptCKM_AES_CBC / CKM_AES_CBC_PADYesAES key (input)
AES-CTR encrypt/decryptCKM_AES_CTRYesAES key (input)
RSA-OAEP encrypt/decryptCKM_RSA_PKCS_OAEPYesRSA key (input)

All encryption/decryption services require User authentication.

Key Wrapping/Unwrapping Services:

ServiceMechanismFIPS ApprovedCSP Access
AES Key WrapCKM_AES_KEY_WRAPYesWrapping key (input), target key (input)
AES Key Wrap with PaddingCKM_AES_KEY_WRAP_KWPYesWrapping key (input), target key (input)

Key Derivation Services:

ServiceMechanismFIPS ApprovedCSP Access
ECDH P-256 deriveCKM_ECDH1_DERIVEYesEC private key (input), derived key (output)
ECDH P-384 deriveCKM_ECDH1_DERIVEYesEC private key (input), derived key (output)
ECDH cofactor deriveCKM_ECDH1_COFACTOR_DERIVEYesEC private key (input), derived key (output)

Digest Services (No CSP access):

ServiceMechanismFIPS Approved
SHA-1 digestCKM_SHA_1Yes (digest only, not for signing)
SHA-256 digestCKM_SHA256Yes
SHA-384 digestCKM_SHA384Yes
SHA-512 digestCKM_SHA512Yes
SHA3-256 digestCKM_SHA3_256Yes
SHA3-384 digestCKM_SHA3_384Yes
SHA3-512 digestCKM_SHA3_512Yes

Digest services are available to all roles including unauthenticated.

Random Number Generation:

ServiceAPI FunctionFIPS ApprovedCSP Access
Generate randomC_GenerateRandomYesDRBG state (input/output)

Available to User and unauthenticated roles.

Object Management Services:

ServiceAPI FunctionCOUserUnauth
Create objectC_CreateObjectYes (RW)Yes (RW)No
Copy objectC_CopyObjectYes (RW)Yes (RW)No
Destroy objectC_DestroyObjectYes (RW)Yes (RW)No
Get attributesC_GetAttributeValueYesYesPublic objects only
Set attributesC_SetAttributeValueYes (RW)Yes (RW)No
Find objectsC_FindObjects*YesYesPublic objects only
Get object sizeC_GetObjectSizeYesYesNo

3.3 Authentication Mechanism

Algorithm: PBKDF2-HMAC-SHA256 (SP 800-132)

ParameterValueSource
PRFHMAC-SHA256src/store/encrypted_store.rs
Iteration count600,000Configurable via security.pbkdf2_iterations
Salt length32 bytes (random, per-token)Generated via OsRng
Derived key length32 bytesUsed for PIN hash comparison
PIN length4-64 bytesConfigurable via security.pin_min_length, security.pin_max_length

Comparison: Constant-time via subtle::ConstantTimeEq to prevent timing side-channel attacks.

Brute-Force Protection:

ParameterValue
Max failed SO login attempts10 (configurable)
Max failed User login attempts10 (configurable)
Lockout behaviorReturns CKR_PIN_LOCKED (0xA4)
Lockout recoverySO resets User PIN via C_InitPIN

Source: src/token/token.rs (login state, failed attempt counters)

3.4 Authentication Strength

With a minimum 4-character PIN (assuming alphanumeric, 62 possible characters):

  • PIN space: 62^4 = 14,776,336 possible PINs
  • PBKDF2 cost: 600,000 iterations per guess
  • Online brute-force cost: 14,776,336 × 600,000 = ~8.9 × 10^12 HMAC-SHA256 operations
  • Online defense: 10-attempt lockout makes online brute-force infeasible

With the recommended 8-character PIN:

  • PIN space: 62^8 = 2.18 × 10^14 possible PINs

4. Software/Firmware Security

4.1 Approved Integrity Technique

The module implements a software integrity test per FIPS 140-3 §9.4 using HMAC-SHA256.

Implementation: src/crypto/integrity.rs

ComponentValue
AlgorithmHMAC-SHA256 (FIPS 198-1)
HMAC key32-byte compile-time constant embedded in binary (per FIPS IG 9.7)
Key valueb"Craton HSM-FIPS-Integrity-Key-v1.0!" (integrity.rs:23)
Expected digestStored in .hmac sidecar file (64 hex characters)
ExecutionFirst test in run_post(), before any algorithm KATs

Module Path Discovery:

  • Unix: dladdr() on function pointer address (integrity.rs:141-156)
  • Windows: GetModuleHandleExW() + GetModuleFileNameW() (integrity.rs:159-197)

Behavior Matrix:

ConditionBehavior
No .hmac sidecar fileWarning logged, test passes (development mode)
.hmac present, HMAC matchesTest passes, module proceeds to KATs
.hmac present, HMAC mismatchTest fails, POST_FAILED set, module enters error state
Module path cannot be determinedWarning logged, test passes

Integrity Tool: tools/compute-integrity-hmac.sh and .ps1 compute the .hmac sidecar file from the compiled binary for production deployment.

4.2 Executable Code Integrity

  • The module contains no dynamically loaded code at runtime
  • No self-modifying code is present
  • All cryptographic functions are statically compiled into the shared library
  • The crate-type = ["cdylib", "rlib"] configuration (Cargo.toml:12) produces a single artifact

5. Operational Environment

5.1 Operating Environment Type

The module operates in a modifiable operational environment (general-purpose operating system). Per FIPS 140-3, a single operator is assumed per instantiation of the module.

5.2 Tested Platforms

Operating SystemArchitectureRust Target TripleStatus
Windows 11 Pro 10.0.26200x86_64x86_64-pc-windows-msvcPrimary development/test platform
Linux (glibc 2.31+)x86_64x86_64-unknown-linux-gnuCI tested
Linux (musl)x86_64x86_64-unknown-linux-muslExpected compatible
macOS (Intel)x86_64x86_64-apple-darwinExpected compatible
macOS (Apple Silicon)aarch64aarch64-apple-darwinExpected compatible

5.3 Platform-Specific Security Features

FeatureLinuxWindowsmacOS
Memory lockingmlock(2) / munlock(2)VirtualLock / VirtualUnlockmlock(2) / munlock(2)
Fork detectionPID comparison via getpid()N/A (CreateProcess is isolated)PID comparison via getpid()
File lockingflock(2) via fs2 crateLockFileEx via fs2 crateflock(2) via fs2 crate
Entropy sourcegetrandom(2)BCryptGenRandomSecRandomCopyBytes

5.4 Build Requirements for FIPS Mode

DependencyVersionPurpose
Rust toolchain1.75+Compilation
CMake3.x+aws-lc-rs build system
Clang/LLVMLatestaws-lc-rs C compilation
Go1.18+aws-lc-rs build tool

6. Physical Security

Not applicable. Craton HSM is a software cryptographic module. The cryptographic boundary is the process address space of the running application. FIPS 140-3 Level 1 does not impose physical security requirements on software modules.


7. Non-Invasive Security

Not applicable. FIPS 140-3 Level 1 does not require non-invasive security mechanisms.


8. Sensitive Security Parameter Management

8.1 CSP Inventory

The following table enumerates all Critical Security Parameters (CSPs) managed by the module:

#CSPTypeSizeStorageGenerationZeroization
1AES-256 symmetric keySymmetric32 bytesRawKeyMaterialHMAC_DRBG (SP 800-90A)zeroize() then munlock()
2AES-192 symmetric keySymmetric24 bytesRawKeyMaterialHMAC_DRBGzeroize() then munlock()
3AES-128 symmetric keySymmetric16 bytesRawKeyMaterialHMAC_DRBGzeroize() then munlock()
4RSA private keyAsymmetricVariable (PKCS#8 DER)RawKeyMaterialHMAC_DRBGzeroize() then munlock()
5ECDSA P-256 private keyAsymmetric32 bytesRawKeyMaterialHMAC_DRBGzeroize() then munlock()
6ECDSA P-384 private keyAsymmetric48 bytesRawKeyMaterialHMAC_DRBGzeroize() then munlock()
7Ed25519 private keyAsymmetric32 bytesRawKeyMaterialHMAC_DRBGzeroize() then munlock()
8ML-DSA signing keyPQCVariableRawKeyMaterialHMAC_DRBGzeroize() then munlock()
9ML-KEM decapsulation keyPQCVariableRawKeyMaterialHMAC_DRBGzeroize() then munlock()
10SLH-DSA signing keyPQCVariableRawKeyMaterialHMAC_DRBGzeroize() then munlock()
11HMAC keySymmetricVariableRawKeyMaterialHMAC_DRBGzeroize() then munlock()
12SO PIN hashAuthentication64 bytes (32 salt + 32 hash)Token struct (Zeroizing<Vec<u8>>)PBKDF2-HMAC-SHA256Zeroizing drop
13User PIN hashAuthentication64 bytes (32 salt + 32 hash)Token struct (Zeroizing<Vec<u8>>)PBKDF2-HMAC-SHA256Zeroizing drop
14Storage encryption keySymmetric32 bytesObjectStore (Mutex)PBKDF2 from SO PINCleared on logout/reinit
15HMAC_DRBG K (key)DRBG internal32 bytesHmacDrbg structSP 800-90A instantiate#[zeroize(drop)]
16HMAC_DRBG V (value)DRBG internal32 bytesHmacDrbg structSP 800-90A instantiate#[zeroize(drop)]
17DRBG last_outputHealth test32 bytesHmacDrbg structDRBG generate#[zeroize(drop)]
18Integrity HMAC keyCompile-time32 bytesBinary constantCompile-timeN/A (constant, not secret)
19Intermediate plaintextTransientVariableActiveOperation.dataDuring multi-part opsZeroizing<Vec<u8>> drop
20Mechanism parametersTransientVariableActiveOperation.mechanism_paramDuring operation initZeroizing<Vec<u8>> drop
21ECDH shared secretDerived32 or 48 bytesRawKeyMaterialECDH derivationzeroize() then munlock()
22AES-GCM noncesEphemeral12 bytesStackOsRngStack deallocation
23PBKDF2 saltPublic parameter32 bytesStored alongside PIN hashOsRngN/A (not secret)

Source: CSPs #1-11 stored in src/store/key_material.rs:10 (RawKeyMaterial); #12-13 in src/token/token.rs; #15-17 in src/crypto/drbg.rs:33-44; #19-20 in src/session/session.rs:39-71

8.2 CSP Generation

All cryptographic keys are generated using the module's HMAC_DRBG (SP 800-90A Rev.1):

DRBG PropertyValueSource
AlgorithmHMAC_DRBG with HMAC-SHA256src/crypto/drbg.rs:22
Entropy sourceOS CSPRNG (OsRng → getrandom(2) / BCryptGenRandom)drbg.rs:76
Seed material32 bytes entropy + 16 bytes noncedrbg.rs:74-78
Prediction resistanceEnabled (reseeds from OS on every generate())drbg.rs:29-31
Reseed interval2^48 (per SP 800-90A Table 2)drbg.rs:25
Continuous health testConsecutive output comparison (SP 800-90B §4.9)drbg.rs:42-44
State zeroization#[derive(ZeroizeOnDrop)] on K, V, last_outputdrbg.rs:32-36

PIN hashes are generated using PBKDF2-HMAC-SHA256 with 600,000 iterations and a 32-byte random salt.

8.3 CSP Entry and Establishment

Entry MethodAPICSPs Affected
Key importC_CreateObject with CKA_VALUEAll key types (#1-11)
Key unwrappingC_UnwrapKey with CKM_AES_KEY_WRAPSymmetric keys (#1-3, 11)
PIN entryC_Login, C_InitToken, C_InitPIN, C_SetPINPIN hashes (#12-13)
DRBG seedingHmacDrbg::new() at C_InitializeDRBG state (#15-17)
Key derivationC_DeriveKey with CKM_ECDH1_DERIVEECDH shared secret (#21)

PIN values are transmitted as plaintext over the PKCS#11 API and immediately hashed via PBKDF2. The plaintext PIN is not stored.

8.4 CSP Output

Output MethodAPICSPs AffectedConditions
Key exportC_GetAttributeValue(CKA_VALUE)Keys #1-11CKA_EXTRACTABLE = true AND CKA_SENSITIVE = false
Key wrappingC_WrapKeyKeys #1-3, 11CKA_EXTRACTABLE = true on target key
Random bytesC_GenerateRandomDRBG state #15-17 (consumed, not output)Always available

The following CSPs are never output through any API:

  • PIN hashes (#12-13)
  • Storage encryption key (#14)
  • DRBG internal state (#15-17)
  • Integrity HMAC key (#18)
  • Intermediate plaintext (#19-20)

8.5 CSP Storage

In-Memory Storage:

All key material is stored in RawKeyMaterial (src/store/key_material.rs:10), which provides:

  1. Memory locking on allocation: mlock() (Unix) or VirtualLock() (Windows) prevents the OS from paging key material to swap/disk. Source: key_material.rs:14-18
  2. Zeroization on deallocation: self.0.zeroize() overwrites all bytes with 0x00 before munlock(). Source: key_material.rs:42-50
  3. Debug redaction: Custom Debug impl displays [REDACTED] instead of key bytes. Source: key_material.rs:54-61
  4. Clone re-locking: Cloned key material is independently mlock'd. Source: key_material.rs:35-39

Persistent Storage (Optional):

When configured with storage_path, objects are persisted using:

  • Database: redb (embedded key-value store)
  • Encryption: Per-object AES-256-GCM encryption
  • Key derivation: Storage key derived from SO PIN via PBKDF2
  • File locking: fs2::FileExt::try_lock_exclusive() prevents concurrent access
  • Source: src/store/encrypted_store.rs

8.6 CSP Zeroization

All CSPs are zeroized when no longer needed. The zeroization lifecycle for key material:

RawKeyMaterial::new(data)
    │
    ├── mlock_buffer(ptr, len)          ← Lock pages in physical memory
    │
    ▼
[Active use: sign, encrypt, wrap, etc.]
    │
    ▼
RawKeyMaterial::drop()
    │
    ├── self.0.zeroize()                ← Overwrite all bytes with 0x00
    │
    ├── munlock_buffer(ptr, len)        ← Unlock (now-zeroed) pages
    │
    └── Vec<u8> deallocated             ← Rust allocator frees memory

Source: src/store/key_material.rs:42-50

Zeroization for other CSP types:

CSPZeroization Mechanism
PIN hashesZeroizing<Vec<u8>> (auto-zeroed on drop)
DRBG K, V, last_output#[derive(ZeroizeOnDrop)] on struct fields
Intermediate plaintextZeroizing<Vec<u8>> in ActiveOperation variants
Mechanism parametersZeroizing<Vec<u8>> in ActiveOperation variants
Storage encryption keyExplicit clear_persist_key() on logout/reinit

Zeroization Verification: 7 tests in tests/zeroization.rs verify that key material is cleared after drop (run in debug mode, require --ignored flag).

8.7 Key Lifecycle (SP 800-57)

The module implements SP 800-57 key lifecycle states with date-based transitions:

Source: src/store/object.rs (KeyLifecycleState enum, effective_lifecycle_state())

StateConditionPermitted Operations
Pre-ActivationCurrent date < CKA_START_DATENone
ActiveCKA_START_DATE ≤ current date ≤ CKA_END_DATE (or no dates set)All: sign, verify, encrypt, decrypt, wrap, unwrap, derive
DeactivatedCurrent date > CKA_END_DATEVerify, decrypt, unwrap only
CompromisedManually setNone
DestroyedAfter C_DestroyObjectHandle invalid (CKR_OBJECT_HANDLE_INVALID)

State Transition Diagram:

                    ┌───────────────┐
     Key Created →  │ Pre-Activation│
                    └──────┬────────┘
                           │ CKA_START_DATE reached
                    ┌──────▼────────┐
                    │    Active     │
                    └──┬─────┬──┬──┘
     CKA_END_DATE     │     │  │ Manual compromise
        passed         │     │  │
                ┌──────▼──┐  │  ┌▼───────────┐
                │Deactivated│  │  │ Compromised│
                └──────┬──┘  │  └─────┬──────┘
                       │     │        │
           C_DestroyObject   │  C_DestroyObject
                       │     │        │
                    ┌──▼─────▼────────▼──┐
                    │     Destroyed       │
                    └────────────────────┘

9. Self-Tests

9.1 Power-On Self-Tests (POST)

POST runs automatically during C_Initialize before any cryptographic service is available. All tests must pass; failure of any test sets POST_FAILED: AtomicBool (src/pkcs11_abi/functions.rs:62) and all subsequent operations return CKR_GENERAL_ERROR.

Source: src/crypto/self_test.rs:19-57 (run_post())

9.1.1 Software Integrity Test (§9.4)

PropertyValue
AlgorithmHMAC-SHA256
Execution orderFirst (before any KATs)
Sourceintegrity.rs:34 (check_integrity())

See Section 4.1 for full details.

9.1.2 Known Answer Tests

#AlgorithmTest TypeTest Vector SourceSource FunctionLine
1SHA-256Known answerNIST FIPS 180-4 ("abc")post_sha256_kat()64
2SHA-384Known answer (prefix)NIST FIPS 180-4 ("abc")post_sha384_kat()80
3SHA-512Known answer (prefix)NIST FIPS 180-4 ("abc")post_sha512_kat()94
4SHA3-256Known answerNIST FIPS 202 ("abc")post_sha3_256_kat()108
5HMAC-SHA256Known answerRFC 4231 Test Case 2post_hmac_sha256_kat()129
6HMAC-SHA384Known answer (prefix)RFC 4231 Test Case 2post_hmac_sha384_kat()153
7HMAC-SHA512Known answer (prefix)RFC 4231 Test Case 2post_hmac_sha512_kat()177
8AES-256-GCMEncrypt/decrypt roundtripFixed key (0x42×32)post_aes_gcm_kat()206
9AES-256-CBCEncrypt/decrypt roundtripFixed key (0x55×32), IV (0xAA×16)post_aes_cbc_kat()220
10AES-256-CTREncrypt/decrypt roundtripFixed key (0x77×32), IV (0xBB×16)post_aes_ctr_kat()235
11ECDSA P-256Sign/verify roundtripGenerated key pairpost_ecdsa_p256_kat()255
12ML-DSA-44Sign/verify roundtripGenerated key pairpost_ml_dsa_kat()272
13ML-KEM-768Encap/decap roundtripGenerated key pairpost_ml_kem_kat()285

9.1.3 RNG Health Tests

#TestDescriptionSource
14OS RNG healthGenerate 256 bytes, verify not all zeros/identical; generate second 256 bytes, verify differs from first (SP 800-90B §4.3)post_rng_health() line 306
15HMAC_DRBG healthInstantiate DRBG, generate two 32-byte outputs, verify not all zeros and consecutive outputs differpost_drbg_health() line 334

9.2 Conditional Self-Tests (§9.6)

9.2.1 Pairwise Consistency Tests

Executed immediately after every asymmetric key pair generation. Source: src/crypto/pairwise_test.rs

Key TypeTestAlgorithmTriggerSource FunctionLine
RSASign/verifySHA-256 RSA PKCS#1v15C_GenerateKeyPair(CKM_RSA_PKCS_KEY_PAIR_GEN)rsa_pairwise_test()16
ECDSA P-256Sign/verifyECDSA P-256C_GenerateKeyPair(CKM_EC_KEY_PAIR_GEN, P-256)ecdsa_p256_pairwise_test()54
ECDSA P-384Sign/verifyECDSA P-384C_GenerateKeyPair(CKM_EC_KEY_PAIR_GEN, P-384)ecdsa_p384_pairwise_test()86
Ed25519Sign/verifyEd25519C_GenerateKeyPair(CKM_EDDSA)ed25519_pairwise_test()118
ML-DSASign/verifyML-DSA-44/65/87C_GenerateKeyPair(CKM_ML_DSA_*)ml_dsa_pairwise_test()150
SLH-DSASign/verifySLH-DSA-SHA2-128s/256sC_GenerateKeyPair(CKM_SLH_DSA_*)slh_dsa_pairwise_test()186
ML-KEMEncap/decapML-KEM-512/768/1024C_GenerateKeyPair(CKM_ML_KEM_*)ml_kem_pairwise_test()221

Test data: b"FIPS 140-3 pairwise consistency test" (pairwise_test.rs:13)

9.2.2 Continuous Random Number Tests

TestTriggerAlgorithmSource
Continuous RNGEvery C_GenerateRandom callCompare consecutive 256-byte OS RNG outputsfunctions.rs (C_GenerateRandom)
Continuous DRBGEvery HmacDrbg::generate() callCompare consecutive 32-byte DRBG outputsdrbg.rs:42-44 (last_output comparison)

9.3 POST Failure Behavior

When any POST or conditional test fails:

  1. POST_FAILED (AtomicBool) is set to true (functions.rs:62)
  2. The get_hsm() function checks this flag on every subsequent PKCS#11 call (functions.rs:83)
  3. All operations return CKR_GENERAL_ERROR (0x00000005)
  4. The module cannot recover without process restart
  5. No cryptographic services are available in the error state

10. Life-Cycle Assurance

10.1 Configuration Management

AspectTool/Process
Source controlGit
Dependency pinningCargo.lock committed to repository
Dependency vettingcargo audit (CVE check), cargo deny (license + advisory compliance)
License policydeny.toml configuration
CI pipelineGitHub Actions (build, test, lint, security audit, Miri)
Undefined behavior detectioncargo +nightly miri test in CI

10.2 Module Design

Central Coordinator: HsmCore (src/core.rs:18-29)

pub struct HsmCore {
    pub slot_manager: SlotManager,
    pub session_manager: SessionManager,
    pub object_store: ObjectStore,
    pub audit_log: AuditLog,
    pub crypto_backend: Arc<dyn CryptoBackend>,
    pub drbg: parking_lot::Mutex<HmacDrbg>,
    pub algorithm_config: AlgorithmConfig,
}

Backend Abstraction: CryptoBackend trait (src/crypto/backend.rs) defines 26 methods covering all cryptographic operations. Two implementations:

  1. RustCryptoBackend (src/crypto/rustcrypto_backend.rs) — default, pure Rust
  2. AwsLcBackend (src/crypto/awslc_backend.rs) — optional, FIPS 140-3 validated

Backend selection is configuration-driven (algorithms.crypto_backend in craton_hsm.toml) and resolved at C_Initialize time.

10.3 Finite State Model

Module-Level States

┌──────────┐    C_Initialize     ┌──────────────┐
│ Power Off├────────────────────►│ POST Running │
└──────────┘                     └──────┬───────┘
                                        │
                        ┌───────────────┼───────────────┐
                        │ All tests pass│               │ Any test fails
                        ▼               │               ▼
                ┌───────────────┐       │       ┌──────────────┐
                │  Initialized  │       │       │  Error State │
                │  (Ready)      │       │       │  POST_FAILED │
                └───────┬───────┘       │       └──────────────┘
                        │               │       All ops return
                   C_Login              │       CKR_GENERAL_ERROR
                        ▼               │
                ┌───────────────┐       │
                │ Authenticated │       │
                │ (CO or User)  │       │
                └───────┬───────┘       │
                        │               │
                   C_Logout             │
                        │               │
                        ▼               │
                  Initialized ◄─────────┘
                        │
                   C_Finalize
                        ▼
                   Power Off

Session-Level States (PKCS#11)

    C_OpenSession(RO)               C_OpenSession(RW)
          │                               │
          ▼                               ▼
    ┌───────────┐                   ┌───────────┐
    │ RO Public │                   │ RW Public │
    │ (CKS=0)   │                   │ (CKS=2)   │
    └─────┬─────┘                   └──┬─────┬──┘
          │                            │     │
   C_Login│(User)            C_Login   │     │ C_Login
          │                 (User)     │     │ (SO)
          ▼                            ▼     ▼
    ┌───────────┐                ┌──────────┐ ┌────────┐
    │ RO User   │                │ RW User  │ │ RW SO  │
    │ (CKS=1)   │                │ (CKS=3)  │ │ (CKS=4)│
    └─────┬─────┘                └────┬─────┘ └───┬────┘
          │                           │            │
   C_Logout                    C_Logout     C_Logout
          │                           │            │
          ▼                           ▼            ▼
    RO Public                   RW Public    RW Public

Source: src/session/session.rs:7-13 (enum), lines 140-173 (transitions)

10.4 Development Environment

AspectValue
LanguageRust (Edition 2021)
Compilerrustc 1.75+ (MSRV), tested with 1.83+
Build systemCargo
Unsafe code in crypto paths0 blocks
Unsafe code totalLimited to FFI boundary (src/pkcs11_abi/functions.rs) and memory locking (src/crypto/mlock.rs)
Panic safetycatch_unwind on every extern "C" function

10.5 Delivery and Operation

Distribution:

  • Source code via Git repository
  • Compiled binaries via CI pipeline artifacts
  • Release signing: GPG, Sigstore/cosign, or Windows Authenticode
  • Source: docs/release-signing.md

Integrity Verification:

  • HMAC-SHA256 sidecar file (.hmac) for runtime integrity test
  • SHA-256 checksums for distribution verification
  • Source: tools/compute-integrity-hmac.sh, tools/compute-integrity-hmac.ps1

Configuration:

  • File: craton_hsm.toml (TOML format)
  • Location: CRATON_HSM_CONFIG environment variable or working directory
  • Source: src/config/config.rs

10.6 FIPS Build Procedures

# Build with FIPS-validated backend
cargo build --release --features awslc-backend

# Run full test suite
cargo test --release --features awslc-backend -- --test-threads=1

# Compute integrity HMAC
./tools/compute-integrity-hmac.sh target/release/libcraton_hsm.so

FIPS configuration (craton_hsm.toml):

[algorithms]
crypto_backend = "awslc"
fips_approved_only = true
enable_pqc = false
allow_sha1_signing = false

10.7 Guidance Documentation

DocumentPathDescription
Installation guidedocs/install.mdBuild, test, deploy, configure
Operator runbookdocs/operator-runbook.mdDaily operations, troubleshooting
FIPS deployment guidedocs/fips-mode-guide.mdFIPS mode configuration and verification
Security policydocs/security-policy.mdFormal security policy (v3.0)
Architecturedocs/architecture.mdSystem design and data flow

11. Mitigation of Other Attacks

FIPS 140-3 Level 1 does not require mitigation of attacks beyond the module boundary. However, the module voluntarily implements the following mitigations:

MitigationAttack AddressedImplementationSource
Constant-time PIN comparisonTiming side-channel on authenticationsubtle::ConstantTimeEq in PBKDF2 verificationsrc/store/encrypted_store.rs
RSA blindingTiming side-channel on RSA private keyDefault in rsa crate / aws-lc-rsLibrary default
AES-NI hardware instructionsCache-timing side-channel on AESHardware intrinsics when availableaes crate autodetection
Memory locking (mlock/VirtualLock)Cold boot attack, swap file recoveryRawKeyMaterial::new()src/store/key_material.rs:14-18
Memory zeroizationMemory remanenceZeroizeOnDrop on all key materialsrc/store/key_material.rs:42-50
Tamper-evident audit logUnauthorized operation detectionChained SHA-256 hashessrc/audit/log.rs
Fork detectionState corruption after Unix forkPID comparison on every callsrc/pkcs11_abi/functions.rs:67-74
Database file lockingConcurrent access corruptionfs2::try_lock_exclusive()src/store/encrypted_store.rs:48
Debug output redactionAccidental key leakage in logsCustom Debug impl with [REDACTED]src/store/key_material.rs:54-61
Intermediate zeroizationPlaintext leakage in multi-part opsZeroizing<Vec<u8>> in ActiveOperationsrc/session/session.rs:44-47

Appendix A: Complete Mechanism Table

All 41 cryptographic mechanisms supported by the module:

RSA Mechanisms (FIPS 186-5):

MechanismCKM ValueOperationsFIPS ApprovedKey Size
CKM_RSA_PKCS_KEY_PAIR_GEN0x00000000Key pair generationYes2048, 3072, 4096 bits
CKM_RSA_PKCS0x00000001Sign, VerifyYes2048+ bits
CKM_SHA256_RSA_PKCS0x00000040Sign, VerifyYes2048+ bits
CKM_SHA384_RSA_PKCS0x00000041Sign, VerifyYes2048+ bits
CKM_SHA512_RSA_PKCS0x00000042Sign, VerifyYes2048+ bits
CKM_RSA_PKCS_PSS0x0000000DSign, VerifyYes2048+ bits
CKM_SHA256_RSA_PKCS_PSS0x00000043Sign, VerifyYes2048+ bits
CKM_SHA384_RSA_PKCS_PSS0x00000044Sign, VerifyYes2048+ bits
CKM_SHA512_RSA_PKCS_PSS0x00000045Sign, VerifyYes2048+ bits
CKM_RSA_PKCS_OAEP0x00000009Encrypt, DecryptYes2048+ bits

ECDSA Mechanisms (FIPS 186-5):

MechanismCKM ValueOperationsFIPS ApprovedCurves
CKM_EC_KEY_PAIR_GEN0x00001040Key pair generationYesP-256, P-384
CKM_ECDSA0x00001041Sign, VerifyYesP-256, P-384
CKM_ECDSA_SHA2560x00001044Sign, VerifyYesP-256, P-384
CKM_ECDSA_SHA3840x00001045Sign, VerifyYesP-256, P-384
CKM_ECDSA_SHA5120x00001046Sign, VerifyYesP-256, P-384

ECDH Mechanisms (SP 800-56A):

MechanismCKM ValueOperationsFIPS ApprovedCurves
CKM_ECDH1_DERIVE0x00001050Key derivationYesP-256, P-384
CKM_ECDH1_COFACTOR_DERIVE0x00001051Key derivationYesP-256, P-384

EdDSA Mechanism:

MechanismCKM ValueOperationsFIPS Approved
CKM_EDDSA0x00001057Keygen, Sign, VerifyNo

AES Mechanisms (FIPS 197, SP 800-38A/D/F):

MechanismCKM ValueOperationsFIPS ApprovedKey Size
CKM_AES_KEY_GEN0x00001080Key generationYes128, 192, 256 bits
CKM_AES_CBC0x00001082Encrypt, DecryptYes128, 192, 256 bits
CKM_AES_CBC_PAD0x00001085Encrypt, DecryptYes128, 192, 256 bits
CKM_AES_CTR0x00001086Encrypt, DecryptYes128, 192, 256 bits
CKM_AES_GCM0x00001087Encrypt, DecryptYes128, 192, 256 bits
CKM_AES_KEY_WRAP0x00002109Wrap, UnwrapYes128, 192, 256 bits
CKM_AES_KEY_WRAP_KWP0x0000210BWrap, UnwrapYes128, 192, 256 bits

Digest Mechanisms (FIPS 180-4, FIPS 202):

MechanismCKM ValueOperationsFIPS ApprovedOutput Size
CKM_SHA_10x00000220DigestYes (digest only)20 bytes
CKM_SHA2560x00000250DigestYes32 bytes
CKM_SHA3840x00000260DigestYes48 bytes
CKM_SHA5120x00000270DigestYes64 bytes
CKM_SHA3_2560x000002B0DigestYes32 bytes
CKM_SHA3_3840x000002C0DigestYes48 bytes
CKM_SHA3_5120x000002D0DigestYes64 bytes

Post-Quantum Mechanisms (PKCS#11 v3.2, not FIPS-approved):

The parameter set comes from the key's CKA_PARAMETER_SET. Keys use the v3.2 key types CKK_ML_KEM (0x49), CKK_ML_DSA (0x4A) and CKK_SLH_DSA (0x4B); the vendor-defined key types 0x80000001–0x80000003 used before v0.10.3 are mapped to these on load and in templates.

MechanismCKM ValueOperationsStandard
CKM_ML_KEM_KEY_PAIR_GEN0x0000000FKeygenFIPS 203
CKM_ML_DSA_KEY_PAIR_GEN0x0000001CKeygenFIPS 204
CKM_ML_DSA0x0000001DSign, Verify (pure, deterministic, empty context)FIPS 204
CKM_SLH_DSA_KEY_PAIR_GEN0x0000002DKeygen (SHA2-128s, SHA2-256s)FIPS 205
CKM_SLH_DSA0x0000002ESign, VerifyFIPS 205

Post-Quantum Mechanisms (vendor-defined, not FIPS-approved):

MechanismCKM ValueOperationsStandard
CKM_ML_KEM_5120x80000001Keygen, Encap, DecapFIPS 203
CKM_ML_KEM_7680x80000002Keygen, Encap, DecapFIPS 203
CKM_ML_KEM_10240x80000003Keygen, Encap, DecapFIPS 203
CKM_ML_DSA_440x80000010Keygen, Sign, VerifyFIPS 204
CKM_ML_DSA_650x80000011Keygen, Sign, VerifyFIPS 204
CKM_ML_DSA_870x80000012Keygen, Sign, VerifyFIPS 204
CKM_SLH_DSA_SHA2_128S0x80000020Keygen, Sign, VerifyFIPS 205
CKM_SLH_DSA_SHA2_256S0x80000021Keygen, Sign, VerifyFIPS 205
CKM_HYBRID_ML_DSA_ECDSA0x80000030Keygen, Sign, VerifyComposite

Source: src/pkcs11_abi/constants.rs:92-138


Appendix B: Error Code Mapping

Complete mapping from internal HsmError variants to PKCS#11 CK_RV return codes:

Source: src/error.rs:104-157

HsmError VariantCK_RV ConstantValue
NotInitializedCKR_CRYPTOKI_NOT_INITIALIZED0x00000190
AlreadyInitializedCKR_CRYPTOKI_ALREADY_INITIALIZED0x00000191
ArgumentsBadCKR_ARGUMENTS_BAD0x00000007
SlotIdInvalidCKR_SLOT_ID_INVALID0x00000003
TokenNotPresentCKR_TOKEN_NOT_PRESENT0x000000E0
TokenNotInitializedCKR_TOKEN_NOT_RECOGNIZED0x000000E1
SessionHandleInvalidCKR_SESSION_HANDLE_INVALID0x000000B3
SessionCountCKR_SESSION_COUNT0x000000B1
SessionReadOnlyCKR_SESSION_READ_ONLY0x000000B5
SessionExistsCKR_SESSION_EXISTS0x000000B6
SessionReadOnlyExistsCKR_SESSION_READ_ONLY_EXISTS0x000000B7
SessionReadWriteSoExistsCKR_SESSION_READ_WRITE_SO_EXISTS0x000000B8
UserAlreadyLoggedInCKR_USER_ALREADY_LOGGED_IN0x00000100
UserNotLoggedInCKR_USER_NOT_LOGGED_IN0x00000101
UserTypeInvalidCKR_USER_TYPE_INVALID0x00000103
UserAnotherAlreadyLoggedInCKR_USER_ANOTHER_ALREADY_LOGGED_IN0x00000104
UserPinNotInitializedCKR_USER_PIN_NOT_INITIALIZED0x00000102
PinIncorrectCKR_PIN_INCORRECT0x000000A0
PinInvalidCKR_PIN_INVALID0x000000A1
PinLenRangeCKR_PIN_LEN_RANGE0x000000A2
PinLockedCKR_PIN_LOCKED0x000000A4
ObjectHandleInvalidCKR_OBJECT_HANDLE_INVALID0x00000082
AttributeTypeInvalidCKR_ATTRIBUTE_TYPE_INVALID0x00000012
AttributeValueInvalidCKR_ATTRIBUTE_VALUE_INVALID0x00000013
AttributeReadOnlyCKR_ATTRIBUTE_READ_ONLY0x00000010
AttributeSensitiveCKR_ATTRIBUTE_SENSITIVE0x00000011
TemplateIncompleteCKR_TEMPLATE_INCOMPLETE0x000000D0
TemplateInconsistentCKR_TEMPLATE_INCONSISTENT0x000000D1
MechanismInvalidCKR_MECHANISM_INVALID0x00000070
MechanismParamInvalidCKR_MECHANISM_PARAM_INVALID0x00000071
KeyHandleInvalidCKR_KEY_HANDLE_INVALID0x00000060
KeyTypeInconsistentCKR_KEY_TYPE_INCONSISTENT0x00000063
KeySizeRangeCKR_KEY_SIZE_RANGE0x00000062
KeyFunctionNotPermittedCKR_KEY_FUNCTION_NOT_PERMITTED0x00000068
OperationActiveCKR_OPERATION_ACTIVE0x00000090
OperationNotInitializedCKR_OPERATION_NOT_INITIALIZED0x00000091
DataInvalidCKR_DATA_INVALID0x00000020
DataLenRangeCKR_DATA_LEN_RANGE0x00000021
EncryptedDataInvalidCKR_ENCRYPTED_DATA_INVALID0x00000040
EncryptedDataLenRangeCKR_ENCRYPTED_DATA_LEN_RANGE0x00000041
SignatureInvalidCKR_SIGNATURE_INVALID0x000000C0
SignatureLenRangeCKR_SIGNATURE_LEN_RANGE0x000000C1
BufferTooSmallCKR_BUFFER_TOO_SMALL0x00000150
FunctionNotSupportedCKR_FUNCTION_NOT_SUPPORTED0x00000054
GeneralErrorCKR_GENERAL_ERROR0x00000005
HostMemoryCKR_HOST_MEMORY0x00000002
TokenWriteProtectedCKR_TOKEN_WRITE_PROTECTED0x000000E2
RandomSeedNotSupportedCKR_RANDOM_SEED_NOT_SUPPORTED0x00000120

Appendix C: Dependency Inventory

Critical cryptographic dependencies inside the module boundary:

CrateVersionPurposeFIPS Status
rsa0.9RSA keygen, sign, verify, encryptNot validated (RustCrypto)
p2560.13ECDSA P-256, ECDH P-256Not validated (RustCrypto)
p3840.13ECDSA P-384, ECDH P-384Not validated (RustCrypto)
ed25519-dalek2.2Ed25519 sign/verifyNot validated
aes-gcm0.10AES-GCM encrypt/decryptNot validated (RustCrypto)
aes0.8AES block cipherNot validated (RustCrypto)
cbc0.1AES-CBC modeNot validated (RustCrypto)
ctr0.9AES-CTR modeNot validated (RustCrypto)
aes-kw0.2AES Key Wrap (RFC 3394)Not validated (RustCrypto)
sha20.10SHA-256, SHA-384, SHA-512Not validated (RustCrypto)
sha30.10SHA3-256, SHA3-384, SHA3-512Not validated (RustCrypto)
sha10.10SHA-1 (digest only)Not validated (RustCrypto)
hmac0.12HMAC (SHA-256/384/512)Not validated (RustCrypto)
pbkdf20.12PBKDF2-HMAC-SHA256Not validated (RustCrypto)
ml-kem0.3.0-rc.0ML-KEM-512/768/1024 (FIPS 203)Not validated
ml-dsa0.1.0-rc.7ML-DSA-44/65/87 (FIPS 204)Not validated
slh-dsa0.2.0-rc.4SLH-DSA-SHA2-128s/256s (FIPS 205)Not validated
aws-lc-rs1.0 (optional)FIPS-validated crypto backendFIPS 140-3 validated
zeroize1.8Cryptographic memory zeroizationN/A (utility)
subtle2.6Constant-time operationsN/A (utility)
redb2.6Persistent key-value storageN/A (storage)
fs20.4Cross-platform file lockingN/A (utility)
dashmap6.1Lock-free concurrent hash mapN/A (utility)

Note: When built with --features awslc-backend and configured with crypto_backend = "awslc", all cryptographic operations are performed through the FIPS 140-3 validated aws-lc-rs library instead of the individual RustCrypto crates.


Appendix D: Test Suite Summary

Total: 547 tests across 29 test suites, plus 5 fuzz targets.

SuiteTestsCoverage Area
Unit tests (lib)15POST verification, DRBG, mlock, integrity, pairwise
crypto_vectors12AES-GCM, RSA sign/verify, key sizes
crypto_vectors_phase256ECDH, AES-CBC/CTR, RSA-OAEP/PSS, key wrap, digests, PBKDF2
pkcs11_compliance1Full PKCS#11 lifecycle
pkcs11_compliance_extended1PQC ABI, PIN enforcement, FindObjects
pqc_phase319ML-KEM, ML-DSA, SLH-DSA, hybrid roundtrips
concurrent_stress5Thread safety under concurrent keygen/sign/encrypt
pkcs11_error_paths50Error code validation for all failure modes
session_state_machine42FSM transitions, PIN validation, lockout
attribute_validation24Sensitivity, CKA_PRIVATE, template matching
concurrent_session_stress6Multi-threaded session/object management
zeroization7Key material zeroization verification (ignored by default)
persistence9Encrypted store integrity and roundtrip
multipart_sign_verify1C_SignUpdate/Final, C_VerifyUpdate/Final
multipart_encrypt_decrypt1C_EncryptUpdate/Final, C_DecryptUpdate/Final
supplementary_functions15C_CopyObject, C_DigestKey
fips_approved_mode11FIPS approved mode policy enforcement
pairwise_consistency6Pairwise consistency on all keygen paths
pkcs11_info_functions25C_GetInfo, C_GetSlotInfo, C_GetTokenInfo, C_GetMechanismInfo
key_lifecycle_abi25SP 800-57 date-based activation/deactivation
key_wrapping_abi22C_WrapKey/C_UnwrapKey roundtrips and error paths
key_derivation_abi19ECDH P-256/P-384 key derivation
rsa_abi_comprehensive28RSA 2048/3072 sign/verify/encrypt/decrypt
digest_abi25All 7 hash algorithms through C ABI
attribute_management25C_GetAttributeValue, C_SetAttributeValue, C_FindObjects
random_and_session22C_GenerateRandom, session management
pqc_abi_comprehensive28ML-DSA/ML-KEM/SLH-DSA through C ABI
audit_and_integrity24AuditLog chain integrity, StoredObject lifecycle
negative_edge_cases30Cross-algo failures, boundary conditions

Fuzz Targets (cargo-fuzz):

TargetFocus
fuzz_c_abiRandom PKCS#11 function calls with fuzzed parameters
fuzz_crypto_opsFuzzed key sizes, data lengths, mechanism parameters
fuzz_attributesFuzzed template construction and attribute values
fuzz_session_lifecycleState machine edge cases, login/logout sequences
fuzz_buffer_overflowInteger overflow, two-call pattern, null pointers

Appendix E: Configuration Reference

Complete craton_hsm.toml schema with FIPS implications:

[token]
label = "Craton HSM Token"          # Token label (32 bytes max, ASCII)
storage_path = ""                 # Path for persistent storage (empty = in-memory only)
max_sessions = 100                # Maximum concurrent sessions
max_rw_sessions = 50              # Maximum read-write sessions

[security]
pin_min_length = 4                # Minimum PIN length (bytes)
pin_max_length = 64               # Maximum PIN length (bytes)
max_failed_logins = 10            # Failed login attempts before lockout
pbkdf2_iterations = 600000        # PBKDF2 iteration count

[algorithms]
crypto_backend = "rustcrypto"     # "rustcrypto" (default) or "awslc" (FIPS)
fips_approved_only = false         # true = block non-FIPS mechanisms
enable_pqc = true                  # true = enable PQC mechanisms
allow_weak_rsa = false             # true = allow RSA < 2048 bits
allow_sha1_signing = false         # true = allow SHA-1 in signing contexts

[audit]
enabled = true                     # Enable audit logging
log_path = ""                      # Audit log file path (empty = in-memory only)
log_level = "all"                  # "all", "security", or "errors"

[daemon]
bind = "127.0.0.1:5696"           # gRPC bind address (daemon only)
tls_cert = ""                      # TLS certificate path
tls_key = ""                       # TLS private key path

FIPS Mode Configuration Requirements:

ParameterRequired ValueReason
crypto_backend"awslc"Must use FIPS-validated backend
fips_approved_onlytrueBlock non-approved mechanisms
enable_pqcfalsePQC not yet FIPS-approved for CMVP
allow_weak_rsafalseRSA < 2048 not approved
allow_sha1_signingfalseSHA-1 deprecated for signing (SP 800-131A)

End of FIPS 140-3 Security Policy and Certification Document Craton HSM v0.9.1 — 2026-03-17