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
|
||||
}
|
||||
|
||||
const streaming = this.supportsStreaming(tag);
|
||||
let packet = null;
|
||||
if (!format) {
|
||||
// 4.2.1. Old Format Packet Lengths
|
||||
|
@ -204,7 +205,6 @@ export default {
|
|||
break;
|
||||
}
|
||||
} else { // 4.2.2. New Format Packet Lengths
|
||||
const streaming = this.supportsStreaming(tag);
|
||||
let wasPartialLength;
|
||||
do {
|
||||
// 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() <<
|
||||
8) | await reader.readByte();
|
||||
}
|
||||
if (streaming) {
|
||||
if (controller) {
|
||||
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
|
||||
reader.releaseLock();
|
||||
packet = stream.subarray(stream.clone(input), 0, packet_length);
|
||||
|
@ -247,14 +251,10 @@ export default {
|
|||
// Read the entire packet before parsing the next one
|
||||
reader = stream.getReader(input);
|
||||
await reader.readBytes(packet_length);
|
||||
}
|
||||
}
|
||||
} while(wasPartialLength);
|
||||
}
|
||||
|
||||
if (!packet) {
|
||||
} else {
|
||||
packet = await reader.readBytes(packet_length);
|
||||
await callback({ tag, packet });
|
||||
}
|
||||
} else if (controller) {
|
||||
controller.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user