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

Encrypted Authorization Response (direct_post.jwt)

Aperta
#327 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
4
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.