Streaming decrypt old-format packets
This commit is contained in:
parent
9fcc075f0b
commit
ead3ddd706
|
@ -169,6 +169,7 @@ export default {
|
||||||
packet_length_type = headerByte & 0x03; // bit 1-0
|
packet_length_type = headerByte & 0x03; // bit 1-0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const streaming = this.supportsStreaming(tag);
|
||||||
let packet = null;
|
let packet = null;
|
||||||
if (!format) {
|
if (!format) {
|
||||||
// 4.2.1. Old Format Packet Lengths
|
// 4.2.1. Old Format Packet Lengths
|
||||||
|
@ -204,7 +205,6 @@ export default {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else { // 4.2.2. New Format Packet Lengths
|
} else { // 4.2.2. New Format Packet Lengths
|
||||||
const streaming = this.supportsStreaming(tag);
|
|
||||||
let wasPartialLength;
|
let wasPartialLength;
|
||||||
do {
|
do {
|
||||||
// 4.2.2.1. One-Octet Lengths
|
// 4.2.2.1. One-Octet Lengths
|
||||||
|
@ -235,10 +235,14 @@ export default {
|
||||||
packet_length = (await reader.readByte() << 24) | (await reader.readByte() << 16) | (await reader.readByte() <<
|
packet_length = (await reader.readByte() << 24) | (await reader.readByte() << 16) | (await reader.readByte() <<
|
||||||
8) | await reader.readByte();
|
8) | await reader.readByte();
|
||||||
}
|
}
|
||||||
if (streaming) {
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
controller.enqueue(await reader.readBytes(packet_length));
|
controller.enqueue(await reader.readBytes(packet_length));
|
||||||
} else {
|
}
|
||||||
|
} while(wasPartialLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!packet) {
|
||||||
|
if (streaming) {
|
||||||
// Send the remainder of the packet to the callback as a stream
|
// Send the remainder of the packet to the callback as a stream
|
||||||
reader.releaseLock();
|
reader.releaseLock();
|
||||||
packet = stream.subarray(stream.clone(input), 0, packet_length);
|
packet = stream.subarray(stream.clone(input), 0, packet_length);
|
||||||
|
@ -247,14 +251,10 @@ export default {
|
||||||
// Read the entire packet before parsing the next one
|
// Read the entire packet before parsing the next one
|
||||||
reader = stream.getReader(input);
|
reader = stream.getReader(input);
|
||||||
await reader.readBytes(packet_length);
|
await reader.readBytes(packet_length);
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
} while(wasPartialLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!packet) {
|
|
||||||
packet = await reader.readBytes(packet_length);
|
packet = await reader.readBytes(packet_length);
|
||||||
await callback({ tag, packet });
|
await callback({ tag, packet });
|
||||||
|
}
|
||||||
} else if (controller) {
|
} else if (controller) {
|
||||||
controller.close();
|
controller.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user