summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRadoslaw Zarzynski <rzarzyns@redhat.com>2019-02-26 21:54:21 +0100
committerRadoslaw Zarzynski <rzarzyns@redhat.com>2019-02-28 21:42:40 +0100
commitb4ffc343fe75c97fc3b470ac233319ae89ccd301 (patch)
treea301b1cb41a577e1245c0acb955877e02d9d7109 /src
parentmsg/async, v2: dissect decryption from SignedEncryptedFrame. (diff)
downloadceph-b4ffc343fe75c97fc3b470ac233319ae89ccd301.tar.xz
ceph-b4ffc343fe75c97fc3b470ac233319ae89ccd301.zip
msg/async, v2: handle epilogue separately from payload/data.
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/msg/async/ProtocolV2.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc
index 9745d75a692..b6d63dd8db9 100644
--- a/src/msg/async/ProtocolV2.cc
+++ b/src/msg/async/ProtocolV2.cc
@@ -1245,11 +1245,20 @@ CtPtr ProtocolV2::handle_frame_payload() {
auto& payload = rx_segments_data.back();
if (session_stream_handlers.rx) {
- const auto length = payload.length();
- payload = session_stream_handlers.rx->authenticated_decrypt_update_final(
+ ceph_assert(epilogue.length() == FRAME_EPILOGUE_SIZE);
+ ceph_assert(session_stream_handlers.rx->get_extra_size_at_final() ==
+ FRAME_EPILOGUE_SIZE);
+
+ payload = session_stream_handlers.rx->authenticated_decrypt_update(
std::move(payload), segment_t::DEFAULT_ALIGNMENT);
- ceph_assert(payload.length() ==
- length - session_stream_handlers.rx->get_extra_size_at_final());
+ try {
+ session_stream_handlers.rx->authenticated_decrypt_update_final(
+ std::move(epilogue), segment_t::DEFAULT_ALIGNMENT);
+ } catch (ceph::crypto::onwire::MsgAuthError &e) {
+ ldout(cct, 5) << __func__ << " message authentication failed: "
+ << e.what() << dendl;
+ return _fault();
+ }
}
ldout(cct, 30) << __func__ << "\n";
@@ -1470,8 +1479,6 @@ CtPtr ProtocolV2::handle_read_frame_epilogue_main(char *buffer, int r) {
epilogue.push_back(buffer::create_static(FRAME_EPILOGUE_SIZE, buffer));
}
- // FIXME
- rx_segments_data.back().claim_append(epilogue);
return handle_read_frame_dispatch();
}
@@ -1534,11 +1541,14 @@ CtPtr ProtocolV2::handle_message_complete() {
middle = session_stream_handlers.rx->authenticated_decrypt_update(
std::move(middle), segment_t::DEFAULT_ALIGNMENT);
}
- // FIXME: append epilogue. This is really ugly.
- data.claim_append(rx_segments_data[SegmentIndex::Msg::DATA]);
- try {
- data = session_stream_handlers.rx->authenticated_decrypt_update_final(
+ if (data.length()) {
+ data = session_stream_handlers.rx->authenticated_decrypt_update(
std::move(data), segment_t::DEFAULT_ALIGNMENT);
+ }
+
+ try {
+ session_stream_handlers.rx->authenticated_decrypt_update_final(
+ std::move(epilogue), segment_t::DEFAULT_ALIGNMENT);
} catch (ceph::crypto::onwire::MsgAuthError &e) {
ldout(cct, 5) << __func__ << " message authentication failed: "
<< e.what() << dendl;