Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf handling #51

Merged
merged 17 commits into from Oct 18, 2023
Merged

Protobuf handling #51

merged 17 commits into from Oct 18, 2023

Conversation

dr7ana
Copy link
Collaborator

@dr7ana dr7ana commented Sep 6, 2023

No description provided.

@jagerman
Copy link
Member

jagerman commented Sep 22, 2023

TODO: we need to squash these changes together (had to update the protobufs again, for the downgrade).

@jagerman
Copy link
Member

Now squashed and rebased on top of #59 (which will most likely be merged before this PR).

jagerman and others added 5 commits October 4, 2023 11:06
It's stupidly difficult to avoid false positives (and protobuf triggers
it).
This adds support for automatic wrapping and unwrapping of config
messages that may be wrapped in protobuf; this was unintentional, but is
out in the wild in current Session releases.  The long-term plan is to
stop doing this eventually, but supporting it here allows us to change
from the current mode (always wrap/unwrap affected message types) to
a mode where we only unwrap, and then finally we can drop unwrapping as
well.

For now: we wrap/unwrap the existing released message types (user
profile, conversation info, and so on) but not the new groups configs
(which should always be un-wrapped).

Various notes:

- protobuf added as external dependency.

- protobuf 21.12 is used, which is an older release, but is what is
  still being used by lots of projects and Linux distributions because
  Google applied huge amounts of extra bloat in v22 (including pulling a
  massive pile of crap in abseil), broke the build system in various
  ways, and made everything suck to the point that many Linux
  distributions have just stuck with the latest 21.12 because of all the
  broken crap Google imposed on everyone in v22 and newer.

- SessionProtos.pro and WebSocketResources.proto looped in from
  session-ios codebase, with one minor change to let us use it in "lite"
  mode (which is still very bloated, but nothing like non-lite mode).

- Added pregenerated header/cpp files; we experimented with building
  them as part of the build, but that ended up neigh impossible for our
  various cross-compiled builds.  (These also get excluded from
  format.sh because they break if formatted.  Hurray.)

- Add protobuf::libprotobuf-lite to the static build list.

- Adds a dummy test script that does nothing, but tests that we can
  probably link against the combined archive (when building with
  `-DSTATIC_BUILD=ON`).
- Removed an unneeded `ustring` argument overload which just calls the
  `ustring_view` alternative (which already is fine when given a
  ustring).

- Don't eat exceptions from protobuf production.  If this throws on
  *producing* a protobuf then it is indicative of some application bug
  (unlike input, where we legitimately might not have a protobuf at
  all).

- Switch to protobuf's ParseFromArray to avoid string construction.

- Small code simplifications
Part of protobuf handling apparently also requires session protocol
decryption, so this adds that to libsession.
Adds protobuf parsing as Session does it.
This adds a deterministic version of session protocol encryption that
differs from crypto_box_seal by using a keyed hash of the sender seed,
recipient pubkey, and message to generate the ephemeral key.

This effectively neuters such an encrypted message to be a regular
crypto_box encryption, which means the sender is later able to decrypt
it; this is thus only really a special case for protobuf+encrypted
config messages for backwards compatible config message support.
The only thing in this header are config-specific, so seems better under
`config`.  This also resolves some issues with circular library
dependencies in the build between config, crypto, and protos.
@jagerman jagerman force-pushed the protobuf branch 4 times, most recently from c3753db to d8d22ce Compare October 4, 2023 19:20
Also moves the `protos` build into /protos rather than building it via
`../` inside src.
The dependencies are causing headaches right now on iOS, and currently
session clients don't need this code so can disable it.
Session clients required the list of hashes from a merge() to perform
various operations based on the messages that were accepted.  This
updates `merge()` to return a vector of accepted hashes.

For the C API, this returns a config_string_list* pointer that needs to
be freed, but contains all the good hashes (the same way
current_hashes() works).
It was only matching 13 but not 13.0, which was making gmp putting in
assembly instructions that ios doesn't support (because gmp only turns
that off if it sees "darwin" in the host string).
Without this we were running `make -j` on macos which is a minor fork
bomb.  Also adds a workaround in case that doesn't work either to fall
back to just -j1.
@jagerman jagerman merged commit 8dc6108 into oxen-io:dev Oct 18, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants