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

My summary of the proposal: is it correct? #2

Open
dimakuv opened this issue Jan 12, 2023 · 6 comments
Open

My summary of the proposal: is it correct? #2

dimakuv opened this issue Jan 12, 2023 · 6 comments

Comments

@dimakuv
Copy link

dimakuv commented Jan 12, 2023

Here is my summary of the current (as of 12. January 2023) proposal:

(I do not care about Endorsement Data Format currently; I'm only interested in the Evidence Data Format)

    /*
     * SGX-quote evidence has the following serialized-CBOR format:
     *
     * CBOR object (major type 6, new CBOR tag for "ECDSA SGX Quotes") ->
     *   CBOR array ->
     *      [
     *        0: CBOR bstr (SGX quote with user_report_data = hash(serialized-cbor-map of claims)),
     *        1: CBOR bstr (serialized-cbor-map of claims)
     *      ]
     *
     * where "serialized-cbor-map of claims" is as follows:
     *
     *   CBOR map ->
     *      {
     *        "pubkey-hash" (req) : CBOR bstr (serialized-cbor-array hash-entry),
     *        "nonce"       (opt) : CBOR bstr (arbitrary-sized nonce for per-session freshness)
     *      }
     *
     * where "serialized-cbor-array hash-entry" is as follows:
     *
     *   CBOR array ->
     *      [
     *        0: CBOR uint (hash-alg-id),
     *        1: CBOR bstr (hash-value -- hash of DER-formatted "SubjectPublicKeyInfo" field as CBOR bstr)
     *      ]
     *
     * For hash-alg-id values, see
     * https://www.iana.org/assignments/named-information/named-information.xhtml
     */

To put it differently, this is the process of creating an Evidence, step by step (basically, go backwards in the above diagram):

  1. Prepare hash-value CBOR bstr:
    1. Get DER-formatted "SubjectPublicKeyInfo" field from the X.509 cert
    2. Encode this field as CBOR bstr
    3. Calculate hash (e.g. SHA256) over this CBOR bstr
    4. Encode the calculated hash as CBOR bstr
  2. Prepare hash-entry CBOR array:
    1. Create hash-alg-id as CBOR unsigned integer (with value 1 which corresponds to the used hash SHA256)
    2. Put hash-alg-id as the first CBOR-array item
    3. Put hash-value (generated in previous step) as the second CBOR-array item
    4. Encode (serialize) the hash-entry CBOR array as CBOR bstr
  3. Prepare map of claims CBOR map:
    1. Put encoded (serialized) hash-entry CBOR bstr as the "pubkey-hash" item in the CBOR map
    2. Put nonce (if any) encoded as CBOR bstr as the "nonce" item in the CBOR map
    3. Encode (serialize) the map of claims CBOR map as CBOR bstr
  4. Prepare final CBOR array:
    1. Calculate SHA256 hash over map of claims CBOR bstr
    2. Generate the SGX quote with user_report_data field containing the calculated hash
    3. Encode (serialize) the SGX quote as CBOR bstr
    4. Put the encoded (serialized) SGX-quote CBOR bstr as the first CBOR-array item
    5. Put the encoded (serialized) map of claims CBOR bstr as the second CBOR-array item
  5. Prepare the final CBOR object:
    1. Use Major type 6 and new CBOR tag <tag1>
    2. Put the final CBOR array as the tagged data item (so-called tag content)

P.S. I tried to use terminology from the following sources:

@dimakuv
Copy link
Author

dimakuv commented Jan 12, 2023

To be honest, I dislike the current "onion" design of the Evidence data format: a serialized CBOR array inside of a serialized CBOR map inside of a CBOR array...

I would prefer to remove one layer of indirection here. For example:

     ...
     * where "serialized-cbor-map of claims" is as follows:
     *
     *   CBOR map ->
     *      {
     *        "pubkey-hash-value" (req) : CBOR bstr (hash of DER-formatted "SubjectPublicKeyInfo" field as CBOR bstr),
     *        "pubkey-hash-alg-id" (opt) : CBOR uint (if skipped, then assume SHA256),
     *        "nonce"       (opt) : CBOR bstr (arbitrary-sized nonce for per-session freshness)
     *      }

But then this doesn't follow the standard CoSWID definition of "hash-entry array"...

@imlk0
Copy link
Contributor

imlk0 commented Jan 13, 2023

My understanding of the proposal is consistent with the above diagram and process.

@dimakuv
Copy link
Author

dimakuv commented Jan 13, 2023

Thanks @KB5201314 for confirmation!

@shnwc
Copy link
Contributor

shnwc commented Jan 14, 2023

@dimakuv @KB5201314 Thank you for your summary! I've created PR #7 to edit the document for better clarity. Let me know if you have feedback to this PR.

@dimakuv
Copy link
Author

dimakuv commented Jan 16, 2023

PR #7 looks good to me. I'll keep this issue open for now, as I think my description may be helpful to others. (If you think otherwise, feel free to close the issue.)

@shnwc
Copy link
Contributor

shnwc commented Jan 17, 2023

How about creating a new document (like design notes) to capture the description? Committing PR #7 will close this issue automatically.

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

No branches or pull requests

3 participants