Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSON marshalling for TPM 2.0 digests #18

Open
orangecms opened this issue Aug 15, 2021 · 2 comments
Open

Fix JSON marshalling for TPM 2.0 digests #18

orangecms opened this issue Aug 15, 2021 · 2 comments

Comments

@orangecms
Copy link
Contributor

This is what it looks like as of now:
fiedka/fiedka@8eb18d0#diff-37dfadeb85117fdfb03addf286bc6002bfac2f93091f7595e1a5b8d39093c199R11

It appears that marshalling heterogeneous data structures in Go is a bit involved. I'm trying to see how it can be done at all.
There is a corresponding TODO: 6e61994#diff-be86e8a168afe2b653da62f7d8f9d44c907b55446fb34edb49ff861c01662e7cR143

@orangecms
Copy link
Contributor Author

It should be like this:

{
  "data": "R\u00001\u0000B\u0000E\u0000T\u00006\u00000\u0000W",
  "digests": [
    {
      "algorithm": "SHA1",
      "digest": "3442feda234..."
    }
  ],
  "type": "EV_S_CRTM_VERSION"
}

Currently: "digests": "{}" - so yea, instead of a map of string to string, it needs to be a map of string to number|string|boolean|array|object, as JSON defines, but Go doesn't have unions. I read that some people use interfaces to mimic that. However, that isn't really yet the full solution AFIUI. I tried various things including map[string]json.RawMessage, but I couldn't figure it out.

@orangecms
Copy link
Contributor Author

I have a "solution" 😨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant