From 89959fb1946c82e48144ba29f9587932730c396b Mon Sep 17 00:00:00 2001 From: Marcus Watts Date: Mon, 7 Dec 2020 17:48:31 -0500 Subject: [PATCH] rgw/kms/vault - share get/set attr between rgw_crypt.cc and rgw_kms.cc In order to pass down and manage "attrs" from crypt logic to kms logic, it's necessary to share the functions that can get and set strings in that structure. Eventually, I plan to have the various engines store and retrieve a per-object "datakey" that is encrypted (wrapped) by the named kms key. Fixes: http://tracker.ceph.com/issues/48746 Signed-off-by: Marcus Watts --- src/rgw/rgw_crypt.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/rgw/rgw_crypt.h b/src/rgw/rgw_crypt.h index ba23221bcad90..f397941632e0b 100644 --- a/src/rgw/rgw_crypt.h +++ b/src/rgw/rgw_crypt.h @@ -150,4 +150,23 @@ int rgw_s3_prepare_decrypt(struct req_state* s, std::map& crypt_http_responses); +static inline void set_attr(map& attrs, + const char* key, + std::string_view value) +{ + bufferlist bl; + bl.append(value.data(), value.size()); + attrs[key] = std::move(bl); +} + +static inline std::string get_str_attribute(map& attrs, + const char *name) +{ + auto iter = attrs.find(name); + if (iter == attrs.end()) { + return {}; + } + return iter->second.to_str(); +} + #endif -- 2.39.5