Replies: 5 comments 8 replies
-
I'm unsure what exactly you want to do in your use case. But generally you would want to use the Intel DCAP libraries. Gramine uses them like this, if you're interested in the source code: gramine/tools/sgx/ra-tls/ra_tls_verify_dcap.c Lines 126 to 260 in a60dcf7 The two important Intel DCAP libraries APIs are:
You can check their documentation if you want to know more: https://download.01.org/intel-sgx/latest/dcap-latest/linux/docs/Intel_SGX_ECDSA_QuoteLibReference_DCAP_API.pdf The Intel DCAP library is called Line 257 in a60dcf7 IIRC, this DCAP library is part of the |
Beta Was this translation helpful? Give feedback.
-
Hey @dimakuv, I work with Patryk but on different field - basically what i'll try to do is, to verify the 'sgx proof' on-chain - via Solidity so therefore i'd like to ask some high-level questions. What i'm thinking is, to do the remote attestation verification off-chain, and once it is verified, then the sgx instance shall be identified by it's ECDSA pub. key (-> ethereum address). In my understanding, attestation is basically proving the identity (and trustworthiness of a machine) to a verifier. -> This can be done by diff. ways, but only need to be done at setup (with this proposed solution of mine) ? So something, high-level like:
OR Attestation necessary each and every time there is a new computation ? If former then i'd just not do attestation verification on-chain, simply done once at setup, if latter (maybe because that instance can make itself 'malicious' on the go(?if this is possible?)), then yes, we need to figure out something. |
Beta Was this translation helpful? Give feedback.
-
Dear @adaki2004, Yes, your understanding is correct, and your explanations look good to me. Just don't forget that you must tie the ECDSA pub key to the identity of the SGX enclave, as reported by the SGX quote. In other words, the SGX quote must bare some evidence that it was indeed generated in the SGX enclave that runs with this particular ECDSA pub key. In RA-TLS (and it's the main feature of RA-TLS), we bind the SGX quote with the ephemeral keypair created inside of the SGX enclave that is used to sign a self-signed X.509 certificate. The diagram shows how it is done: https://gramine.readthedocs.io/en/stable/attestation.html#mid-level-ra-tls-interface If you haven't yet, also read our RA-TLS whitepaper: https://arxiv.org/abs/1801.05863 (Gramine and RA-TLS are not unique in this solution. In fact, all SGX frameworks/runtimes use a variation of this scheme.)
There is another catch which is the SGX-attestation validity period. Imagine that your SGX enclave runs for several weeks non-stop. If you generated only one ECDSA key, and use its public part for authentication for several weeks, then the SGX enclave (or the underlying hardware) could be hi-jacked, secrets -- including the private ECDSA key -- could be stolen, and the SGX enclave is compromised. So typically people also add a rather-small validity period for the attestation token (in your case, the attestation token = ECDSA pub key). For example, Microsoft Azure Attestation sets this period to 8 hours: https://learn.microsoft.com/en-us/azure/attestation/faq#how-long-is-an-attestation-token-valid- TLDR: Your approach looks correct, but be aware of the aforementioned caveats. |
Beta Was this translation helpful? Give feedback.
-
Dear @dimakuv,
Regarding this, our initial plan is/was to always use another ECDSA key for signing the data to avoid side-channel attacks. So like this:
Would it work without expiry then ? Or we shall take other extra measures ? |
Beta Was this translation helpful? Give feedback.
-
@dimakuv, do you perhaps have some minimal example of RA-TLS implemented in Rust (instead of |
Beta Was this translation helpful? Give feedback.
-
I've prepared a simple demo repository that prints the SGX quote by reading
/dev/attestation/quote
(I'm usingDCAP
attestation). It seems to work fine because it prints a quote (at least that's what I think, since it prints a random string of bytes; see below). Now: how can I verify that SGX quote? Is that quote all I need to provide to the SGX DCAP verifier? I know Intel provides a reference verifier implementation, but it is very poorly documented and difficult to use for me. Maybe you have some tips that will help me verify the quote?In case you want to try out my demo:
Process the manifest file (BTW: does it generate
MRENCLAVE
at this point?)Sign the manifest file:
Run the app printing the SGX quote:
BTW, the demo above was inspired by the Gramine sample code: https://github.com/gramineproject/gramine/blob/master/CI-Examples/python/scripts/sgx-quote.py I just reimplemented it in Rust.
BTW2, quote from your docs:
but still seeking your help with that :)
Beta Was this translation helpful? Give feedback.
All reactions