20#ifndef lime_x3dh_protocol_hpp
21#define lime_x3dh_protocol_hpp
43 template <
typename Curve>
60 X3DH_peerBundle(std::string &&
deviceId,
const std::vector<uint8_t>::const_iterator bundle,
bool haveOPk, std::ostringstream &message_trace) :
66 message_trace <<
" Ik: "<<std::hex << std::setfill(
'0');
69 SPk.dump(message_trace);
72 OPk.dump(message_trace);
83 namespace x3dh_protocol {
119 template <
typename Curve>
122 template <
typename Curve>
125 template <
typename Curve>
128 template <
typename Curve>
131 template <
typename Curve>
134 template <
typename Curve>
137 template <
typename Curve>
140 template <
typename Curve>
143 template <
typename Curve>
144 bool parseMessage_selfOPks(
const std::vector<uint8_t> &body, std::vector<uint32_t> &selfOPkIds)
noexcept;
147#ifdef EC25519_ENABLED
172#ifdef EC25519_ENABLED
Base buffer definition for DSA data structure.
Definition lime_crypto_primitives.hpp:148
static constexpr size_t ssize(void)
provide a static size function to be able to call the function not on an object
Definition lime_crypto_primitives.hpp:151
x3dh_message_type
the x3dh message type exchanged with the X3DH server
Definition lime_x3dh_protocol.hpp:88
@ peerBundle
Definition lime_x3dh_protocol.hpp:94
@ registerUser
Definition lime_x3dh_protocol.hpp:97
@ postOPks
Definition lime_x3dh_protocol.hpp:92
@ getSelfOPks
Definition lime_x3dh_protocol.hpp:95
@ selfOPks
Definition lime_x3dh_protocol.hpp:96
@ postSPk
Definition lime_x3dh_protocol.hpp:91
@ deprecated_registerUser
Definition lime_x3dh_protocol.hpp:89
@ deleteUser
Definition lime_x3dh_protocol.hpp:90
@ error
Definition lime_x3dh_protocol.hpp:98
@ getPeerBundle
Definition lime_x3dh_protocol.hpp:93
void buildMessage_registerUser(std::vector< uint8_t > &message, const DSA< typename Curve::EC, lime::DSAtype::publicKey > &Ik, const SignedPreKey< Curve > &SPk, const std::vector< OneTimePreKey< Curve > > &OPks) noexcept
build a registerUser message : Identity Key<EDDSA Public Key length>
Definition lime_x3dh_protocol.cpp:146
void buildMessage_getSelfOPks(std::vector< uint8_t > &message) noexcept
build a getSelfOPks message
Definition lime_x3dh_protocol.cpp:320
void buildMessage_getPeerBundles(std::vector< uint8_t > &message, std::vector< std::string > &peer_device_ids) noexcept
build a getPeerBundle message
Definition lime_x3dh_protocol.cpp:277
bool parseMessage_selfOPks(const std::vector< uint8_t > &body, std::vector< uint32_t > &selfOPkIds) noexcept
Parse a selfOPk message and populate a self OPk ids.
Definition lime_x3dh_protocol.cpp:598
bool parseMessage_getType(const std::vector< uint8_t > &body, x3dh_message_type &message_type, x3dh_error_code &error_code, const std::shared_ptr< limeCallback > callback) noexcept
Definition lime_x3dh_protocol.cpp:337
void buildMessage_publishOPks(std::vector< uint8_t > &message, const std::vector< OneTimePreKey< Curve > > &OPks) noexcept
build a postOPks message
Definition lime_x3dh_protocol.cpp:234
void buildMessage_deleteUser(std::vector< uint8_t > &message) noexcept
build a deleteUser message
Definition lime_x3dh_protocol.cpp:192
bool parseMessage_getPeerBundles(const std::vector< uint8_t > &body, std::vector< X3DH_peerBundle< Curve > > &peersBundle) noexcept
Parse a peerBundles message and populate a vector of peerBundles.
Definition lime_x3dh_protocol.cpp:494
x3dh_error_code
the error codes included in the x3dh error message received from the X3DH server
Definition lime_x3dh_protocol.hpp:104
@ resource_limit_reached
Definition lime_x3dh_protocol.hpp:115
@ user_already_in
Definition lime_x3dh_protocol.hpp:110
@ unset_error_code
Definition lime_x3dh_protocol.hpp:117
@ bad_request
Definition lime_x3dh_protocol.hpp:113
@ server_failure
Definition lime_x3dh_protocol.hpp:114
@ unknown_error_code
Definition lime_x3dh_protocol.hpp:116
@ missing_senderId
Definition lime_x3dh_protocol.hpp:107
@ bad_curve
Definition lime_x3dh_protocol.hpp:106
@ user_not_found
Definition lime_x3dh_protocol.hpp:111
@ bad_content_type
Definition lime_x3dh_protocol.hpp:105
@ bad_size
Definition lime_x3dh_protocol.hpp:109
@ bad_x3dh_protocol_version
Definition lime_x3dh_protocol.hpp:108
@ db_error
Definition lime_x3dh_protocol.hpp:112
void buildMessage_publishSPk(std::vector< uint8_t > &message, const SignedPreKey< Curve > &SPk) noexcept
build a postSPk message
Definition lime_x3dh_protocol.cpp:209
DSAtype
List of data types used by Signature algorithm.
Definition lime_keys.hpp:49
@ publicKey
Definition lime_keys.hpp:38
X3DHKeyBundleFlag
Set possible values for a flag in the keyBundle X3DH packet.
Definition lime_x3dh_protocol.hpp:35
@ OPk
Definition lime_x3dh_protocol.hpp:37
@ noOPk
Definition lime_x3dh_protocol.hpp:36
@ noBundle
Definition lime_x3dh_protocol.hpp:38
void hexStr(std::ostringstream &os, const uint8_t *data, size_t len, size_t digest)
Definition lime_log.cpp:30
Definition lime_x3dh.hpp:218
Definition lime_x3dh.hpp:32
Holds everything found in a key bundle received from X3DH server.
Definition lime_x3dh_protocol.hpp:44
OneTimePreKey< Curve > OPk
Definition lime_x3dh_protocol.hpp:49
X3DH_peerBundle(std::string &&deviceId)
Definition lime_x3dh_protocol.hpp:79
X3DH_peerBundle(std::string &&deviceId, const std::vector< uint8_t >::const_iterator bundle, bool haveOPk, std::ostringstream &message_trace)
Definition lime_x3dh_protocol.hpp:60
const lime::X3DHKeyBundleFlag bundleFlag
Definition lime_x3dh_protocol.hpp:50
static constexpr size_t ssize(bool haveOPk)
Definition lime_x3dh_protocol.hpp:45
const SignedPreKey< Curve > SPk
Definition lime_x3dh_protocol.hpp:48
const DSA< typename Curve::EC, lime::DSAtype::publicKey > Ik
Definition lime_x3dh_protocol.hpp:47
const std::string deviceId
Definition lime_x3dh_protocol.hpp:46