Skip to content
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

suggest adding a check for shouldPrepare() in RecordLayer when sending record data #181

Open
GSoJC234 opened this issue Nov 13, 2024 · 0 comments

Comments

@GSoJC234
Copy link

Hello,

I noticed that the Record class supports the shouldPrepare option; however,
the sendConfiguration and sendData methods in the RecordLayer class currently do not account for cases where shouldPrepare is set to false.

To enhance functionality, I suggest adding a check for shouldPrepare within both sendConfiguration and sendData methods before creating a RecordPreparator object.
Here's an example of how this could be implemented

In the sendConfiguration method

if (encryptor.getRecordCipher(writeEpoch).getState().getVersion().isDTLS() && record.getEpoch() == null) {
    record.setEpoch(writeEpoch);
}
if (record.getCleanProtocolMessageBytes() == null) {
    record.setCleanProtocolMessageBytes(new byte[0]);
}
// add checking shouldPrepare option
if (record.shouldPrepare()){
    RecordPreparator preparator = record.getRecordPreparator(context, encryptor, compressor, contentType);
    preparator.prepare();
    preparator.afterPrepare();
}

In the sendData method

for (Record record : records) {
    ProtocolMessageType contentType = record.getContentMessageType();
    if (contentType == null) {
        contentType = type;
    }
    if (encryptor.getRecordCipher(writeEpoch).getState().getVersion().isDTLS()) {
        record.setEpoch(writeEpoch);
    }
// add checking shouldPrepare option
    if (record.shouldPrepare()){
        RecordPreparator preparator =
                record.getRecordPreparator(context, encryptor, compressor, contentType);
        preparator.prepare();
        preparator.afterPrepare();
    }

Additionally, while the RecordLayer class extends ProtocolLayer class, which implements the prepareDataContainer method,
it currently supports only a default record preparator, which assigns null value to both the encryptor and decryptor fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant