From 0ccffe528079894c4ce1aa66acb81e39f172582c Mon Sep 17 00:00:00 2001 From: roman_harazha Date: Fri, 8 Mar 2024 20:01:29 +0200 Subject: [PATCH] fix signed attributes validation --- internal/service/api/handlers/create_identity.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/api/handlers/create_identity.go b/internal/service/api/handlers/create_identity.go index 7a7f373..b71523b 100644 --- a/internal/service/api/handlers/create_identity.go +++ b/internal/service/api/handlers/create_identity.go @@ -279,12 +279,12 @@ func validateSignedAttributes(signedAttributes, encapsulatedContent []byte, algo return errors.Wrap(err, "failed to unmarshal ASN1 with params") } - if len(signedAttributesASN1) < 2 { - return errors.New("signed attributes amount is less than 2") + if len(signedAttributesASN1) == 0 { + return errors.New("signed attributes amount is 0") } digestAttr := resources.DigestAttribute{} - if _, err := asn1.Unmarshal(signedAttributesASN1[1].FullBytes, &digestAttr); err != nil { + if _, err := asn1.Unmarshal(signedAttributesASN1[len(signedAttributesASN1)-1].FullBytes, &digestAttr); err != nil { return errors.Wrap(err, "failed to unmarshal ASN1") }