projects
/
squeep-mystery-box
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9b31aca
)
replace deprecated Buffer slice() calls with subarray()
author
Justin Wind
<justin.wind+git@gmail.com>
Sat, 17 Sep 2022 19:43:51 +0000
(12:43 -0700)
committer
Justin Wind
<justin.wind+git@gmail.com>
Sat, 17 Sep 2022 19:43:51 +0000
(12:43 -0700)
lib/mystery-box.js
patch
|
blob
|
history
diff --git
a/lib/mystery-box.js
b/lib/mystery-box.js
index cb85ebe698453a70f48f6af68bdad8d7cdeb9b08..2fb68a583e2c9b2408e37f7d17dcde212bb9a481 100644
(file)
--- a/
lib/mystery-box.js
+++ b/
lib/mystery-box.js
@@
-74,7
+74,6
@@
class MysteryBox {
if (!this.secrets.length) {
throw new Error('missing encryption secret');
}
if (!this.secrets.length) {
throw new Error('missing encryption secret');
}
- // TODO: support secret rolling
// Filter any unavailable algorithms
const availableCiphers = crypto.getCiphers();
// Filter any unavailable algorithms
const availableCiphers = crypto.getCiphers();
@@
-218,7
+217,7
@@
class MysteryBox {
const raw = Buffer.from(base64URLToBase64(box), 'base64');
let offset = 0;
const raw = Buffer.from(base64URLToBase64(box), 'base64');
let offset = 0;
- const version = raw.s
lice
(offset, 1).readUInt8(0);
+ const version = raw.s
ubarray
(offset, 1).readUInt8(0);
if (!(version in this.versionParameters)) {
throw new RangeError('unsupported version');
}
if (!(version in this.versionParameters)) {
throw new RangeError('unsupported version');
}
@@
-231,23
+230,23
@@
class MysteryBox {
throw new RangeError('not enough to unpack');
}
throw new RangeError('not enough to unpack');
}
- const flags = raw.s
lice
(offset, offset + v.flagsBytes).readUInt8(0);
+ const flags = raw.s
ubarray
(offset, offset + v.flagsBytes).readUInt8(0);
offset += v.flagsBytes;
const { compression, payloadIsBuffer } = MysteryBox._decodeFlags(flags);
offset += v.flagsBytes;
const { compression, payloadIsBuffer } = MysteryBox._decodeFlags(flags);
- const iv = raw.s
lice
(offset, offset + v.ivBytes);
+ const iv = raw.s
ubarray
(offset, offset + v.ivBytes);
offset += v.ivBytes;
offset += v.ivBytes;
- const salt = raw.s
lice
(offset, offset + v.saltBytes);
+ const salt = raw.s
ubarray
(offset, offset + v.saltBytes);
offset += v.saltBytes;
offset += v.saltBytes;
- const aad = raw.s
lice
(0, offset); // Everything up to here
+ const aad = raw.s
ubarray
(0, offset); // Everything up to here
- const tag = raw.s
lice
(offset, offset + v.tagBytes);
+ const tag = raw.s
ubarray
(offset, offset + v.tagBytes);
offset += v.tagBytes;
offset += v.tagBytes;
- const encrypted = raw.s
lice
(offset);
+ const encrypted = raw.s
ubarray
(offset);
timingsMs.preCrypt = performance.now();
timingsMs.preCrypt = performance.now();