| id | qrng | |||||
|---|---|---|---|---|---|---|
| title | Quantum Random Number Generation - QubeSec | |||||
| description | Generate cryptographically secure random numbers for your Kubernetes applications. Use quantum-based entropy for keys, tokens, and secure identifiers. | |||||
| keywords |
|
Cryptographically secure random numbers are fundamental to all cryptography. QubeSec provides the QuantumRandomNumber custom resource to generate high-entropy random bytes suitable for key generation, initialization vectors, and other cryptographic needs.
Traditional pseudo-random number generators (PRNGs) rely on algorithms that can be predictable if the seed is known or compromised. QubeSec leverages the unpredictability of physical or quantum sources to provide genuinely random numbers via liboqs.
Generate cryptographically secure random bytes using quantum or system entropy sources.
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: my-random-bytes
namespace: default
spec:
numBytes: 32 # Generate 32 random bytes (256 bits)| Field | Type | Required | Description |
|---|---|---|---|
spec.numBytes |
integer | Yes | Number of random bytes to generate (1-65536) |
After the controller reconciles the resource, the status will contain:
status:
status: Success # Pending, Success, or Failed
randomData: # Base64-encoded random bytes
fingerprint: # SHA256 fingerprint of generated data (first 10 hex chars)
size: # Number of bytes generated
lastGeneratedTime: # Timestamp of generation
error: # Error message if operation failedapiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: encryption-nonce
spec:
numBytes: 16 # 128-bit nonce
---
# Use the nonce in your application
apiVersion: v1
kind: ConfigMap
metadata:
name: nonce-config
data:
nonce-ref: encryption-nonce # Reference to retrieve the random bytesGenerate random seed material to feed into key derivation functions:
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: kdf-seed
spec:
numBytes: 64 # 512 bits of seed material
---
# Reference this in a QuantumDerivedKey
apiVersion: qubessec.io/v1
kind: QuantumDerivedKey
metadata:
name: derived-from-random
spec:
sharedSecretRef:
name: kdf-seed
outputSecretName: my-derived-keyapiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: batch-random-1
spec:
numBytes: 32
---
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: batch-random-2
spec:
numBytes: 32
---
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: batch-random-3
spec:
numBytes: 32The generated random bytes are stored in a Kubernetes Secret named after the resource. To retrieve the random data:
# Get the secret containing random bytes
kubectl get secret my-random-bytes -o jsonpath='{.data.random}'
# Decode and view (if text-based display is needed)
kubectl get secret my-random-bytes -o jsonpath='{.data.random}' | base64 -d | xxd
# Get the fingerprint (useful for verification without exposing full data)
kubectl get quantum randomnumber my-random-bytes -o jsonpath='{.status.fingerprint}'Generate IVs for AES-GCM or other authenticated encryption modes:
spec:
numBytes: 12 # 96-bit IV recommended for GCMGenerate fresh nonces for ECDH, KEM protocols, or TLS handshakes:
spec:
numBytes: 32 # 256-bit nonceGenerate salt for password-based key derivation:
spec:
numBytes: 16 # 128-bit salt minimumGenerate challenges in authentication flows:
spec:
numBytes: 32 # 256-bit challengeReplenish entropy pools for other cryptographic operations:
spec:
numBytes: 256 # Large seed material- QubeSec uses liboqs-provided randomness, which sources entropy from:
- System entropy (e.g.,
/dev/urandomon Linux) - OpenSSL oqs-provider entropy sources
- Quantum entropy when available in the underlying system
- System entropy (e.g.,
The status.fingerprint field provides a SHA256 hash of generated data without exposing the full random bytes. This is useful for:
- Verifying that the same random bytes were generated and stored
- Creating audit trails without logging sensitive data
- Comparing random data across systems without transmission
- All random data is stored in Kubernetes Secrets
- Enable ETCD encryption at rest in your cluster for maximum security
- Use RBAC to restrict access to Secrets containing random data
- Consider using external secret management (HashiCorp Vault, AWS Secrets Manager, etc.)
You can track and verify random data generation using only the fingerprint:
# Generate random data
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: sensitive-random
spec:
numBytes: 64
---
# View only the fingerprint (safe to log/audit)
# kubectl get qrn sensitive-random -o jsonpath='{.status.fingerprint}'
# Output: a1b2c3d4e5 (10 hex characters)Fingerprints help you:
- Track which random data was used when
- Verify consistency across multiple uses
- Maintain audit logs without exposing secrets
- Compare random data across namespaces or clusters
# Check the controller logs
kubectl logs -n qubesec-system deployment/qubesec-controller-manager | grep "QuantumRandomNumber"
# Check resource status for error messages
kubectl describe qrn my-random-bytesMount the Secret as a volume in your Pod:
apiVersion: v1
kind: Pod
metadata:
name: app-using-random
spec:
containers:
- name: app
image: myapp:latest
volumeMounts:
- name: random-data
mountPath: /etc/random
volumes:
- name: random-data
secret:
secretName: my-random-bytesThen in your application, read from /etc/random/random.
- Generate Only What You Need: Generate the exact number of bytes needed; don't over-generate
- Rotate Regularly: For long-lived applications, regenerate random material periodically
- Store Securely: Use Kubernetes Secret encryption and RBAC
- Audit Access: Monitor who accesses Secrets containing random data
- Use Fingerprints: Log fingerprints instead of full random data for auditability
- Isolate Sensitive Data: Store random data in separate Secrets from other application config
- Verify After Generation: Check the
status.statusfield to ensure successful generation
Use random data as input to key derivation:
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: my-seed
spec:
numBytes: 32
---
apiVersion: qubessec.io/v1
kind: QuantumDerivedKey
metadata:
name: derived-key
spec:
sharedSecretRef:
name: my-seedGenerate random padding or nonces for signing operations:
apiVersion: qubessec.io/v1
kind: QuantumRandomNumber
metadata:
name: signing-nonce
spec:
numBytes: 32