CKeyManager Class

Static cryptographic key lifecycle management utility for Katlux applications. Provides key generation, JWK import/export, key wrapping (AES-KW and RSA-OAEP), and Key Derivation Functions (PBKDF2 and HKDF) using native browser and Node.js Web Crypto APIs.

๐Ÿ”’ CWebCryptoEncryptionProvider ยท ๐Ÿ” CECDHEncryptionProvider ยท ๐Ÿ” CRSAEncryptionProvider ยท ๐Ÿ”‘ IKeyPair ยท โš™๏ธ IKDFOptions

Key Lifecycle & Derivation

Generate, export, wrap, and derive keys without requiring external libraries or WASM dependencies:

import { CKeyManager } from '@katlux/providers'

// 1. Generate and export AES key
// Security note: exportAESKey exports raw key bytes (plaintext). Never expose raw keys in client code; use wrapKey before transit.
const aesKey = await CKeyManager.generateAESKey(256, 'AES-GCM')
const base64Key = await CKeyManager.exportAESKey(aesKey)

// 2. Derive key from human passphrase using PBKDF2 (310,000 rounds)
const { key, salt } = await CKeyManager.deriveKey('user-passphrase', {
    kdf: 'pbkdf2',
    iterations: 310_000,
    hash: 'SHA-256'
})

// 3. Wrap an Account Symmetric Key with AES-KW
const kek = await CKeyManager.generateAESKey(256, 'AES-KW')
const wrapped = await CKeyManager.wrapKey(aesKey, kek)
const unwrapped = await CKeyManager.unwrapKey(wrapped, kek)