-
Notifications
You must be signed in to change notification settings - Fork 125
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
Q: When to use Enclave and when LockedBuffer? #118
Comments
Generally use an enclave when you have lots of data to store or when you have some data that will hang around for a while in memory. Use a LockedBuffer when you need frequent access to the data such that decrypting it every time is too much of a performance penalty. |
Sorry to add more questions to this closed issue as my question is closest to this, instead of raising a new question. |
I would personally use one enclave per key.
Nope, Enclaves basically just look like this: type Enclave struct {
ciphertext []byte
} There is a single global key that is used to protect all existing Enclaves, and resetting this key (for example by calling Purge) invalidates all of them at once by destroying this global key.
This has come up before. There's no way currently to invalidate a single Enclave. There would be too much overhead in having a single key for each Enclave, and the ciphertext is stored in an ordinary byte slice provided by the runtime so wiping it wouldn't be effective. I see two solutions to this in the future:
I think I'm in favour of (2) but first we need a more efficient allocator (#124). In any case, ciphertext is not the easiest part of your system for an adversary to attack. It should be sufficient to just minimise the amount of time the keys spend decrypted inside LockedBuffer objects and let Enclave objects that you no longer need to fall out of scope.
You could use a To read data from a http Response you could use this method or |
Thank you Awn for the detailed answer. I think I understand better now. I thought the content inside an Enclave was constantly being rekeyed (I didn't look inside the code earlier), which caused my concern on the overhead when the number of Enclaves are large. Now I know rekey applies to the encryption key representation. No worries there. And I don't see a need to destroy enclaves when Go GC can just reclaim them. |
I am not sure when I should be using the enclave object and when the locked buffer.
My use case is that I have encrypted data in database and I am providing decryption key on boot via environment variable which is immediately unset and I am storing that key in enclave. When I need to decrypt the data in database, I get the key from the enclave as locked buffer, I decrypt the data and remove the locked buffer.
I am not sure if this is the correct use or if I should be simply keeping the locked buffer only and read the key from it when needed, not bothering with the enclave altogether?
The text was updated successfully, but these errors were encountered: