MCPcopy Create free account
hub / github.com/ceph/ceph / decrypt

Method decrypt

src/auth/Crypto.cc:176–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176std::size_t CryptoKeyHandler::decrypt(
177 const CryptoKeyHandler::in_slice_t& in,
178 const CryptoKeyHandler::out_slice_t& out) const
179{
180 ceph::bufferptr inptr(reinterpret_cast<const char*>(in.buf), in.length);
181 ceph::bufferlist ciphertext;
182 ciphertext.append(std::move(inptr));
183
184 ceph::bufferlist plaintext;
185 std::string error;
186 const int ret = decrypt(ciphertext, plaintext, &error);
187 if (ret != 0 || !error.empty()) {
188 throw std::runtime_error(std::move(error));
189 }
190
191 // we need to specify the template parameter explicitly as ::length()
192 // returns unsigned int, not size_t.
193 const auto todo_len = \
194 std::min<std::size_t>(plaintext.length(), out.max_length);
195 memcpy(out.buf, plaintext.c_str(), todo_len);
196
197 return todo_len;
198}
199
200sha256_digest_t CryptoKeyHandler::hmac_sha256(
201 const ceph::bufferlist& in) const

Callers 1

decode_decrypt_enc_blFunction · 0.45

Calls 4

appendMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected