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

Method encrypt

src/auth/Crypto.cc:152–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150// interface.
151
152std::size_t CryptoKeyHandler::encrypt(
153 const CryptoKeyHandler::in_slice_t& in,
154 const CryptoKeyHandler::out_slice_t& out) const
155{
156 ceph::bufferptr inptr(reinterpret_cast<const char*>(in.buf), in.length);
157 ceph::bufferlist plaintext;
158 plaintext.append(std::move(inptr));
159
160 ceph::bufferlist ciphertext;
161 std::string error;
162 const int ret = encrypt(plaintext, ciphertext, &error);
163 if (ret != 0 || !error.empty()) {
164 throw std::runtime_error(std::move(error));
165 }
166
167 // we need to specify the template parameter explicitly as ::length()
168 // returns unsigned int, not size_t.
169 const auto todo_len = \
170 std::min<std::size_t>(ciphertext.length(), out.max_length);
171 memcpy(out.buf, ciphertext.c_str(), todo_len);
172
173 return todo_len;
174}
175
176std::size_t CryptoKeyHandler::decrypt(
177 const CryptoKeyHandler::in_slice_t& in,

Callers 2

_calc_signatureMethod · 0.45
encode_encrypt_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