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

Fix value EVP_PKEY_OP_TYPE_CRYPT as declared by OpenSSL #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

squaresmini
Copy link

@squaresmini squaresmini commented Nov 22, 2024

After upgrading OpenResty from 1.21.4.4 to 1.27.1.1, decryption of JWE fails with error "failed to decrypt key: invalid operation".

The error is raised by this line, and the err value comes from this line in OpenSSL project.

The reason should be the following:

  • at this line the value of EVP_PKEY_OP_TYPE_CRYPT is 768 (1 << 8) | (1 << 9), while in Openssl is 1536 (1 << 9) | (1 << 10) as described here.
  • Since EVP_PKEY_OP_DECRYPT equals (1 << 10), the bitwise comparison (ctx->operation & optype) returns 0, because optype = 768. However, this value has not been changed between OpenSSL versions.
  • For reasons I don't fully understand, in Openssl 1.1.1n, this line is not triggered, wheras in Openssl 3.0.15 it is.

Changing EVP_PKEY_OP_TYPE_CRYPT should fix the problem.

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

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