Skip to content

[jwe] Work with non X25519 ECDH encryption#1442

Merged
lestrrat merged 8 commits intodevelop/v3from
gh-1434
Aug 15, 2025
Merged

[jwe] Work with non X25519 ECDH encryption#1442
lestrrat merged 8 commits intodevelop/v3from
gh-1434

Conversation

@lestrrat
Copy link
Collaborator

@lestrrat lestrrat commented Aug 14, 2025

fixes #1434

This change introduces conversion from ECDH keys to ECDSA keys such that JWE encryption works for both types of raw keys.

@lestrrat lestrrat requested a review from Copilot August 14, 2025 09:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables JWE (JSON Web Encryption) to work with non-X25519 ECDH encryption by adding support for ECDH keys using P-256, P-384, and P-521 curves. The implementation introduces a conversion mechanism between ECDH and ECDSA key formats to leverage existing ECDSA encryption functions.

  • Adds ECDH to ECDSA key conversion functionality
  • Modifies JWE encryption logic to handle ECDH keys for non-X25519 curves
  • Includes comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/keyconv/keyconv.go Implements ECDHToECDSA conversion function and curve mapping utilities
internal/keyconv/keyconv_test.go Adds comprehensive tests for ECDH to ECDSA conversion functionality
jwe/encrypt.go Updates encryption logic to handle ECDH keys by converting to ECDSA when needed
jwe/jwe_test.go Adds basic test for ECDH key encryption/decryption
jwx_test.go Adds comprehensive interoperability tests with jose for different ECDH curves

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@lestrrat lestrrat merged commit 544d040 into develop/v3 Aug 15, 2025
23 checks passed
@lestrrat lestrrat deleted the gh-1434 branch August 15, 2025 01:33
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.

Encrypt with ECDH JWK, error: unsupported key type for ECDH-ES: *ecdsa.PrivateKey

2 participants