Skip to content

Commit e2eed34

Browse files
authored
Merge pull request #26 from mpretty-cyro/feature/updated-libquic
Updated to the latest stable libQuic, Retyped the networking code
2 parents 35e300d + b52ebfe commit e2eed34

File tree

94 files changed

+2071
-1691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2071
-1691
lines changed

.drone.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ local static_build(name,
319319
'echo "Building on ${DRONE_STAGE_MACHINE}"',
320320
apt_get_quiet + ' update',
321321
apt_get_quiet + ' install -y eatmydata',
322-
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git clang-format-15 jsonnet',
322+
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y git clang-format-19 jsonnet',
323323
'./utils/ci/drone-format-verify.sh',
324324
],
325325
}],

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if(CCACHE_PROGRAM)
1717
endif()
1818

1919
project(libsession-util
20-
VERSION 1.2.1
20+
VERSION 1.3.0
2121
DESCRIPTION "Session client utility library"
2222
LANGUAGES ${LANGS})
2323

external/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ endif()
102102

103103
set(LIBQUIC_BUILD_TESTS OFF CACHE BOOL "")
104104
if(ENABLE_ONIONREQ)
105-
libsession_system_or_submodule(OXENQUIC quic liboxenquic>=1.1.0 oxen-libquic)
105+
libsession_system_or_submodule(OXENQUIC quic liboxenquic>=1.2.0 oxen-libquic)
106106
endif()
107107

108108
if(NOT TARGET oxenc::oxenc)
109109
# The oxenc target will already exist if we load libquic above via submodule
110110
set(OXENC_BUILD_TESTS OFF CACHE BOOL "")
111111
set(OXENC_BUILD_DOCS OFF CACHE BOOL "")
112-
libsession_system_or_submodule(OXENC oxenc liboxenc>=1.1.0 oxen-libquic/external/oxen-encoding)
112+
libsession_system_or_submodule(OXENC oxenc liboxenc>=1.3.0 oxen-libquic/external/oxen-encoding)
113113
endif()
114114

115115
if(NOT TARGET oxen::logging)

external/oxen-libquic

Submodule oxen-libquic updated 87 files

