Skip to content

Protected header should not be re-serialized for verification. #7

@shizhMSFT

Description

@shizhMSFT

The verification process of COSE Sign1 signature is as below.

msg := &cose.Sign1Message{}
err := cbor.Unmarshal(sign, msg)
check(err)

err = msg.Verify(nil, *verifier)
check(err)

To verify the message, we need to unmarhsal the binary data to a Sign1Message structure. In the unmarhsal process, the protected header (encoded as a binary string) is deserialized into a map.

Later in msg.Verify() calls EncodeProtected() to re-serialized the protected header map back to a binary string for computing the digest-to-be-verified. Although canonical encoding is applied, the re-serialized protected header may not be the same as the original header, especially the header is encoded with tags. Hence, the verification will fail.

We should refactor the go-cose library so that the original protected header in the binary string form is used in the digest computation withour re-serialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions