Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
return todo_len;
}
+sha256_digest_t CryptoKeyHandler::hmac_sha256(
+ const ceph::bufferlist& in) const
+{
+ ceph::crypto::HMACSHA256 hmac((const unsigned char*)secret.c_str(), secret.length());
+
+ for (const auto& bptr : in.buffers()) {
+ hmac.Update((const unsigned char *)bptr.c_str(), bptr.length());
+ }
+ sha256_digest_t ret;
+ hmac.Final(ret.v);
+
+ return ret;
+}
+
// ---------------------------------------------------
class CryptoNoneKeyHandler : public CryptoKeyHandler {
const out_slice_t& out) const;
virtual std::size_t decrypt(const in_slice_t& in,
const out_slice_t& out) const;
+
+ sha256_digest_t hmac_sha256(const ceph::bufferlist& in) const;
};
/*
return ckh->encrypt(in, out);
}
+ sha256_digest_t hmac_sha256(CephContext*, const ceph::bufferlist& in) {
+ ceph_assert(ckh);
+ return ckh->hmac_sha256(in);
+ }
+
static constexpr std::size_t get_max_outbuf_size(std::size_t want_size) {
return want_size + CryptoKeyHandler::MAX_BLOCK_SIZE;
}