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

Fixing errors with OpenSSL 1.0/1.1 #105

Merged
merged 6 commits into from
Feb 5, 2024
Merged

Conversation

dutow
Copy link
Collaborator

@dutow dutow commented Jan 22, 2024

Issue: there's a slight behavior difference between OpenSSL 1.1 and 3.0 in regards to padding, and how the EVP encryption/decryption functions exactly behave.

Our code also incorrectly used these functions until now, which by chance worked correctly with 3.0, but caused decryption issues with 1.0/1.1.

This commit:

  • Fixes the issue
  • Adds a few related assertions
  • Adds an Ubuntu 20.04 (OpenSSL 1.1) github runner to verify that everything works correctly with 1.1.

Issue: there's a slight behavior difference between OpenSSL 1.1 and 3.0
in regards to padding, and how the EVP encryption/decryption functions
exactly behave.

Our code also incorrectly used these functions until now, which by chance
worked correctly with 3.0, but caused decryption issues with 1.0/1.1.

This commit:

* Fixes the issue
* Adds a few related assertions
* Adds an Ubuntu 20.04 (OpenSSL 1.1) github runner to verify that everything
  works correctly with 1.1.
src/encryption/enc_aes.c Show resolved Hide resolved
src/encryption/enc_aes.c Show resolved Hide resolved
@@ -102,12 +102,11 @@ AesRun2(EVP_CIPHER_CTX** ctxPtr, int enc, const unsigned char* key, const unsign

static void AesRun(int enc, const unsigned char* key, const unsigned char* iv, const unsigned char* in, int in_len, unsigned char* out, int* out_len)
{
int out_len2 = 0;
Copy link
Contributor

@hqakhtar hqakhtar Jan 24, 2024

Choose a reason for hiding this comment

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

We need some comments about why out_len2 is required so that people who don't understand SSL can also understand the changes. And perhaps changing the name of out_len2 to something that more self-explanatory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I already added a comment around the second assertion

@dutow dutow requested a review from dAdAbird January 25, 2024 12:32
@@ -141,6 +144,11 @@ static void AesRun(int enc, const unsigned char* key, const unsigned char* iv, c
goto cleanup;
}

// We encrypt one block (16 bytes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use multiline comments /* ... */ instead of single line ones.

Copy link
Contributor

@hqakhtar hqakhtar left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@codeforall codeforall left a comment

Choose a reason for hiding this comment

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

Looks good

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.

3 participants