Cross-Language Security Module Interface
Side-channel claim limit. Nothing on this page claims constant-time behaviour or side-channel resistance for any target: the side-channel harness covers nothing (finding A48) and no measurement exists. The Rust and C cores are designed for constant time and unmeasured; managed runtimes (JIT, GC, bounds checks) make no timing claim. Where this page names constant-time or side-channel techniques, in prose or in code, they are design intent or recommendations, not measured properties.
Overview
The MetaMUI Security Module provides a standardized interface for security-critical operations across all language implementations. This ensures consistent security guarantees regardless of the implementation language.
Core Components
1. Secure Random Number Generation
interface SecureRandom {
// Generate cryptographically secure random bytes
generateBytes(length: number): Uint8Array
// Generate random integer in range [0, max)
generateInt(max: bigint): bigint
// Reseed with additional entropy
reseed(additionalEntropy?: Uint8Array): void
// Get RNG health status
getHealthStatus(): HealthStatus
}
enum HealthStatus {
Healthy,
Warning,
Critical,
Failed
}
2. Secure Memory Management
interface SecureMemory {
// Allocate secure memory that will be zeroized on deallocation
allocate(size: number): SecureBuffer
// Securely clear memory
zeroize(buffer: Uint8Array): void
// Compare buffers in constant time
constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean
// Copy buffer in constant time
constantTimeCopy(dest: Uint8Array, src: Uint8Array): void
}
interface SecureBuffer {
// Get underlying data (use with caution)
getData(): Uint8Array
// Get size
getSize(): number
// Explicit zeroization
zeroize(): void
// Automatic zeroization on garbage collection
[Symbol.dispose](): void
}
3. Key Management
interface KeyManager {
// Generate key with specified algorithm
generateKey(algorithm: KeyAlgorithm, params?: KeyParams): CryptoKey
// Import key from raw bytes
importKey(
format: KeyFormat,
keyData: Uint8Array,
algorithm: KeyAlgorithm,
extractable: boolean,
keyUsages: KeyUsage[]
): CryptoKey
// Export key (if extractable)
exportKey(format: KeyFormat, key: CryptoKey): Uint8Array
// Derive key from master key
deriveKey(
algorithm: KdfAlgorithm,
masterKey: CryptoKey,
derivedKeyAlgorithm: KeyAlgorithm,
extractable: boolean,
keyUsages: KeyUsage[]
): CryptoKey
// Securely destroy key
destroyKey(key: CryptoKey): void
}
interface CryptoKey {
algorithm: KeyAlgorithm
extractable: boolean
type: KeyType
usages: KeyUsage[]
handle: opaque // Language-specific secure handle
}
4. Cryptographic Operations
interface CryptoOperations {
// Encrypt data
encrypt(
algorithm: EncryptionAlgorithm,
key: CryptoKey,
plaintext: Uint8Array,
additionalData?: Uint8Array
): EncryptionResult
// Decrypt data
decrypt(
algorithm: EncryptionAlgorithm,
key: CryptoKey,
ciphertext: Uint8Array,
nonce: Uint8Array,
tag?: Uint8Array,
additionalData?: Uint8Array
): Uint8Array
// Sign data
sign(
algorithm: SignatureAlgorithm,
key: CryptoKey,
data: Uint8Array
): Uint8Array
// Verify signature
verify(
algorithm: SignatureAlgorithm,
key: CryptoKey,
signature: Uint8Array,
data: Uint8Array
): boolean
// Hash data
hash(algorithm: HashAlgorithm, data: Uint8Array): Uint8Array
}
interface EncryptionResult {
ciphertext: Uint8Array
nonce: Uint8Array
tag?: Uint8Array // For AEAD modes
}
5. Security Audit
interface SecurityAudit {
// Log security event
logEvent(event: SecurityEvent): void
// Get audit entries
getEntries(filter?: AuditFilter): AuditEntry[]
// Clear audit log (requires special permission)
clearLog(authorization: Authorization): void
// Export audit log
exportLog(format: ExportFormat): Uint8Array
}
interface SecurityEvent {
type: EventType
severity: EventSeverity
details: Record<string, any>
timestamp?: number // Auto-generated if not provided
}
interface AuditEntry {
id: string
event: SecurityEvent
timestamp: number
signature?: Uint8Array // For tamper detection
}
Implementation Requirements
1. Language-Specific Implementations
Each language must provide:
- Native implementation following the interface
- Language-specific optimizations while maintaining security
- Comprehensive test suite
- Performance benchmarks
2. Security Requirements
All implementations MUST:
- Use constant-time operations for secret data
- Implement secure memory zeroization
- Provide side-channel resistance
- Support security audit logging
- Pass standardized security tests
3. Cross-Language Compatibility
- Standardized data formats (JSON, CBOR, Protobuf)
- Common test vectors
- Interoperability test suite
- Performance comparison benchmarks
Standard Algorithms
Symmetric Encryption
- AES-256-GCM
- ChaCha20-Poly1305
- AES-256-CBC with HMAC-SHA256
Asymmetric Encryption
- RSA-OAEP with SHA-256
- ECIES with P-256/P-384/P-521
Digital Signatures
- Ed25519
- ECDSA with P-256/P-384/P-521
- RSA-PSS with SHA-256
Key Derivation
- HKDF with SHA-256/SHA-512
- PBKDF2 with SHA-256/SHA-512
- Argon2id
Hash Functions
- SHA-256/SHA-384/SHA-512
- SHA3-256/SHA3-384/SHA3-512
- BLAKE2b/BLAKE2s
- BLAKE3
Error Handling
All operations should use consistent error codes:
enum SecurityError {
// Initialization errors
NotInitialized = 1000,
AlreadyInitialized = 1001,
// Key errors
InvalidKey = 2000,
KeyNotFound = 2001,
KeyExpired = 2002,
KeyUsageViolation = 2003,
// Operation errors
InvalidAlgorithm = 3000,
InvalidParameter = 3001,
BufferTooSmall = 3002,
// Verification errors
VerificationFailed = 4000,
IntegrityCheckFailed = 4001,
// System errors
OutOfMemory = 5000,
EntropyFailure = 5001,
HardwareError = 5002,
// Self-test errors
SelfTestFailed = 6001
}
Usage Example
// Initialize security module
const security = new SecurityModule({
auditLogging: true
});
// Generate secure random
const random = security.secureRandom();
const nonce = random.generateBytes(12);
// Create encryption key
const keyManager = security.keyManager();
const key = await keyManager.generateKey('AES-GCM', { length: 256 });
// Encrypt data
const crypto = security.cryptoOperations();
const result = await crypto.encrypt(
'AES-GCM',
key,
plaintext,
additionalData
);
// Secure cleanup
security.secureMemory().zeroize(plaintext);
keyManager.destroyKey(key);
Testing Requirements
- Unit tests for each component
- Integration tests for cross-component operations
- Security-specific tests:
- Timing attack resistance
- Memory leak detection
- Zeroization verification
- Side-channel analysis
- Cross-language compatibility tests
- Performance benchmarks
- Fuzzing tests
Certification
Implementations should support:
- HMAC_DRBG per SP 800-90A with SP 800-90B-style health tests; not a validated FIPS 140-3 module
- Common Criteria EAL2+
- SOC 2 Type II compliance
- Industry-specific certifications (PCI-DSS, HIPAA, etc.)