| 111 | namespace gcs = ::google::cloud::storage; |
| 112 | |
| 113 | Result<gcs::EncryptionKey> ToEncryptionKey( |
| 114 | const std::shared_ptr<const KeyValueMetadata>& metadata) { |
| 115 | if (!metadata) { |
| 116 | return gcs::EncryptionKey{}; |
| 117 | } |
| 118 | |
| 119 | const auto& keys = metadata->keys(); |
| 120 | const auto& values = metadata->values(); |
| 121 | |
| 122 | for (std::size_t i = 0; i < keys.size(); ++i) { |
| 123 | if (keys[i] == "encryptionKeyBase64") { |
| 124 | return gcs::EncryptionKey::FromBase64Key(values[i]); |
| 125 | } |
| 126 | } |
| 127 | return gcs::EncryptionKey{}; |
| 128 | } |
| 129 | |
| 130 | Result<gcs::KmsKeyName> ToKmsKeyName( |
| 131 | const std::shared_ptr<const KeyValueMetadata>& metadata) { |