@omnituum/pqc-shared 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +543 -0
- package/dist/crypto/index.cjs +807 -0
- package/dist/crypto/index.d.cts +641 -0
- package/dist/crypto/index.d.ts +641 -0
- package/dist/crypto/index.js +716 -0
- package/dist/decrypt-eSHlbh1j.d.cts +321 -0
- package/dist/decrypt-eSHlbh1j.d.ts +321 -0
- package/dist/fs/index.cjs +1168 -0
- package/dist/fs/index.d.cts +400 -0
- package/dist/fs/index.d.ts +400 -0
- package/dist/fs/index.js +1091 -0
- package/dist/index.cjs +2160 -0
- package/dist/index.d.cts +282 -0
- package/dist/index.d.ts +282 -0
- package/dist/index.js +2031 -0
- package/dist/integrity-CCYjrap3.d.ts +31 -0
- package/dist/integrity-Dx9jukMH.d.cts +31 -0
- package/dist/types-61c7Q9ri.d.ts +134 -0
- package/dist/types-Ch0y-n7K.d.cts +134 -0
- package/dist/utils/index.cjs +129 -0
- package/dist/utils/index.d.cts +49 -0
- package/dist/utils/index.d.ts +49 -0
- package/dist/utils/index.js +114 -0
- package/dist/vault/index.cjs +713 -0
- package/dist/vault/index.d.cts +237 -0
- package/dist/vault/index.d.ts +237 -0
- package/dist/vault/index.js +677 -0
- package/dist/version-BygzPVGs.d.cts +55 -0
- package/dist/version-BygzPVGs.d.ts +55 -0
- package/package.json +86 -0
- package/src/crypto/dilithium.ts +233 -0
- package/src/crypto/hybrid.ts +358 -0
- package/src/crypto/index.ts +181 -0
- package/src/crypto/kyber.ts +199 -0
- package/src/crypto/nacl.ts +204 -0
- package/src/crypto/primitives/blake3.ts +141 -0
- package/src/crypto/primitives/chacha.ts +211 -0
- package/src/crypto/primitives/hkdf.ts +192 -0
- package/src/crypto/primitives/index.ts +54 -0
- package/src/crypto/primitives.ts +144 -0
- package/src/crypto/x25519.ts +134 -0
- package/src/fs/aes.ts +343 -0
- package/src/fs/argon2.ts +184 -0
- package/src/fs/browser.ts +408 -0
- package/src/fs/decrypt.ts +320 -0
- package/src/fs/encrypt.ts +324 -0
- package/src/fs/format.ts +425 -0
- package/src/fs/index.ts +144 -0
- package/src/fs/types.ts +304 -0
- package/src/index.ts +414 -0
- package/src/kdf/index.ts +311 -0
- package/src/runtime/crypto.ts +16 -0
- package/src/security/index.ts +345 -0
- package/src/tunnel/index.ts +39 -0
- package/src/tunnel/session.ts +229 -0
- package/src/tunnel/types.ts +115 -0
- package/src/utils/entropy.ts +128 -0
- package/src/utils/index.ts +25 -0
- package/src/utils/integrity.ts +95 -0
- package/src/vault/decrypt.ts +167 -0
- package/src/vault/encrypt.ts +207 -0
- package/src/vault/index.ts +71 -0
- package/src/vault/manager.ts +327 -0
- package/src/vault/migrate.ts +190 -0
- package/src/vault/types.ts +177 -0
- package/src/version.ts +304 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
export { BLAKE3_OUTPUT_LENGTH, BOX_KEY_SIZE, BOX_NONCE_SIZE, BoxPayload, CHACHA20_KEY_SIZE, ClassicalWrap, DILITHIUM_ALGORITHM, DILITHIUM_PUBLIC_KEY_SIZE, DILITHIUM_SECRET_KEY_SIZE, DILITHIUM_SIGNATURE_SIZE, DilithiumKeypair, DilithiumKeypairB64, DilithiumSignature, HybridEnvelope, HybridIdentity, HybridPublicKeys, HybridSecretKeys, KyberEncapsulation, KyberKeypair, KyberKeypairB64, POLY1305_TAG_SIZE, SECRETBOX_KEY_SIZE, SECRETBOX_NONCE_SIZE, SECRETBOX_OVERHEAD, SecretboxPayload, X25519Keypair, X25519KeypairHex, XCHACHA20_NONCE_SIZE, assertLen, b64, blake3, blake3DeriveKey, blake3Hex, blake3Mac, boxDecrypt, boxEncrypt, boxUnwrapWithX25519, boxWrapWithX25519, chaCha20Poly1305Decrypt, chaCha20Poly1305Encrypt, createChaCha20Poly1305, createXChaCha20Poly1305, deriveKeyFromShared, dilithiumSign, dilithiumSignRaw, dilithiumVerify, dilithiumVerifyRaw, fromB64, fromHex, generateDilithiumKeypair, generateDilithiumKeypairFromSeed, generateHybridIdentity, generateKyberKeypair, generateX25519Keypair, generateX25519KeypairFromSeed, getPublicKeys, getSecretKeys, hkdfDerive, hkdfExpand, hkdfExtract, hkdfSha256, hkdfSplitForNoise, hkdfTripleSplitForNoise, hybridDecrypt, hybridDecryptToString, hybridEncrypt, isDilithiumAvailable, isKyberAvailable, kyberDecapsulate, kyberEncapsulate, kyberUnwrapKey, kyberWrapKey, rand12, rand24, rand32, randN, secretboxDecrypt, secretboxDecryptString, secretboxEncrypt, secretboxEncryptString, secretboxOpenRaw, secretboxRaw, sha256, sha256String, textDecoder, textEncoder, toB64, toHex, u8, ub64, x25519SharedSecret, xChaCha20Poly1305Decrypt, xChaCha20Poly1305Encrypt } from './crypto/index.cjs';
|
|
2
|
+
export { E as EncryptedVaultFile, H as HybridIdentityRecord, O as OmnituumVault } from './types-Ch0y-n7K.cjs';
|
|
3
|
+
export { MigrationOptions, MigrationResult, addIdentity, createEmptyVault, createIdentity, decryptVault, encryptVault, getVaultKdfInfo, isV2Vault, migrateEncryptedVault, needsMigration } from './vault/index.cjs';
|
|
4
|
+
export { c as computeIntegrityHash, b as computeKeyFingerprint } from './integrity-Dx9jukMH.cjs';
|
|
5
|
+
export { g as ENVELOPE_AEAD, f as ENVELOPE_SUITE, E as ENVELOPE_VERSION, c as VAULT_ALGORITHM, a as VAULT_ENCRYPTED_VERSION, d as VAULT_ENCRYPTED_VERSION_V2, b as VAULT_KDF, e as VAULT_KDF_V2, V as VAULT_VERSION, i as validateEncryptedVault, h as validateEnvelope, v as validateVault } from './version-BygzPVGs.cjs';
|
|
6
|
+
export { D as DecryptOptions, E as EncryptOptions, c as OQEDecryptResult, O as OQEEncryptResult, d as decryptFile, b as decryptFileWithPassword, e as encryptFile, a as encryptFileWithPassword } from './decrypt-eSHlbh1j.cjs';
|
|
7
|
+
import '@noble/ciphers/utils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Omnituum PQC Shared - Unified Key Derivation
|
|
11
|
+
*
|
|
12
|
+
* Single source of truth for password-based key derivation.
|
|
13
|
+
* Supports both legacy PBKDF2 (for backwards compatibility) and
|
|
14
|
+
* Argon2id (recommended for new implementations).
|
|
15
|
+
*
|
|
16
|
+
* Security Levels:
|
|
17
|
+
* - PBKDF2-SHA256: 600K iterations (OWASP 2023)
|
|
18
|
+
* - Argon2id: 64MB memory, 3 iterations, 4 parallelism (OWASP 2024)
|
|
19
|
+
*/
|
|
20
|
+
type KDFAlgorithm = 'PBKDF2-SHA256' | 'Argon2id';
|
|
21
|
+
interface KDFConfig {
|
|
22
|
+
algorithm: KDFAlgorithm;
|
|
23
|
+
pbkdf2Iterations?: number;
|
|
24
|
+
argon2MemoryCost?: number;
|
|
25
|
+
argon2TimeCost?: number;
|
|
26
|
+
argon2Parallelism?: number;
|
|
27
|
+
saltLength: number;
|
|
28
|
+
hashLength: number;
|
|
29
|
+
}
|
|
30
|
+
/** Legacy PBKDF2 config (for existing vaults) */
|
|
31
|
+
declare const KDF_CONFIG_PBKDF2: KDFConfig;
|
|
32
|
+
/** Modern Argon2id config (recommended for new vaults) */
|
|
33
|
+
declare const KDF_CONFIG_ARGON2ID: KDFConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Generate a cryptographically secure salt.
|
|
36
|
+
*/
|
|
37
|
+
declare function generateSalt(length?: number): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* Derive a key from a password using the specified KDF configuration.
|
|
40
|
+
*
|
|
41
|
+
* @param password - User password
|
|
42
|
+
* @param salt - Random salt (use generateSalt())
|
|
43
|
+
* @param config - KDF configuration
|
|
44
|
+
* @returns Derived key as Uint8Array
|
|
45
|
+
*/
|
|
46
|
+
declare function kdfDeriveKey(password: string, salt: Uint8Array, config?: KDFConfig): Promise<Uint8Array>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the recommended KDF config based on environment capabilities.
|
|
49
|
+
*/
|
|
50
|
+
declare function getRecommendedConfig(): Promise<KDFConfig>;
|
|
51
|
+
/**
|
|
52
|
+
* Benchmark a KDF configuration.
|
|
53
|
+
* @returns Time in milliseconds
|
|
54
|
+
*/
|
|
55
|
+
declare function benchmarkKDF(config?: KDFConfig): Promise<number>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Omnituum PQC Shared - Security Utilities
|
|
59
|
+
*
|
|
60
|
+
* Memory hygiene, secure comparison, and session management utilities.
|
|
61
|
+
* These are critical for enterprise credibility and threat model legitimacy.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Securely zero out a Uint8Array to prevent sensitive data from lingering in memory.
|
|
65
|
+
*
|
|
66
|
+
* Note: JavaScript garbage collection may still leave copies. This is a best-effort
|
|
67
|
+
* approach for browser environments. For maximum security, use Web Assembly or
|
|
68
|
+
* native code.
|
|
69
|
+
*
|
|
70
|
+
* @param arr - Array to zero
|
|
71
|
+
*/
|
|
72
|
+
declare function zeroMemory(arr: Uint8Array): void;
|
|
73
|
+
/**
|
|
74
|
+
* Zero multiple arrays at once.
|
|
75
|
+
*
|
|
76
|
+
* @param arrays - Arrays to zero
|
|
77
|
+
*/
|
|
78
|
+
declare function zeroAll(...arrays: (Uint8Array | null | undefined)[]): void;
|
|
79
|
+
/**
|
|
80
|
+
* Execute a function and zero the result after a callback processes it.
|
|
81
|
+
* Ensures sensitive data is cleared even if callback throws.
|
|
82
|
+
*
|
|
83
|
+
* @param getData - Function that returns sensitive data
|
|
84
|
+
* @param process - Function to process the data
|
|
85
|
+
* @returns Result of process function
|
|
86
|
+
*/
|
|
87
|
+
declare function withSecureData<T, R>(getData: () => Promise<Uint8Array>, process: (data: Uint8Array) => Promise<R>): Promise<R>;
|
|
88
|
+
/**
|
|
89
|
+
* Compare two byte arrays in constant time to prevent timing attacks.
|
|
90
|
+
*
|
|
91
|
+
* @param a - First array
|
|
92
|
+
* @param b - Second array
|
|
93
|
+
* @returns true if arrays are equal
|
|
94
|
+
*/
|
|
95
|
+
declare function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
96
|
+
type UnlockReason = 'password' | 'biometric' | 'hardware_key' | 'session_restore' | 'api_token' | 'unknown';
|
|
97
|
+
interface SecureSession {
|
|
98
|
+
/** Session is currently unlocked */
|
|
99
|
+
unlocked: boolean;
|
|
100
|
+
/** Timestamp when session was unlocked (ms since epoch) */
|
|
101
|
+
unlockedAt: number | null;
|
|
102
|
+
/** Session timeout in milliseconds (0 = never) */
|
|
103
|
+
timeoutMs: number;
|
|
104
|
+
/** How the session was unlocked */
|
|
105
|
+
unlockReason: UnlockReason | null;
|
|
106
|
+
/** Optional session identifier */
|
|
107
|
+
sessionId: string | null;
|
|
108
|
+
/** Last activity timestamp (ms since epoch) */
|
|
109
|
+
lastActivityAt: number | null;
|
|
110
|
+
/** Number of failed unlock attempts */
|
|
111
|
+
failedAttempts: number;
|
|
112
|
+
/** Lockout until timestamp (ms since epoch) if too many failed attempts */
|
|
113
|
+
lockedOutUntil: number | null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create a new locked session.
|
|
117
|
+
*/
|
|
118
|
+
declare function createSession(timeoutMs?: number): SecureSession;
|
|
119
|
+
/**
|
|
120
|
+
* Unlock a secure session.
|
|
121
|
+
*/
|
|
122
|
+
declare function unlockSecureSession(session: SecureSession, reason?: UnlockReason): SecureSession;
|
|
123
|
+
/**
|
|
124
|
+
* Lock a secure session and clear sensitive state.
|
|
125
|
+
*/
|
|
126
|
+
declare function lockSecureSession(session: SecureSession): SecureSession;
|
|
127
|
+
/**
|
|
128
|
+
* Check if session has timed out.
|
|
129
|
+
*/
|
|
130
|
+
declare function isSessionTimedOut(session: SecureSession): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Wrapper for sensitive data that auto-zeros on disposal.
|
|
133
|
+
*/
|
|
134
|
+
declare class SecureBuffer {
|
|
135
|
+
private _data;
|
|
136
|
+
private _disposed;
|
|
137
|
+
constructor(data: Uint8Array);
|
|
138
|
+
/**
|
|
139
|
+
* Get a copy of the data (original stays protected).
|
|
140
|
+
*/
|
|
141
|
+
get data(): Uint8Array;
|
|
142
|
+
/**
|
|
143
|
+
* Get data length without exposing contents.
|
|
144
|
+
*/
|
|
145
|
+
get length(): number;
|
|
146
|
+
/**
|
|
147
|
+
* Check if buffer has been disposed.
|
|
148
|
+
*/
|
|
149
|
+
get isDisposed(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Zero and dispose the buffer.
|
|
152
|
+
*/
|
|
153
|
+
dispose(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Execute a function with the data, then dispose.
|
|
156
|
+
*/
|
|
157
|
+
useAndDispose<T>(fn: (data: Uint8Array) => Promise<T>): Promise<T>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Omnituum Tunnel v1 - Type Definitions
|
|
162
|
+
*
|
|
163
|
+
* Post-handshake encrypted tunnel interface.
|
|
164
|
+
* Handshake-agnostic: any key agreement can feed into this.
|
|
165
|
+
*
|
|
166
|
+
* @see pqc-docs/specs/tunnel.v1.md
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* Key material required to establish a tunnel session.
|
|
170
|
+
* Produced by any key agreement protocol (Noise, TLS, custom).
|
|
171
|
+
*/
|
|
172
|
+
interface TunnelKeyMaterial {
|
|
173
|
+
/** 32-byte key for outgoing messages */
|
|
174
|
+
sendKey: Uint8Array;
|
|
175
|
+
/** 32-byte key for incoming messages */
|
|
176
|
+
recvKey: Uint8Array;
|
|
177
|
+
/** 24-byte base nonce for outgoing messages */
|
|
178
|
+
sendBaseNonce: Uint8Array;
|
|
179
|
+
/** 24-byte base nonce for incoming messages */
|
|
180
|
+
recvBaseNonce: Uint8Array;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A secure tunnel session for post-handshake communication.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { createTunnelSession } from '@omnituum/pqc-shared';
|
|
188
|
+
*
|
|
189
|
+
* const tunnel = createTunnelSession(keys);
|
|
190
|
+
*
|
|
191
|
+
* // Send a message
|
|
192
|
+
* const ciphertext = tunnel.encrypt(plaintext);
|
|
193
|
+
*
|
|
194
|
+
* // Receive a message
|
|
195
|
+
* const plaintext = tunnel.decrypt(ciphertext);
|
|
196
|
+
* if (!plaintext) throw new Error('Authentication failed');
|
|
197
|
+
*
|
|
198
|
+
* // Clean up
|
|
199
|
+
* tunnel.close();
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
interface PQCTunnelSession {
|
|
203
|
+
/**
|
|
204
|
+
* Encrypt plaintext for transmission.
|
|
205
|
+
* Automatically increments the send counter.
|
|
206
|
+
*
|
|
207
|
+
* @param plaintext - Data to encrypt
|
|
208
|
+
* @param aad - Optional additional authenticated data
|
|
209
|
+
* @returns Ciphertext with authentication tag
|
|
210
|
+
* @throws Error if tunnel is closed
|
|
211
|
+
*/
|
|
212
|
+
encrypt(plaintext: Uint8Array, aad?: Uint8Array): Uint8Array;
|
|
213
|
+
/**
|
|
214
|
+
* Decrypt received ciphertext.
|
|
215
|
+
* Automatically increments the receive counter.
|
|
216
|
+
*
|
|
217
|
+
* @param ciphertext - Data to decrypt (includes auth tag)
|
|
218
|
+
* @param aad - Optional additional authenticated data (must match encryption)
|
|
219
|
+
* @returns Plaintext, or null if authentication fails
|
|
220
|
+
* @throws Error if tunnel is closed
|
|
221
|
+
*/
|
|
222
|
+
decrypt(ciphertext: Uint8Array, aad?: Uint8Array): Uint8Array | null;
|
|
223
|
+
/**
|
|
224
|
+
* Securely close the tunnel.
|
|
225
|
+
* Zeros all key material and rejects further operations.
|
|
226
|
+
*/
|
|
227
|
+
close(): void;
|
|
228
|
+
/**
|
|
229
|
+
* Check if the tunnel is still open.
|
|
230
|
+
*/
|
|
231
|
+
readonly isOpen: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Get current send counter (for debugging/monitoring).
|
|
234
|
+
*/
|
|
235
|
+
readonly sendCounter: bigint;
|
|
236
|
+
/**
|
|
237
|
+
* Get current receive counter (for debugging/monitoring).
|
|
238
|
+
*/
|
|
239
|
+
readonly recvCounter: bigint;
|
|
240
|
+
}
|
|
241
|
+
/** Tunnel version string */
|
|
242
|
+
declare const TUNNEL_VERSION: "omnituum.tunnel.v1";
|
|
243
|
+
/** Key size in bytes (32 = 256 bits) */
|
|
244
|
+
declare const TUNNEL_KEY_SIZE = 32;
|
|
245
|
+
/** Base nonce size in bytes (24 for XChaCha20) */
|
|
246
|
+
declare const TUNNEL_NONCE_SIZE = 24;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Omnituum Tunnel v1 - Session Implementation
|
|
250
|
+
*
|
|
251
|
+
* XChaCha20-Poly1305 encrypted tunnel with counter-based nonces.
|
|
252
|
+
* Handshake-agnostic: accepts any TunnelKeyMaterial producer.
|
|
253
|
+
*
|
|
254
|
+
* @see pqc-docs/specs/tunnel.v1.md
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Create a secure tunnel session from key material.
|
|
259
|
+
*
|
|
260
|
+
* @param keys - Key material from handshake (Noise, TLS, etc.)
|
|
261
|
+
* @returns Tunnel session for encrypted communication
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* // From Noise handshake
|
|
266
|
+
* const keys = toTunnelKeyMaterial(noiseState);
|
|
267
|
+
* const tunnel = createTunnelSession(keys);
|
|
268
|
+
*
|
|
269
|
+
* // Send encrypted message
|
|
270
|
+
* const ciphertext = tunnel.encrypt(plaintext);
|
|
271
|
+
* channel.send(ciphertext);
|
|
272
|
+
*
|
|
273
|
+
* // Receive encrypted message
|
|
274
|
+
* const plaintext = tunnel.decrypt(received);
|
|
275
|
+
*
|
|
276
|
+
* // Clean up when done
|
|
277
|
+
* tunnel.close();
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare function createTunnelSession(keys: TunnelKeyMaterial): PQCTunnelSession;
|
|
281
|
+
|
|
282
|
+
export { type KDFAlgorithm, type KDFConfig, KDF_CONFIG_ARGON2ID, KDF_CONFIG_PBKDF2, type PQCTunnelSession, SecureBuffer, type SecureSession, TUNNEL_KEY_SIZE, TUNNEL_NONCE_SIZE, TUNNEL_VERSION, type TunnelKeyMaterial, type UnlockReason, benchmarkKDF, constantTimeEqual, createSession, createTunnelSession, generateSalt, getRecommendedConfig, isSessionTimedOut, kdfDeriveKey, lockSecureSession, unlockSecureSession, withSecureData, zeroAll, zeroMemory };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
export { BLAKE3_OUTPUT_LENGTH, BOX_KEY_SIZE, BOX_NONCE_SIZE, BoxPayload, CHACHA20_KEY_SIZE, ClassicalWrap, DILITHIUM_ALGORITHM, DILITHIUM_PUBLIC_KEY_SIZE, DILITHIUM_SECRET_KEY_SIZE, DILITHIUM_SIGNATURE_SIZE, DilithiumKeypair, DilithiumKeypairB64, DilithiumSignature, HybridEnvelope, HybridIdentity, HybridPublicKeys, HybridSecretKeys, KyberEncapsulation, KyberKeypair, KyberKeypairB64, POLY1305_TAG_SIZE, SECRETBOX_KEY_SIZE, SECRETBOX_NONCE_SIZE, SECRETBOX_OVERHEAD, SecretboxPayload, X25519Keypair, X25519KeypairHex, XCHACHA20_NONCE_SIZE, assertLen, b64, blake3, blake3DeriveKey, blake3Hex, blake3Mac, boxDecrypt, boxEncrypt, boxUnwrapWithX25519, boxWrapWithX25519, chaCha20Poly1305Decrypt, chaCha20Poly1305Encrypt, createChaCha20Poly1305, createXChaCha20Poly1305, deriveKeyFromShared, dilithiumSign, dilithiumSignRaw, dilithiumVerify, dilithiumVerifyRaw, fromB64, fromHex, generateDilithiumKeypair, generateDilithiumKeypairFromSeed, generateHybridIdentity, generateKyberKeypair, generateX25519Keypair, generateX25519KeypairFromSeed, getPublicKeys, getSecretKeys, hkdfDerive, hkdfExpand, hkdfExtract, hkdfSha256, hkdfSplitForNoise, hkdfTripleSplitForNoise, hybridDecrypt, hybridDecryptToString, hybridEncrypt, isDilithiumAvailable, isKyberAvailable, kyberDecapsulate, kyberEncapsulate, kyberUnwrapKey, kyberWrapKey, rand12, rand24, rand32, randN, secretboxDecrypt, secretboxDecryptString, secretboxEncrypt, secretboxEncryptString, secretboxOpenRaw, secretboxRaw, sha256, sha256String, textDecoder, textEncoder, toB64, toHex, u8, ub64, x25519SharedSecret, xChaCha20Poly1305Decrypt, xChaCha20Poly1305Encrypt } from './crypto/index.js';
|
|
2
|
+
export { E as EncryptedVaultFile, H as HybridIdentityRecord, O as OmnituumVault } from './types-61c7Q9ri.js';
|
|
3
|
+
export { MigrationOptions, MigrationResult, addIdentity, createEmptyVault, createIdentity, decryptVault, encryptVault, getVaultKdfInfo, isV2Vault, migrateEncryptedVault, needsMigration } from './vault/index.js';
|
|
4
|
+
export { c as computeIntegrityHash, b as computeKeyFingerprint } from './integrity-CCYjrap3.js';
|
|
5
|
+
export { g as ENVELOPE_AEAD, f as ENVELOPE_SUITE, E as ENVELOPE_VERSION, c as VAULT_ALGORITHM, a as VAULT_ENCRYPTED_VERSION, d as VAULT_ENCRYPTED_VERSION_V2, b as VAULT_KDF, e as VAULT_KDF_V2, V as VAULT_VERSION, i as validateEncryptedVault, h as validateEnvelope, v as validateVault } from './version-BygzPVGs.js';
|
|
6
|
+
export { D as DecryptOptions, E as EncryptOptions, c as OQEDecryptResult, O as OQEEncryptResult, d as decryptFile, b as decryptFileWithPassword, e as encryptFile, a as encryptFileWithPassword } from './decrypt-eSHlbh1j.js';
|
|
7
|
+
import '@noble/ciphers/utils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Omnituum PQC Shared - Unified Key Derivation
|
|
11
|
+
*
|
|
12
|
+
* Single source of truth for password-based key derivation.
|
|
13
|
+
* Supports both legacy PBKDF2 (for backwards compatibility) and
|
|
14
|
+
* Argon2id (recommended for new implementations).
|
|
15
|
+
*
|
|
16
|
+
* Security Levels:
|
|
17
|
+
* - PBKDF2-SHA256: 600K iterations (OWASP 2023)
|
|
18
|
+
* - Argon2id: 64MB memory, 3 iterations, 4 parallelism (OWASP 2024)
|
|
19
|
+
*/
|
|
20
|
+
type KDFAlgorithm = 'PBKDF2-SHA256' | 'Argon2id';
|
|
21
|
+
interface KDFConfig {
|
|
22
|
+
algorithm: KDFAlgorithm;
|
|
23
|
+
pbkdf2Iterations?: number;
|
|
24
|
+
argon2MemoryCost?: number;
|
|
25
|
+
argon2TimeCost?: number;
|
|
26
|
+
argon2Parallelism?: number;
|
|
27
|
+
saltLength: number;
|
|
28
|
+
hashLength: number;
|
|
29
|
+
}
|
|
30
|
+
/** Legacy PBKDF2 config (for existing vaults) */
|
|
31
|
+
declare const KDF_CONFIG_PBKDF2: KDFConfig;
|
|
32
|
+
/** Modern Argon2id config (recommended for new vaults) */
|
|
33
|
+
declare const KDF_CONFIG_ARGON2ID: KDFConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Generate a cryptographically secure salt.
|
|
36
|
+
*/
|
|
37
|
+
declare function generateSalt(length?: number): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* Derive a key from a password using the specified KDF configuration.
|
|
40
|
+
*
|
|
41
|
+
* @param password - User password
|
|
42
|
+
* @param salt - Random salt (use generateSalt())
|
|
43
|
+
* @param config - KDF configuration
|
|
44
|
+
* @returns Derived key as Uint8Array
|
|
45
|
+
*/
|
|
46
|
+
declare function kdfDeriveKey(password: string, salt: Uint8Array, config?: KDFConfig): Promise<Uint8Array>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the recommended KDF config based on environment capabilities.
|
|
49
|
+
*/
|
|
50
|
+
declare function getRecommendedConfig(): Promise<KDFConfig>;
|
|
51
|
+
/**
|
|
52
|
+
* Benchmark a KDF configuration.
|
|
53
|
+
* @returns Time in milliseconds
|
|
54
|
+
*/
|
|
55
|
+
declare function benchmarkKDF(config?: KDFConfig): Promise<number>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Omnituum PQC Shared - Security Utilities
|
|
59
|
+
*
|
|
60
|
+
* Memory hygiene, secure comparison, and session management utilities.
|
|
61
|
+
* These are critical for enterprise credibility and threat model legitimacy.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Securely zero out a Uint8Array to prevent sensitive data from lingering in memory.
|
|
65
|
+
*
|
|
66
|
+
* Note: JavaScript garbage collection may still leave copies. This is a best-effort
|
|
67
|
+
* approach for browser environments. For maximum security, use Web Assembly or
|
|
68
|
+
* native code.
|
|
69
|
+
*
|
|
70
|
+
* @param arr - Array to zero
|
|
71
|
+
*/
|
|
72
|
+
declare function zeroMemory(arr: Uint8Array): void;
|
|
73
|
+
/**
|
|
74
|
+
* Zero multiple arrays at once.
|
|
75
|
+
*
|
|
76
|
+
* @param arrays - Arrays to zero
|
|
77
|
+
*/
|
|
78
|
+
declare function zeroAll(...arrays: (Uint8Array | null | undefined)[]): void;
|
|
79
|
+
/**
|
|
80
|
+
* Execute a function and zero the result after a callback processes it.
|
|
81
|
+
* Ensures sensitive data is cleared even if callback throws.
|
|
82
|
+
*
|
|
83
|
+
* @param getData - Function that returns sensitive data
|
|
84
|
+
* @param process - Function to process the data
|
|
85
|
+
* @returns Result of process function
|
|
86
|
+
*/
|
|
87
|
+
declare function withSecureData<T, R>(getData: () => Promise<Uint8Array>, process: (data: Uint8Array) => Promise<R>): Promise<R>;
|
|
88
|
+
/**
|
|
89
|
+
* Compare two byte arrays in constant time to prevent timing attacks.
|
|
90
|
+
*
|
|
91
|
+
* @param a - First array
|
|
92
|
+
* @param b - Second array
|
|
93
|
+
* @returns true if arrays are equal
|
|
94
|
+
*/
|
|
95
|
+
declare function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
96
|
+
type UnlockReason = 'password' | 'biometric' | 'hardware_key' | 'session_restore' | 'api_token' | 'unknown';
|
|
97
|
+
interface SecureSession {
|
|
98
|
+
/** Session is currently unlocked */
|
|
99
|
+
unlocked: boolean;
|
|
100
|
+
/** Timestamp when session was unlocked (ms since epoch) */
|
|
101
|
+
unlockedAt: number | null;
|
|
102
|
+
/** Session timeout in milliseconds (0 = never) */
|
|
103
|
+
timeoutMs: number;
|
|
104
|
+
/** How the session was unlocked */
|
|
105
|
+
unlockReason: UnlockReason | null;
|
|
106
|
+
/** Optional session identifier */
|
|
107
|
+
sessionId: string | null;
|
|
108
|
+
/** Last activity timestamp (ms since epoch) */
|
|
109
|
+
lastActivityAt: number | null;
|
|
110
|
+
/** Number of failed unlock attempts */
|
|
111
|
+
failedAttempts: number;
|
|
112
|
+
/** Lockout until timestamp (ms since epoch) if too many failed attempts */
|
|
113
|
+
lockedOutUntil: number | null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create a new locked session.
|
|
117
|
+
*/
|
|
118
|
+
declare function createSession(timeoutMs?: number): SecureSession;
|
|
119
|
+
/**
|
|
120
|
+
* Unlock a secure session.
|
|
121
|
+
*/
|
|
122
|
+
declare function unlockSecureSession(session: SecureSession, reason?: UnlockReason): SecureSession;
|
|
123
|
+
/**
|
|
124
|
+
* Lock a secure session and clear sensitive state.
|
|
125
|
+
*/
|
|
126
|
+
declare function lockSecureSession(session: SecureSession): SecureSession;
|
|
127
|
+
/**
|
|
128
|
+
* Check if session has timed out.
|
|
129
|
+
*/
|
|
130
|
+
declare function isSessionTimedOut(session: SecureSession): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Wrapper for sensitive data that auto-zeros on disposal.
|
|
133
|
+
*/
|
|
134
|
+
declare class SecureBuffer {
|
|
135
|
+
private _data;
|
|
136
|
+
private _disposed;
|
|
137
|
+
constructor(data: Uint8Array);
|
|
138
|
+
/**
|
|
139
|
+
* Get a copy of the data (original stays protected).
|
|
140
|
+
*/
|
|
141
|
+
get data(): Uint8Array;
|
|
142
|
+
/**
|
|
143
|
+
* Get data length without exposing contents.
|
|
144
|
+
*/
|
|
145
|
+
get length(): number;
|
|
146
|
+
/**
|
|
147
|
+
* Check if buffer has been disposed.
|
|
148
|
+
*/
|
|
149
|
+
get isDisposed(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Zero and dispose the buffer.
|
|
152
|
+
*/
|
|
153
|
+
dispose(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Execute a function with the data, then dispose.
|
|
156
|
+
*/
|
|
157
|
+
useAndDispose<T>(fn: (data: Uint8Array) => Promise<T>): Promise<T>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Omnituum Tunnel v1 - Type Definitions
|
|
162
|
+
*
|
|
163
|
+
* Post-handshake encrypted tunnel interface.
|
|
164
|
+
* Handshake-agnostic: any key agreement can feed into this.
|
|
165
|
+
*
|
|
166
|
+
* @see pqc-docs/specs/tunnel.v1.md
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* Key material required to establish a tunnel session.
|
|
170
|
+
* Produced by any key agreement protocol (Noise, TLS, custom).
|
|
171
|
+
*/
|
|
172
|
+
interface TunnelKeyMaterial {
|
|
173
|
+
/** 32-byte key for outgoing messages */
|
|
174
|
+
sendKey: Uint8Array;
|
|
175
|
+
/** 32-byte key for incoming messages */
|
|
176
|
+
recvKey: Uint8Array;
|
|
177
|
+
/** 24-byte base nonce for outgoing messages */
|
|
178
|
+
sendBaseNonce: Uint8Array;
|
|
179
|
+
/** 24-byte base nonce for incoming messages */
|
|
180
|
+
recvBaseNonce: Uint8Array;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A secure tunnel session for post-handshake communication.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { createTunnelSession } from '@omnituum/pqc-shared';
|
|
188
|
+
*
|
|
189
|
+
* const tunnel = createTunnelSession(keys);
|
|
190
|
+
*
|
|
191
|
+
* // Send a message
|
|
192
|
+
* const ciphertext = tunnel.encrypt(plaintext);
|
|
193
|
+
*
|
|
194
|
+
* // Receive a message
|
|
195
|
+
* const plaintext = tunnel.decrypt(ciphertext);
|
|
196
|
+
* if (!plaintext) throw new Error('Authentication failed');
|
|
197
|
+
*
|
|
198
|
+
* // Clean up
|
|
199
|
+
* tunnel.close();
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
interface PQCTunnelSession {
|
|
203
|
+
/**
|
|
204
|
+
* Encrypt plaintext for transmission.
|
|
205
|
+
* Automatically increments the send counter.
|
|
206
|
+
*
|
|
207
|
+
* @param plaintext - Data to encrypt
|
|
208
|
+
* @param aad - Optional additional authenticated data
|
|
209
|
+
* @returns Ciphertext with authentication tag
|
|
210
|
+
* @throws Error if tunnel is closed
|
|
211
|
+
*/
|
|
212
|
+
encrypt(plaintext: Uint8Array, aad?: Uint8Array): Uint8Array;
|
|
213
|
+
/**
|
|
214
|
+
* Decrypt received ciphertext.
|
|
215
|
+
* Automatically increments the receive counter.
|
|
216
|
+
*
|
|
217
|
+
* @param ciphertext - Data to decrypt (includes auth tag)
|
|
218
|
+
* @param aad - Optional additional authenticated data (must match encryption)
|
|
219
|
+
* @returns Plaintext, or null if authentication fails
|
|
220
|
+
* @throws Error if tunnel is closed
|
|
221
|
+
*/
|
|
222
|
+
decrypt(ciphertext: Uint8Array, aad?: Uint8Array): Uint8Array | null;
|
|
223
|
+
/**
|
|
224
|
+
* Securely close the tunnel.
|
|
225
|
+
* Zeros all key material and rejects further operations.
|
|
226
|
+
*/
|
|
227
|
+
close(): void;
|
|
228
|
+
/**
|
|
229
|
+
* Check if the tunnel is still open.
|
|
230
|
+
*/
|
|
231
|
+
readonly isOpen: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Get current send counter (for debugging/monitoring).
|
|
234
|
+
*/
|
|
235
|
+
readonly sendCounter: bigint;
|
|
236
|
+
/**
|
|
237
|
+
* Get current receive counter (for debugging/monitoring).
|
|
238
|
+
*/
|
|
239
|
+
readonly recvCounter: bigint;
|
|
240
|
+
}
|
|
241
|
+
/** Tunnel version string */
|
|
242
|
+
declare const TUNNEL_VERSION: "omnituum.tunnel.v1";
|
|
243
|
+
/** Key size in bytes (32 = 256 bits) */
|
|
244
|
+
declare const TUNNEL_KEY_SIZE = 32;
|
|
245
|
+
/** Base nonce size in bytes (24 for XChaCha20) */
|
|
246
|
+
declare const TUNNEL_NONCE_SIZE = 24;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Omnituum Tunnel v1 - Session Implementation
|
|
250
|
+
*
|
|
251
|
+
* XChaCha20-Poly1305 encrypted tunnel with counter-based nonces.
|
|
252
|
+
* Handshake-agnostic: accepts any TunnelKeyMaterial producer.
|
|
253
|
+
*
|
|
254
|
+
* @see pqc-docs/specs/tunnel.v1.md
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Create a secure tunnel session from key material.
|
|
259
|
+
*
|
|
260
|
+
* @param keys - Key material from handshake (Noise, TLS, etc.)
|
|
261
|
+
* @returns Tunnel session for encrypted communication
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* // From Noise handshake
|
|
266
|
+
* const keys = toTunnelKeyMaterial(noiseState);
|
|
267
|
+
* const tunnel = createTunnelSession(keys);
|
|
268
|
+
*
|
|
269
|
+
* // Send encrypted message
|
|
270
|
+
* const ciphertext = tunnel.encrypt(plaintext);
|
|
271
|
+
* channel.send(ciphertext);
|
|
272
|
+
*
|
|
273
|
+
* // Receive encrypted message
|
|
274
|
+
* const plaintext = tunnel.decrypt(received);
|
|
275
|
+
*
|
|
276
|
+
* // Clean up when done
|
|
277
|
+
* tunnel.close();
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare function createTunnelSession(keys: TunnelKeyMaterial): PQCTunnelSession;
|
|
281
|
+
|
|
282
|
+
export { type KDFAlgorithm, type KDFConfig, KDF_CONFIG_ARGON2ID, KDF_CONFIG_PBKDF2, type PQCTunnelSession, SecureBuffer, type SecureSession, TUNNEL_KEY_SIZE, TUNNEL_NONCE_SIZE, TUNNEL_VERSION, type TunnelKeyMaterial, type UnlockReason, benchmarkKDF, constantTimeEqual, createSession, createTunnelSession, generateSalt, getRecommendedConfig, isSessionTimedOut, kdfDeriveKey, lockSecureSession, unlockSecureSession, withSecureData, zeroAll, zeroMemory };
|