Closed blmalone closed 3 years ago
@petreeftime Tagging you as you seem to be actively replying to recent issues.
@blmalone
The API call between the enclave and KMS is using HTTPS, so the data in transit is encrypted.
In addition, when kmstool-enclave
generates the attestation document, it attaches its public key (enclave public key) to it. The workflow is as follow (Ref: https://docs.aws.amazon.com/enclaves/latest/user/flow.html#attest-decrypt):
kmstool-enclave
generate RSA keypair and attach the public key (enclave public key) to the attestation documentkmstool-enclave
uses its private key to decrypt ciphertext 2 and get the plaintextAs long as the enclave private key doesn't go out of the enclave, even an attacker cracks the HTTPS encryption and gets the KMS response, he/she still cannot get the original plaintext.
If you take a look at the code, you will find it generating RSA keypair, putting the public key to the attestation document, and decrypting KMS response using the keypair:
I've created a sample project using Python to demonstrate the entire process, you can take a look and it may help you understand:
@richardfan1126 Thank you, great explanation.
I've been able to provision an EC2 instance with the Nitro Enclave sample running successfully.
After spending some time reading through the code, I'd like to piece together how KMS knows to decrypt the ciphertext and return the plaintext.
The sample application has two parts,
kmstool-enclave
andkmstool-instance
.Of course, after encrypting data
X
to keyY
(stored in KMS), we will want to decrypt X with Y only by the enclave. I'm aware that this is enforced by the KMS CMK policy (by providing the value of PCR0).What isn't clear to me is that when I run the following:
for decryption, how does the enclave actually:
(My guess is that there is some attestation happening beforehand that is abstracted away? Allowing for a session to be established between enclave and KMS.)
Extra Notes:
From attestation documentation:
Thanks in advance.