Group in this namespace all the functions related to building or parsing double ratchet packets.
More...
|
| template<typename Curve> |
| void | buildMessage_X3DHinit (std::vector< uint8_t > &message, const DSA< Curve, lime::DSAtype::publicKey > &Ik, const X< Curve, lime::Xtype::publicKey > &Ek, const uint32_t SPk_id, const uint32_t OPk_id, const bool OPk_flag) noexcept |
| | build an X3DH init message to insert in DR header EC only version
|
| template<typename Curve> |
| void | buildMessage_X3DHinit (std::vector< uint8_t > &message, const DSA< typename Curve::EC, lime::DSAtype::publicKey > &Ik, const X< typename Curve::EC, lime::Xtype::publicKey > &Ek, const K< typename Curve::KEM, lime::Ktype::cipherText > &Ct, const uint32_t SPk_id, const uint32_t OPk_id, const bool OPk_flag) noexcept |
| | build an X3DH init message to insert in DR header EC and KEM version
|
| template<typename Curve> |
| void | parseMessage_X3DHinit (const std::vector< uint8_t >message, DSA< Curve, lime::DSAtype::publicKey > &Ik, X< Curve, lime::Xtype::publicKey > &Ek, uint32_t &SPk_id, uint32_t &OPk_id, bool &OPk_flag) noexcept |
| | Parse the X3DH init message and extract peer Ik, peer Ek, self SPk id and seld OPk id if present This is for EC only version.
|
| template<typename Curve> |
| void | parseMessage_X3DHinit (const std::vector< uint8_t >message, DSA< typename Curve::EC, lime::DSAtype::publicKey > &Ik, X< typename Curve::EC, lime::Xtype::publicKey > &Ek, K< typename Curve::KEM, lime::Ktype::cipherText > &Ct, uint32_t &SPk_id, uint32_t &OPk_id, bool &OPk_flag) noexcept |
| | Parse the X3DH init message and extract peer Ik, peer Ek, self SPk id and seld OPk id if present This is for EC and KEM version.
|
| template<typename Curve> |
| bool | parseMessage_get_X3DHinit (const std::vector< uint8_t > &message, std::vector< uint8_t > &X3DH_initMessage) noexcept |
| | check the message for presence of X3DH init in the header, extract it if there is one
|
| template<typename Curve> |
| constexpr size_t | headerSize (uint8_t messageType) noexcept |
| | return the size of the double ratchet packet header
|
| template<typename Curve> |
| constexpr size_t | X3DHinitSize (bool haveOPk, typename std::enable_if_t<!std::is_base_of_v< genericKEM, Curve >, bool >=true) noexcept |
| | return the size of the X3DH init packet included in the double ratchet packet header
|
| template<typename Algo> |
| constexpr size_t | X3DHinitSize (bool haveOPk, typename std::enable_if_t< std::is_base_of_v< genericKEM, Algo >, bool >=true) noexcept |
| | return the size of the X3DH init packet included in the double ratchet packet header
|
| template<typename Algo> |
| void | buildMessage_X3DHinit (std::vector< uint8_t > &message, const DSA< typename Algo::EC, lime::DSAtype::publicKey > &Ik, const X< typename Algo::EC, lime::Xtype::publicKey > &Ek, const K< typename Algo::KEM, lime::Ktype::cipherText > &Ct, const uint32_t SPk_id, const uint32_t OPk_id, const bool OPk_flag) noexcept |
| template<typename Algo> |
| void | parseMessage_X3DHinit (const std::vector< uint8_t >message, DSA< typename Algo::EC, lime::DSAtype::publicKey > &Ik, X< typename Algo::EC, lime::Xtype::publicKey > &Ek, K< typename Algo::KEM, lime::Ktype::cipherText > &Ct, uint32_t &SPk_id, uint32_t &OPk_id, bool &OPk_flag) noexcept |
Group in this namespace all the functions related to building or parsing double ratchet packets.
Implemented version of the DR session protocol (provide a way to handle future/alternative packets formats/crypto algorithm) Supported version description :
- Version 0x01:
DRHeader is: Protocol Version Number<1 byte> || Message Type <1 byte> || curveId <1 byte> || [X3DH Init message < variable >] || Ns<2 bytes> || PN<2 bytes> || [ DHs<...> or DHrIndex<12 bytes> || DHsIndex<12 bytes> ]
Message is : DRheader<...> || cipherMessageKeyK<32 bytes> || Key auth tag<16 bytes> || cipherText<...> || Message auth tag<16 bytes>
Associated Data are transmitted separately: ADk for the Key auth tag, and ADm for the Message auth tag
Message AEAD on : (ADm, message plain text) keyed by message Key(include IV)
Key AEAD on : (ADk || Message auth tag || header, Message Key) keyed by Double Ratchet generated key/IV
ADm is : source GRUU<...> || recipient sip-uri(can be a group uri)<...>
ADk is : source GRUU<...> || recipient GRUU<...>
- Note
- : ADk is used with session stored AD provided by X3DH at session creation which is HKDF(initiator Ik || receiver Ik || initiator device Id || receiver device Id)
Diffie-Hellman support: X25519 or X448 (not mixed, specified by X3DH server and client setting which must match)
Packets types are : regular or x3dhinit
- regular packet does not contain x3dh init message
- x3dh init packet includes x3dh init message in the header as follow:
haveOPk <flag 1 byte> ||
self Ik < DSA<Curve, lime::DSAtype::publicKey>::ssize() bytes > ||
Ek < X<Curve, lime::Xtype::publicKey>::keyLenght() bytes> ||
peer SPk id < 4 bytes > ||
[peer OPk id(if flag is set)<4bytes>]