From 1907b2b52fb056fae395b87eba203177fe774254 Mon Sep 17 00:00:00 2001 From: Arvid Lunnemark Date: Thu, 30 Jun 2022 13:44:10 -0700 Subject: [PATCH] it compiles --- daemon/crypto/BUILD | 1 + daemon/crypto/constants.hpp | 7 ++++++- daemon/crypto/crypto.cc | 3 +-- daemon/crypto/crypto.hpp | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/daemon/crypto/BUILD b/daemon/crypto/BUILD index f1697936..9e29e631 100644 --- a/daemon/crypto/BUILD +++ b/daemon/crypto/BUILD @@ -16,6 +16,7 @@ cc_library( visibility = ["//daemon:__subpackages__"], deps = [ "@asphr//asphr:asphr_lib", + "@asphr//schema:asyncinvitation_proto_cc", "@asphr//schema:daemon_cc_grpc", "@asphr//schema:message_proto_cc", "@asphr//schema:server_cc_grpc", diff --git a/daemon/crypto/constants.hpp b/daemon/crypto/constants.hpp index 28a2630d..777ea9a5 100644 --- a/daemon/crypto/constants.hpp +++ b/daemon/crypto/constants.hpp @@ -36,7 +36,12 @@ constexpr int MAX_ASYNC_FRIEND_REQUESTS = 500; constexpr int ASYNC_FRIEND_REQUEST_BATCH_SIZE = 1000; // TODO: figure out a reasonable limit here... constexpr size_t ASYNC_INVITATION_SIZE = MESSAGE_SIZE; // arbitrary -constexpr int INVITATION_MESSAGE_MAX_PLAINTEXT_SIZE = ASYNC_INVITATION_SIZE; +// TODO: optimize this size. we have a protobuf in asyncinvitation.proto +// it also contains the public ID. the public ID should never be bigger than +// 190, and the protobuf should never add more than 10 extra bytes, so 200 is +// very safe. +constexpr int INVITATION_MESSAGE_MAX_PLAINTEXT_SIZE = + ASYNC_INVITATION_SIZE - 200; static_assert( INVITATION_MESSAGE_MAX_PLAINTEXT_SIZE < ASYNC_INVITATION_SIZE, "INVITATION_MESSAGE_MAX_PLAINTEXT_SIZE must be < " diff --git a/daemon/crypto/crypto.cc b/daemon/crypto/crypto.cc index 56ad9a90..49e2bc25 100644 --- a/daemon/crypto/crypto.cc +++ b/daemon/crypto/crypto.cc @@ -431,7 +431,6 @@ auto decrypt_async_invitation(const string& self_invitation_private_key, // TODO: specifically, we need to verify that the public_id in the body // corresponds to the public_id that the message was authenticated with // otherwise, someone might impersonate the real receiver - return make_pair(async_invitation.public_id(), - async_invitation.invitation_id()); + return make_pair(async_invitation.my_public_id(), async_invitation.message()); } } // namespace crypto \ No newline at end of file diff --git a/daemon/crypto/crypto.hpp b/daemon/crypto/crypto.hpp index 7c5996c3..40c8e392 100644 --- a/daemon/crypto/crypto.hpp +++ b/daemon/crypto/crypto.hpp @@ -11,7 +11,7 @@ #include #include "constants.hpp" -#include "schema/asyncinvitation.proto" +#include "schema/asyncinvitation.pb.h" #include "schema/message.pb.h" /* Crypto implements an IND-CCA2 secure scheme.