if (!this.secrets.length) {
throw new Error('missing encryption secret');
}
- // TODO: support secret rolling
// Filter any unavailable algorithms
const availableCiphers = crypto.getCiphers();
const raw = Buffer.from(base64URLToBase64(box), 'base64');
let offset = 0;
- const version = raw.slice(offset, 1).readUInt8(0);
+ const version = raw.subarray(offset, 1).readUInt8(0);
if (!(version in this.versionParameters)) {
throw new RangeError('unsupported version');
}
throw new RangeError('not enough to unpack');
}
- const flags = raw.slice(offset, offset + v.flagsBytes).readUInt8(0);
+ const flags = raw.subarray(offset, offset + v.flagsBytes).readUInt8(0);
offset += v.flagsBytes;
const { compression, payloadIsBuffer } = MysteryBox._decodeFlags(flags);
- const iv = raw.slice(offset, offset + v.ivBytes);
+ const iv = raw.subarray(offset, offset + v.ivBytes);
offset += v.ivBytes;
- const salt = raw.slice(offset, offset + v.saltBytes);
+ const salt = raw.subarray(offset, offset + v.saltBytes);
offset += v.saltBytes;
- const aad = raw.slice(0, offset); // Everything up to here
+ const aad = raw.subarray(0, offset); // Everything up to here
- const tag = raw.slice(offset, offset + v.tagBytes);
+ const tag = raw.subarray(offset, offset + v.tagBytes);
offset += v.tagBytes;
- const encrypted = raw.slice(offset);
+ const encrypted = raw.subarray(offset);
timingsMs.preCrypt = performance.now();