Skip to content

Conversation

@p1gp1g
Copy link

@p1gp1g p1gp1g commented Jan 10, 2025

Bring back openssl3 support and fix encryption

Copy link
Collaborator

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

Hi! Thank you for your contribution.

First, can you rebase this PR? main should have the OpenSSL 3 fixes already.

I'm not very knowledgeable about RFC8291 and aes128gcm, but my understanding is that the current code is already correct, and your changes amount to:

  • checking message size before encryption for earlier error handling
  • removing an unnecessary byte of padding after the padding delimiter
  • choosing a fixed value of 4096 for the record size

@p1gp1g
Copy link
Author

p1gp1g commented Jan 13, 2025

Hi! Thank you for your contribution.

First, can you rebase this PR? main should have the OpenSSL 3 fixes already.

I've rebased the branch

I'm not very knowledgeable about RFC8291 and aes128gcm, but my understanding is that the current code is already correct, and your changes amount to:

* checking message size before encryption for earlier error handling

* removing an unnecessary byte of padding after the padding delimiter

* choosing a fixed value of 4096 for the record size

It is currently not possible to decrypt push messages with other libs, the error may come from that extra padding or from a wrong RS.

Removing that extra padding and using the fixed RS fixes decryption with other libs (tested with tink used by UnifiedPush lib), and also allow testing against the RFC example (that is what I've implemented in mastodon PR)

@ClearlyClaire
Copy link
Collaborator

Right, so this PR changes various parameters to use the particular ones used in the RFC example to be able to use it as a verifiable example.

As for tink failing to process our messages without changes, I was not aware of that and will look into it, as it sounds like an issue with tink.

@p1gp1g
Copy link
Author

p1gp1g commented Jan 13, 2025

I haven't check if there were an issue on tink side

@ClearlyClaire
Copy link
Collaborator

@ClearlyClaire ClearlyClaire changed the title Fix encryption Fix compatibility with UnifiedPush/tink Jan 13, 2025
@ClearlyClaire ClearlyClaire merged commit 9631ac6 into mastodon:main Jan 13, 2025
@p1gp1g
Copy link
Author

p1gp1g commented Jan 13, 2025

Maybe the decryption was correct and the error come from that RS indeed 👍

The extra padding could let message with exact length of 3993 to fail even if it could succeed

@p1gp1g
Copy link
Author

p1gp1g commented Feb 4, 2025

@ClearlyClaire : There was indeed a bug in tink: tink-crypto/tink-java-apps#5

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

Successfully merging this pull request may close these issues.

2 participants