From f7363dc2e737a62b40ac94d5fc8ef36b3c9ef96d Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Thu, 4 Apr 2024 13:48:24 +0545 Subject: [PATCH] feat: Suppot _sd_alg = sha-256 only #2560 --- lib/oidc4vc/add_oidc4vc_credential.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/oidc4vc/add_oidc4vc_credential.dart b/lib/oidc4vc/add_oidc4vc_credential.dart index e9a907665..61ac1c930 100644 --- a/lib/oidc4vc/add_oidc4vc_credential.dart +++ b/lib/oidc4vc/add_oidc4vc_credential.dart @@ -32,6 +32,17 @@ Future addOIDC4VCCredential({ final jsonContent = jwtDecode.parseJwt(data); if (format == VCFormatType.vcSdJWT.value) { + final sdAlg = jsonContent['_sd_alg']; + + if (sdAlg == null || sdAlg != 'sha-256') { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': 'Only sha-256 is supported.', + }, + ); + } + credentialFromOIDC4VC = jsonContent; } else { credentialFromOIDC4VC = jsonContent['vc'] as Map;