@the9ines/bolt-core 0.6.3 → 0.6.4
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/dist/crypto.js +5 -1
- package/package.json +1 -1
package/dist/crypto.js
CHANGED
|
@@ -28,11 +28,14 @@ export function sealBoxPayload(plaintext, remotePublicKey, senderSecretKey) {
|
|
|
28
28
|
return wasm.sealBoxPayload(plaintext, remotePublicKey, senderSecretKey);
|
|
29
29
|
const nonce = randomBytes(box.nonceLength);
|
|
30
30
|
const encrypted = box(plaintext, nonce, remotePublicKey, senderSecretKey);
|
|
31
|
-
if (!encrypted)
|
|
31
|
+
if (!encrypted) {
|
|
32
|
+
nonce.fill(0); // Zeroize on error path too
|
|
32
33
|
throw new EncryptionError('Encryption returned null');
|
|
34
|
+
}
|
|
33
35
|
const combined = new Uint8Array(nonce.length + encrypted.length);
|
|
34
36
|
combined.set(nonce);
|
|
35
37
|
combined.set(encrypted, nonce.length);
|
|
38
|
+
nonce.fill(0); // Best-effort nonce zeroization (ENDPOINT-SECURITY-1, F-MED-01)
|
|
36
39
|
return toBase64(combined);
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
@@ -53,6 +56,7 @@ export function openBoxPayload(sealed, senderPublicKey, receiverSecretKey) {
|
|
|
53
56
|
const nonce = data.slice(0, box.nonceLength);
|
|
54
57
|
const ciphertext = data.slice(box.nonceLength);
|
|
55
58
|
const decrypted = box.open(ciphertext, nonce, senderPublicKey, receiverSecretKey);
|
|
59
|
+
nonce.fill(0); // Best-effort nonce zeroization (ENDPOINT-SECURITY-1, F-MED-01)
|
|
56
60
|
if (!decrypted)
|
|
57
61
|
throw new EncryptionError('Decryption failed');
|
|
58
62
|
return decrypted;
|