diff options
author | tholenst <tholenst@google.com> | 2019-11-08 04:45:41 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2019-11-08 04:46:20 -0800 |
commit | 77b6740e09a7952d26d91624ac97f10fabc10604 (patch) | |
tree | e32a9e5434fd47840adbc231422ee46ef9310280 /cc/registry.h | |
parent | c95c893159c358d5bc2713b99ac3dfd2e5e9f416 (diff) | |
download | tink-77b6740e09a7952d26d91624ac97f10fabc10604.tar.gz |
Add the guarantee to the Registry that KeyManagers returned by get_key_manager() remain valid, even in the presence of concurrent registering calls.
This was previously already the case, except for calls to RegisterAsymmetricKeyManagers after a non-asymmetric register call. Hence, there's a bit of a change of behavior, but if someone does this already I think they will prefer the new failure to the previous potential one.
I also remove the reference_wrapper TODO, since I think it's infeasible to change this at this point (see e.g. [1]). Let me know if you want to keep it.
PiperOrigin-RevId: 279289623
Diffstat (limited to 'cc/registry.h')
-rw-r--r-- | cc/registry.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cc/registry.h b/cc/registry.h index 2de4ebf47..47348af8c 100644 --- a/cc/registry.h +++ b/cc/registry.h @@ -142,11 +142,11 @@ class Registry { } // Returns a key manager for the given type_url (if any found). - // Keeps the ownership of the manager. - // TODO(przydatek): consider changing return value to - // StatusOr<std::reference_wrapper<KeyManager<P>>> - // (cannot return reference directly, as StatusOr does not support it, - // see https://goo.gl/x0ymDz) + // Keeps the ownership of the manager. Returned key_managers are guaranteed + // to stay valid for the lifetime of the binary (with the exception of a user + // calling Reset()). + // TODO(tholenst): Remove Reset() from the interface, as it could violate this + // but should be test only anyhow. template <class P> static crypto::tink::util::StatusOr<const KeyManager<P>*> get_key_manager( const std::string& type_url) { |