Group in this namespace all the functions related to building or parsing x3dh packets.
More...
|
static std::string | x3dh_messageTypeString (const x3dh_message_type message_type) |
| Helper function to get human readable trace of x3dh messages types. More...
|
|
static std::vector< uint8_t > | X3DH_makeHeader (const x3dh_message_type message_type, const lime::CurveId curve) noexcept |
| Build X3DH message header using current protocol Version byte. More...
|
|
template<typename Curve > |
void | buildMessage_registerUser (std::vector< uint8_t > &message, const DSA< Curve, lime::DSAtype::publicKey > &Ik, const X< Curve, lime::Xtype::publicKey > &SPk, const DSA< Curve, lime::DSAtype::signature > &Sig, const uint32_t SPk_id, const std::vector< X< Curve, lime::Xtype::publicKey >> &OPks, const std::vector< uint32_t > &OPk_ids) noexcept |
| build a registerUser message : Identity Key<EDDSA Public Key length> More...
|
|
template<typename Curve > |
void | buildMessage_deleteUser (std::vector< uint8_t > &message) noexcept |
| build a deleteUser message More...
|
|
template<typename Curve > |
void | buildMessage_publishSPk (std::vector< uint8_t > &message, const X< Curve, lime::Xtype::publicKey > &SPk, const DSA< Curve, lime::DSAtype::signature > &Sig, const uint32_t SPk_id) noexcept |
| build a postSPk message More...
|
|
template<typename Curve > |
void | buildMessage_publishOPks (std::vector< uint8_t > &message, const std::vector< X< Curve, lime::Xtype::publicKey >> &OPks, const std::vector< uint32_t > &OPk_ids) noexcept |
| build a postOPks message More...
|
|
template<typename Curve > |
void | buildMessage_getPeerBundles (std::vector< uint8_t > &message, std::vector< std::string > &peer_device_ids) noexcept |
| build a getPeerBundle message More...
|
|
template<typename Curve > |
void | buildMessage_getSelfOPks (std::vector< uint8_t > &message) noexcept |
| build a getSelfOPks message More...
|
|
template<typename Curve > |
bool | parseMessage_getType (const std::vector< uint8_t > &body, x3dh_message_type &message_type, x3dh_error_code &error_code, const limeCallback callback) noexcept |
|
template<typename Curve > |
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. More...
|
|
template<typename Curve > |
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. More...
|
|
Group in this namespace all the functions related to building or parsing x3dh packets.
- Protocol Version 0x01:
- Header is : Protccol Version Number<1 byte> || Message type<1 byte> || Curve id<1 byte> Messages are : header<3 bytes> || Message content
If not an error the server responds with a message holding just a header of the same message type except for getPeerBundle which shall be answered with a peerBundle message
Message types description :
- registerUser : Identity Key<EDDSA Public Key length>
SPk< ECDH Public key length > ||
SPk Signature< Signature Length > ||
SPk Id < 4 bytes>
OPk Keys Count<2 bytes unsigned integer Big endian> ||
( OPk< ECDH Public key length > || OPk Id <4 bytes>){Keys Count}
- deleteUser : empty message, user to delete is retrieved from header From
- postSPk : SPk< ECDH Public key length > || SPk Signature< Signature Length > || SPk Id < 4 bytes>
- postOPks : Keys Count<2 bytes unsigned integer Big endian> ||
( OPk< ECDH Public key length > || OPk Id <4 bytes>){Keys Count}
- getPeerBundle : request Count < 2 bytes unsigned Big Endian> ||
(userId Size <2 bytes unsigned Big Endian> || UserId <...> (the GRUU of user we wan't to send a message)) {request Count}
- peerBundle : bundle Count < 2 bytes unsigned Big Endian> ||
( deviceId Size < 2 bytes unsigned Big Endian > || deviceId Flag<1 byte: 0 if no OPK in bundle, 1 if OPk is the bundle, 2 if no key bundle is associated to this device> || Ik < EDDSA Public Key Length > || SPk < ECDH Public Key Length > || SPK id <4 bytes> SPk_sig < Signature Length > || (OPk < ECDH Public Key Length > || OPk id <4 bytes>){0,1 in accordance to flag} ) { bundle Count}
- getSelfOPks : empty message, ask server for the OPk Id it still holds for us
- selfOPks : OPk Count <2 bytes unsigned integer Big Endian> ||
(OPk id <4 bytes uint32_t big endian>){OPk Count}
- error : errorCode<1 byte> || (errorMessage<...>){0,1}
template<typename Curve >
bool lime::x3dh_protocol::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.
Warning: no checks are done on message type, they are performed before calling this function
peerBundle : bundle Count < 2 bytes unsigned Big Endian> ||
( deviceId Size < 2 bytes unsigned Big Endian > || deviceId Flag<1 byte: 0 if no OPK in bundle, 1 if present, 2 no key bundle found on server> || Ik < EDDSA Public Key Length > || SPk < ECDH Public Key Length > || SPK id <4 bytes> SPk_sig < Signature Length > || (OPk < ECDH Public Key Length > || OPk id <4 bytes>){0,1 in accordance to flag} ) { bundle Count}
- Parameters
-
[in] | body | a buffer holding the message |
[out] | peersBundle | a vector to be populated from message content, is empty if none found |
- Returns
- true if all went ok, false and empty peersBundle otherwise