Skip to content

fix: sif frame enqueing with e2ee #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions web/e2ee.cryptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class FrameCryptor {

var srcFrame = readFrameInfo(frameObj);

logger.fine(
logger.finer(
'encodeFunction: buffer ${srcFrame.buffer.length}, synchronizationSource ${srcFrame.ssrc} frameType ${srcFrame.frameType}');

var secretKey = keyHandler.getKeySet(currentKeyIndex)?.encryptionKey;
Expand Down Expand Up @@ -479,7 +479,7 @@ class FrameCryptor {
var srcFrame = readFrameInfo(frameObj);
var ratchetCount = 0;

logger.fine('decodeFunction: frame lenght ${srcFrame.buffer.length}');
logger.finer('decodeFunction: frame length ${srcFrame.buffer.length}');

ByteBuffer? decrypted;
KeySet? initialKeySet;
Expand All @@ -490,9 +490,8 @@ class FrameCryptor {
srcFrame.buffer.isEmpty) {
sifGuard.recordUserFrame();
if (keyOptions.discardFrameWhenCryptorNotReady) return;
logger.fine('enqueing empty frame');
logger.fine('enqueing empty dtx frame');
controller.enqueue(frameObj);
logger.finer('enqueing silent frame');
return;
}

Expand All @@ -508,20 +507,19 @@ class FrameCryptor {
if (sifGuard.isSifAllowed()) {
var frameType =
srcFrame.buffer.sublist(srcFrame.buffer.length - 1)[0];
logger
.finer('ecodeFunction: skip uncrypted frame, type $frameType');
logger.finer(
'encodeFunction: skip unencrypted frame, type $frameType');
var finalBuffer = BytesBuilder();
finalBuffer.add(Uint8List.fromList(srcFrame.buffer
.sublist(0, srcFrame.buffer.length - (magicBytes.length + 1))));
logger.fine(
'encodeFunction: enqueing silent frame');
enqueueFrame(frameObj, controller, finalBuffer);
logger.fine('ecodeFunction: enqueing silent frame');
controller.enqueue(frameObj);
return;
} else {
logger.finer('ecodeFunction: SIF limit reached, dropping frame');
logger.fine('encodeFunction: SIF limit reached, dropping frame');
return;
}
logger.finer('ecodeFunction: enqueing silent frame');
controller.enqueue(frameObj);
return;
} else {
sifGuard.recordUserFrame();
}
Expand Down Expand Up @@ -678,7 +676,7 @@ class FrameCryptor {
});
}

logger.fine(
logger.finer(
'decodeFunction[CryptorError.kOk]: decryption success kind $kind, headerLength: $headerLength, timestamp: ${srcFrame.timestamp}, ssrc: ${srcFrame.ssrc}, data length: ${srcFrame.buffer.length}, decrypted length: ${finalBuffer.toBytes().length}, keyindex $keyIndex iv $iv');
} catch (e, s) {
logger.info('decodeFunction[CryptorError.kDecryptError]: $e, $s');
Expand Down
Loading