ADORSYS-GIS / ADORSYS-GIS/cloud-identity-wallet

Encrypted Authorization Response (direct_post.jwt)

Đang mở
#327 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
4
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Part of Epic #13

### Description

The `DirectPostResponseSender` currently only supports plain `direct_post` and returns `UnsupportedResponseMode` for `direct_post.jwt`. Implement an `EncryptedResponseSender` that:

1. Serializes the Authorization Response JSON payload.
2. Encrypts it as a JWE using the Verifier's encryption JWK from its metadata (`jwks` or `jwks_uri`, `use: "enc"`).
3. Key management: `ECDH-ES` (HAIP mandatory) with support for `ECDH-ES+A128KW`, `ECDH-ES+A256KW`.
4. Content encryption: `A128GCM`, `A256GCM`, `A128CBC-HS256` (per HAIP, `A128GCM` or `A256GCM`).
5. POSTs the compact JWE in the `response` form parameter to the `response_uri`.

### File Placement

`crates/cloud-wallet-openid4vc/src/oid4vp/response_mode/encrypted.rs`

### Spec References

- [OpenID4VP §8.3 — Response Mode direct_post.jwt](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#section-8.3)
- [HAIP §6.4 — Response Encryption](https://openid.net/specs/openid4vc-high-assurance-interoperability-profile-1_0.html)
- [RFC 7516 — JWE](https://tools.ietf.org/html/rfc7516)
- [RFC 7518 §4.6 — ECDH-ES](https://tools.ietf.org/html/rfc7518#section-4.6)

### Acceptance Criteria

- [ ] `EncryptedResponseSender` implementing `AuthorizationResponseSender`.
- [ ] Constructor accepts the Verifier's encryption JWK (from metadata).
- [ ] JWE construction using `ECDH-ES` + `A128GCM` (HAIP default).
- [ ] The `response` form field carries a valid compact JWE (5 dot-separated parts).
- [ ] Existing `CompactJwe` type reused for structural validation.
- [ ] Falls back to `direct_post` if `response_mode` is not `direct_post.jwt`.
- [ ] Key type validation: rejects non-EC keys for `ECDH-ES`.
- [ ] Unit tests for: successful encryption + decryption round-trip, invalid key type rejection, `CompactJwe` structural validation.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.