Closed johanstokking closed 4 years ago
Please coordinate
Please coordinate. I don't have time for this.
I'll pick this up.
I can see two possible implementations with this one:
crypto.KeyVault
and returns a crypto.KeyVault
which caches the keys for a period of time upon unwrapping
crypto.KeyVault
only before 'mass usage', and defer
the destruction/deletion of the keys from memory
I'm more in favor of 1, but any thoughts on this @johanstokking ?
A few things on the context;
That being said, I prefer option 1. Those units of work last typically in the order of seconds. With https://github.com/TheThingsNetwork/lorawan-stack/issues/2708, we might get a bulk of messages of a single device, so having a cache expiry of 5 to 10 seconds seems reasonable, but please add some Prometheus metrics on the cache (hit ratio, size). Having a fixed size, long (hour) TTL and an ARC cache (balancing LFU and LRU) can also be just fine.
Summary:
Cache unwrapping keys to reduce load on key vault
What do you see now?
Unwrapping keys on-the-fly, also inside loops.
What do you want to see instead?
Keys should not be stored (long) in memory, but they can be cached briefly within the same function.
Original issue: https://github.com/TheThingsIndustries/lorawan-stack/issues/1218 by @johanstokking