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

Refactoring of the encryptPacket method #123

Merged
merged 1 commit into from Nov 21, 2022

Conversation

artemredkin
Copy link
Contributor

Motivation:
I think there is a bit of a mix of responsibilities between TransportProtection and PacketSerializer. PacketSerializer is responsible for writing out plaintext packet structure, but encrypted packet structure is written out by the TransportProtection implementations. This means that we will have duplicate implementations of basic packet writing logic, every implementation of TP will have to write length, padding length, payload and padding. Also, right now this API uses EncryptablePayload, which we cannot make fully public and accessible for writing tests as it will mean making all SSHMessages public as well.

Modifications:

  • Extract packet writing logic to a separate function that will be used by both plaintext and ciphertext modes
  • Removes usage of EncryptablePayload
  • Write plaintext packet structure (including payload) in the parser
  • TransportProtection implementations now only have to encrypt and tag

@artemredkin artemredkin changed the title refactoring of the encryptPacket method Refactoring of the encryptPacket method Oct 25, 2022
Motivation:
I think there is a bit of a mix of responsibilities between
TransportProtection and PacketSerializer. PacketSerializer is
responsible for writing out plaintext packet structure, but encrypted
packet structure is written out by the TransportProtection
implementations. This means that we will have duplicate implementations
of basic packet writing logic, every implementation of TP will have to
write length, padding length, payload and padding. Also, right now this
API uses EncryptablePayload, which we cannot make fully public and
accessible for writing tests as it will mean making all SSHMessages
public as well.

Modifications:
 - Extract packet writing logic to a separate function that will be
   used by both plaintext and ciphertext modes
 - Removes usage of EncryptablePayload
 - Write plaintext packet structure (including payload) in the parser
 - TransportProtection implementations now only have to encrypt and tag
@artemredkin artemredkin force-pushed the refactor_transport_protection_api branch from c59354c to f31df60 Compare November 7, 2022 11:41
Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, this LGTM!

@Lukasa Lukasa added the 🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0 label Nov 21, 2022
@Lukasa
Copy link
Collaborator

Lukasa commented Nov 21, 2022

This breaks our API, but we haven't gone 1.0 yet so this will just take us to 0.5.0.

@Lukasa Lukasa merged commit a48586f into apple:main Nov 21, 2022
@artemredkin
Copy link
Contributor Author

We made parts of TransportProtection APIs public with #97 and we haven't tagged anything yet, this only changes that part, yes

@artemredkin artemredkin deleted the refactor_transport_protection_api branch November 22, 2022 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants