Skip to content

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