Skip to content

Commit 5decc72

Browse files
committed
fix: supported algorithm check
1 parent d50f8a7 commit 5decc72

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

example/satosa/pyeudiw_backend.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ config:
181181
- module: pyeudiw.openid4vp.vp_sd_jwt_vc
182182
class: VpVcSdJwtParserVerifier
183183
format: dc+sd-jwt
184+
config:
185+
sig_alg_supported: *sig_alg_supported
184186
- module: pyeudiw.openid4vp.vp_mdoc_cbor
185187
class: VpMDocCbor
186188
format: mso_mdoc

pyeudiw/openid4vp/vp_sd_jwt_vc.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,23 @@
66
from pyeudiw.jwt.utils import decode_jwt_header
77
from pyeudiw.sd_jwt.schema import is_sd_jwt_kb_format
88
from pyeudiw.openid4vp.presentation_submission.base_vp_parser import BaseVPParser
9+
from pyeudiw.trust.dynamic import CombinedTrustEvaluator
910

1011

1112
class VpVcSdJwtParserVerifier(BaseVPParser):
13+
14+
def __init__(self, trust_evaluator: CombinedTrustEvaluator, sig_alg_supported: list[str] = [], **kwargs) -> None:
15+
"""
16+
Initialize the VpVcSdJwtParserVerifier with the trust evaluator.
17+
18+
:param trust_evaluator: The trust evaluator instance.
19+
:type trust_evaluator: CombinedTrustEvaluator
20+
:param sig_alg_supported: List of supported signature algorithms.
21+
:type sig_alg_supported: list[str]
22+
"""
23+
self.sig_alg_supported = sig_alg_supported
24+
super().__init__(trust_evaluator, **kwargs)
25+
1226
def _get_issuer_name(self, sdjwt: SdJwt) -> str:
1327
"""
1428
Get the issuer name from the token payload.
@@ -47,6 +61,10 @@ def validate(
4761
static_trust_materials = {}
4862
header = decode_jwt_header(token)
4963

64+
alg = header.get("alg", None)
65+
if alg not in self.sig_alg_supported:
66+
raise ValueError(f"Unsupported algorithm: {alg}")
67+
5068
if "x5c" in header:
5169
static_trust_materials["x5c"] = header["x5c"]
5270

pyeudiw/tests/settings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,16 @@
324324
"module": "pyeudiw.openid4vp.vp_sd_jwt_vc",
325325
"class": "VpVcSdJwtParserVerifier",
326326
"format": "dc+sd-jwt",
327+
"config": {
328+
"sig_alg_supported": [
329+
"RS256",
330+
"RS384",
331+
"RS512",
332+
"ES256",
333+
"ES384",
334+
"ES512",
335+
]
336+
}
327337
},
328338
{
329339
"module": "pyeudiw.openid4vp.vp_mdoc_cbor",

0 commit comments

Comments
 (0)