include/session/blinding.hpp

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ namespace session {
5959

6060
/// Returns the blinding factor for 15 blinding. Typically this isn't used directly, but is
6161
/// exposed for debugging/testing. Takes server pk in bytes, not hex.
62-
uc32 blind15_factor(ustring_view server_pk);
62+
std::array<unsigned char, 32> blind15_factor(std::span<const unsigned char> server_pk);
6363

6464
/// Returns the blinding factor for 25 blinding. Typically this isn't used directly, but is
6565
/// exposed for debugging/testing. Takes session id and server pk in bytes, not hex. session
6666
/// id can be 05-prefixed (33 bytes) or unprefixed (32 bytes).
67-
uc32 blind25_factor(ustring_view session_id, ustring_view server_pk);
67+
std::array<unsigned char, 32> blind25_factor(
68+
std::span<const unsigned char> session_id, std::span<const unsigned char> server_pk);
6869

6970
/// Computes the two possible 15-blinded ids from a session id and server pubkey. Values accepted
7071
/// and returned are hex-encoded.
@@ -75,7 +76,8 @@ std::array<std::string, 2> blind15_id(std::string_view session_id, std::string_v
7576
/// session_id here may be passed unprefixed (i.e. 32 bytes instead of 33 with the 05 prefix). Only
7677
/// the *positive* possible ID is returned: the alternative can be computed by flipping the highest
7778
/// bit of byte 32, i.e.: `result[32] ^= 0x80`.
78-
ustring blind15_id(ustring_view session_id, ustring_view server_pk);
79+
std::vector<unsigned char> blind15_id(
80+
std::span<const unsigned char> session_id, std::span<const unsigned char> server_pk);
7981

8082
/// Computes the 25-blinded id from a session id and server pubkey. Values accepted and
8183
/// returned are hex-encoded.
@@ -84,7 +86,8 @@ std::string blind25_id(std::string_view session_id, std::string_view server_pk);
8486
/// Same as above, but takes the session id and pubkey as byte values instead of hex, and returns a
8587
/// 33-byte value (instead of a 66-digit hex value). Unlike the string version, session_id here may
8688
/// be passed unprefixed (i.e. 32 bytes instead of 33 with the 05 prefix).
87-
ustring blind25_id(ustring_view session_id, ustring_view server_pk);
89+
std::vector<unsigned char> blind25_id(
90+
std::span<const unsigned char> session_id, std::span<const unsigned char> server_pk);
8891

8992
/// Computes the 15-blinded id from a 32-byte Ed25519 pubkey, i.e. from the known underlying Ed25519
9093
/// pubkey behind a (X25519) Session ID. Unlike blind15_id, knowing the true Ed25519 pubkey allows
@@ -96,8 +99,10 @@ ustring blind25_id(ustring_view session_id, ustring_view server_pk);
9699
/// `blinded25_id_from_ed`, but unlike the 25 version, this value is not read if non-empty, and is
97100
/// not an optimization (that is: it is purely for convenience and is no more efficient to use this
98101
/// than it is to compute it yourself).
99-
ustring blinded15_id_from_ed(
100-
ustring_view ed_pubkey, ustring_view server_pk, ustring* session_id = nullptr);
102+
std::vector<unsigned char> blinded15_id_from_ed(
103+
std::span<const unsigned char> ed_pubkey,
104+
std::span<const unsigned char> server_pk,
105+
std::vector<unsigned char>* session_id = nullptr);
101106

102107
/// Computes the 25-blinded id from a 32-byte Ed25519 pubkey, i.e. from the known underlying Ed25519
103108
/// pubkey behind a (X25519) Session ID. This will be the same as blind25_id (if given the X25519
@@ -109,8 +114,10 @@ ustring blinded15_id_from_ed(
109114
/// containing the precomputed value (to avoid needing to compute it again). If unknown but needed
110115
/// then a pointer to an empty string can be given to computed and stored the value here. Otherwise
111116
/// (if omitted or nullptr) then the value will temporarily computed within the function.
112-
ustring blinded25_id_from_ed(
113-
ustring_view ed_pubkey, ustring_view server_pk, ustring* session_id = nullptr);
117+
std::vector<unsigned char> blinded25_id_from_ed(
118+
std::span<const unsigned char> ed_pubkey,
119+
std::span<const unsigned char> server_pk,
120+
std::vector<unsigned char>* session_id = nullptr);
114121

115122
/// Computes a 15-blinded key pair.
116123
///
@@ -122,8 +129,10 @@ ustring blinded25_id_from_ed(
122129
///
123130
/// It is recommended to pass the full 64-byte libsodium-style secret key for `ed25519_sk` (i.e.
124131
/// seed + appended pubkey) as with just the 32-byte seed the public key has to be recomputed.
125-
std::pair<uc32, cleared_uc32> blind15_key_pair(
126-
ustring_view ed25519_sk, ustring_view server_pk, uc32* k = nullptr);
132+
std::pair<std::array<unsigned char, 32>, cleared_uc32> blind15_key_pair(
133+
std::span<const unsigned char> ed25519_sk,
134+
std::span<const unsigned char> server_pk,
135+
std::array<unsigned char, 32>* k = nullptr);
127136

128137
/// Computes a 25-blinded key pair.
129138
///
@@ -137,8 +146,10 @@ std::pair<uc32, cleared_uc32> blind15_key_pair(
137146
///
138147
/// It is recommended to pass the full 64-byte libsodium-style secret key for `ed25519_sk` (i.e.
139148
/// seed + appended pubkey) as with just the 32-byte seed the public key has to be recomputed.
140-
std::pair<uc32, cleared_uc32> blind25_key_pair(
141-
ustring_view ed25519_sk, ustring_view server_pk, uc32* k_prime = nullptr);
149+
std::pair<std::array<unsigned char, 32>, cleared_uc32> blind25_key_pair(
150+
std::span<const unsigned char> ed25519_sk,
151+
std::span<const unsigned char> server_pk,
152+
std::array<unsigned char, 32>* k_prime = nullptr);
142153

143154
/// Computes a version-blinded key pair.
144155
///
@@ -147,7 +158,8 @@ std::pair<uc32, cleared_uc32> blind25_key_pair(
147158
///
148159
/// It is recommended to pass the full 64-byte libsodium-style secret key for `ed25519_sk` (i.e.
149160
/// seed + appended pubkey) as with just the 32-byte seed the public key has to be recomputed.
150-
std::pair<uc32, cleared_uc64> blind_version_key_pair(ustring_view ed25519_sk);
161+
std::pair<std::array<unsigned char, 32>, cleared_uc64> blind_version_key_pair(
162+
std::span<const unsigned char> ed25519_sk);
151163

152164
/// Computes a verifiable 15-blinded signature that validates with the blinded pubkey that would
153165
/// be returned from blind15_key_pair().
@@ -157,7 +169,10 @@ std::pair<uc32, cleared_uc64> blind_version_key_pair(ustring_view ed25519_sk);
157169
///
158170
/// It is recommended to pass the full 64-byte libsodium-style secret key for `ed25519_sk` (i.e.
159171
/// seed + appended pubkey) as with just the 32-byte seed the public key has to be recomputed.
160-
ustring blind15_sign(ustring_view ed25519_sk, std::string_view server_pk_in, ustring_view message);
172+
std::vector<unsigned char> blind15_sign(
173+
std::span<const unsigned char> ed25519_sk,
174+
std::string_view server_pk_in,
175+
std::span<const unsigned char> message);
161176

162177
/// Computes a verifiable 25-blinded signature that validates with the blinded pubkey that would
163178
/// be returned from blind25_id().
@@ -167,27 +182,31 @@ ustring blind15_sign(ustring_view ed25519_sk, std::string_view server_pk_in, ust
167182
///
168183
/// It is recommended to pass the full 64-byte libsodium-style secret key for `ed25519_sk` (i.e.
169184
/// seed + appended pubkey) as with just the 32-byte seed the public key has to be recomputed.
170-
ustring blind25_sign(ustring_view ed25519_sk, std::string_view server_pk, ustring_view message);
185+
std::vector<unsigned char> blind25_sign(
186+
std::span<const unsigned char> ed25519_sk,
187+
std::string_view server_pk,
188+
std::span<const unsigned char> message);
171189

172190
/// Computes a verifiable version-blinded signature that validates with the version-blinded pubkey
173191
/// that would be returned from blind_version_key_pair.
174192
///
175193
/// Takes the Ed25519 secret key (64 bytes, or 32-byte seed), unix timestamp, method, path, and
176194
/// optional body.
177195
/// Returns the version-blinded signature.
178-
ustring blind_version_sign_request(
179-
ustring_view ed25519_sk,
196+
std::vector<unsigned char> blind_version_sign_request(
197+
std::span<const unsigned char> ed25519_sk,
180198
uint64_t timestamp,
181199
std::string_view method,
182200
std::string_view path,
183-
std::optional<ustring_view> body);
201+
std::optional<std::span<const unsigned char>> body);
184202

185203
/// Computes a verifiable version-blinded signature that validates with the version-blinded pubkey
186204
/// that would be returned from blind_version_key_pair.
187205
///
188206
/// Takes the Ed25519 secret key (64 bytes, or 32-byte seed), current platform and unix timestamp.
189207
/// Returns the version-blinded signature.
190-
ustring blind_version_sign(ustring_view ed25519_sk, Platform platform, uint64_t timestamp);
208+
std::vector<unsigned char> blind_version_sign(
209+
std::span<const unsigned char> ed25519_sk, Platform platform, uint64_t timestamp);
191210

192211
/// Takes in a standard session_id and returns a flag indicating whether it matches the given
193212
/// blinded_id for a given server_pk.

include/session/config.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ class ConfigMessage {
108108
/// message. It can also throw to abort message construction (that is: returning false skips
109109
/// the message when loading multiple messages, but can still continue with other messages;
110110
/// throwing aborts the entire construction).
111-
using verify_callable = std::function<bool(ustring_view data, ustring_view signature)>;
111+
using verify_callable = std::function<bool(
112+
std::span<const unsigned char> data, std::span<const unsigned char> signature)>;
112113

113114
/// Signing function: this is passed the data to be signed and returns the 64-byte signature.
114-
using sign_callable = std::function<ustring(ustring_view data)>;
115+
using sign_callable =
116+
std::function<std::vector<unsigned char>(std::span<const unsigned char> data)>;
115117

116118
ConfigMessage();
117119
ConfigMessage(const ConfigMessage&) = default;
@@ -124,7 +126,7 @@ class ConfigMessage {
124126
/// Initializes a config message by parsing a serialized message. Throws on any error. See the
125127
/// vector version below for argument descriptions.
126128
explicit ConfigMessage(
127-
ustring_view serialized,
129+
std::span<const unsigned char> serialized,
128130
verify_callable verifier = nullptr,
129131
sign_callable signer = nullptr,
130132
int lag = DEFAULT_DIFF_LAGS,
@@ -160,7 +162,7 @@ class ConfigMessage {
160162
/// `[](size_t, const auto& e) { throw e; }` can be used to make any parse error of any message
161163
/// fatal.
162164
explicit ConfigMessage(
163-
const std::vector<ustring_view>& configs,
165+
const std::vector<std::span<const unsigned char>>& configs,
164166
verify_callable verifier = nullptr,
165167
sign_callable signer = nullptr,
166168
int lag = DEFAULT_DIFF_LAGS,
@@ -231,10 +233,11 @@ class ConfigMessage {
231233
/// typically for a local serialization value that isn't being pushed to the server). Note that
232234
/// signing is always disabled if there is no signing callback set, regardless of the value of
233235
/// this argument.
234-
virtual ustring serialize(bool enable_signing = true);
236+
virtual std::vector<unsigned char> serialize(bool enable_signing = true);
235237

236238
protected:
237-
ustring serialize_impl(const oxenc::bt_dict& diff, bool enable_signing = true);
239+
std::vector<unsigned char> serialize_impl(
240+
const oxenc::bt_dict& diff, bool enable_signing = true);
238241
};
239242

240243
// Constructor tag
@@ -282,7 +285,7 @@ class MutableConfigMessage : public ConfigMessage {
282285
/// constructor only increments seqno once while the indirect version would increment twice in
283286
/// the case of a required merge conflict resolution.
284287
explicit MutableConfigMessage(
285-
const std::vector<ustring_view>& configs,
288+
const std::vector<std::span<const unsigned char>>& configs,
286289
verify_callable verifier = nullptr,
287290
sign_callable signer = nullptr,
288291
int lag = DEFAULT_DIFF_LAGS,
@@ -292,7 +295,7 @@ class MutableConfigMessage : public ConfigMessage {
292295
/// take an error handler and instead always throws on parse errors (the above also throws for
293296
/// an erroneous single message, but with a less specific "no valid config messages" error).
294297
explicit MutableConfigMessage(
295-
ustring_view config,
298+
std::span<const unsigned char> config,
296299
verify_callable verifier = nullptr,
297300
sign_callable signer = nullptr,
298301
int lag = DEFAULT_DIFF_LAGS);
@@ -339,7 +342,7 @@ class MutableConfigMessage : public ConfigMessage {
339342
const hash_t& hash() override;
340343

341344
protected:
342-
const hash_t& hash(ustring_view serialized);
345+
const hash_t& hash(std::span<const unsigned char> serialized);
343346
void increment_impl();
344347
};
345348

include/session/config/base.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,7 @@ LIBSESSION_EXPORT config_string_list* config_current_hashes(const config_object*
274274
///
275275
/// Outputs:
276276
/// - `config_string_list*` -- pointer to the list of hashes; the pointer belongs to the caller
277-
LIBSESSION_EXPORT config_string_list* config_old_hashes(config_object* conf)
278-
#ifdef __GNUC__
279-
__attribute__((warn_unused_result))
280-
#endif
281-
;
277+
LIBSESSION_EXPORT config_string_list* config_old_hashes(config_object* conf) LIBSESSION_WARN_UNUSED;
282278

283279
/// API: base/config_get_keys
284280
///

0 commit comments

Comments
 (0)