Skip to content

Commit

Permalink
Add AaSignature validation
Browse files Browse the repository at this point in the history
  • Loading branch information
J3imip committed Dec 10, 2024
1 parent 6bff281 commit 0d60b06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
26 changes: 13 additions & 13 deletions internal/service/api/handlers/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ func Register(w http.ResponseWriter, r *http.Request) {
}

func verifySod(
signedAttributes []byte,
encapsulatedContent []byte,
signature []byte,
cert *x509.Certificate,
algorithmPair types.AlgorithmPair,
cfg *config.VerifierConfig,
signedAttributes []byte,
encapsulatedContent []byte,
signature []byte,
cert *x509.Certificate,
algorithmPair types.AlgorithmPair,
cfg *config.VerifierConfig,
) error {
if err := validateSignedAttributes(signedAttributes, encapsulatedContent, algorithmPair.HashAlgorithm); err != nil {
return &types.SodError{
Expand Down Expand Up @@ -300,9 +300,9 @@ func parseCertificate(pemFile []byte) (*x509.Certificate, error) {
}

func validateSignedAttributes(
signedAttributes,
encapsulatedContent []byte,
hashAlgorithm types.HashAlgorithm,
signedAttributes,
encapsulatedContent []byte,
hashAlgorithm types.HashAlgorithm,
) error {
signedAttributesASN1 := make([]asn1.RawValue, 0)

Expand Down Expand Up @@ -340,10 +340,10 @@ func validateSignedAttributes(
}

func verifySignature(
signature []byte,
cert *x509.Certificate,
signedAttributes []byte,
algorithmPair types.AlgorithmPair,
signature []byte,
cert *x509.Certificate,
signedAttributes []byte,
algorithmPair types.AlgorithmPair,
) error {
h := types.GeneralHash(algorithmPair.HashAlgorithm)
h.Write(signedAttributes)
Expand Down
4 changes: 4 additions & 0 deletions internal/service/api/requests/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func validateRegister(r resources.RegisterResponse) error {
validation.Required,
validation.Length(1, 4096),
),
"/data/attributes/document_sod/aa_signature": validation.Validate(
r.Data.Attributes.DocumentSod.AaSignature,
validation.Length(0, 4096),
),
"/data/attributes/document_sod/pem_file": validation.Validate(
r.Data.Attributes.DocumentSod.PemFile,
validation.Required,
Expand Down

0 comments on commit 0d60b06

Please sign in to comment.