Page MenuHomePhabricator

Implement method to deserialize olm account from a file
ClosedPublic

Authored by marcin on Feb 20 2023, 4:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 30, 6:08 AM
Unknown Object (File)
Sat, Oct 26, 10:54 PM
Unknown Object (File)
Sat, Oct 26, 10:54 PM
Unknown Object (File)
Sat, Oct 26, 10:54 PM
Unknown Object (File)
Sat, Oct 26, 10:54 PM
Unknown Object (File)
Sat, Oct 26, 10:54 PM
Unknown Object (File)
Sat, Oct 26, 10:54 PM
Unknown Object (File)
Sat, Oct 26, 10:47 PM
Subscribers

Details

Summary

This differential implements a method in NotificationsCryptoModule that can deserialize flat file containing JSON-fied pickled olm account into in-memory CryptoModule onject that is capable to perform end2end encrypted messaging sessions.

Test Plan

Temporarily make this method public. Partially modify this method so that it does not read from a file but takes JSONI-ified pickled olm account directly and use it to create CryptoModule instance in CommCoreModule where we read pickled public olm account from the database. Use XCode debugger or logging to examine object
content. JSON-ified pickled olm account can be created in CommCoreModule.

Diff Detail

Repository
rCOMM Comm
Branch
marcin/eng-2901
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

marcin published this revision for review.Feb 20 2023, 4:43 AM
native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
26 ↗(On Diff #22879)

I think ifstream::in is the default, but can be left for clarity.

46 ↗(On Diff #22879)

What if JSON is malformed and account doesn't exist?

native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
46 ↗(On Diff #22879)
  1. The counterpart method to this one - serializeAndFlushCryptoModule - introduced in child differential ensures that either entire JSON (containing "account" key) is written or the method fails.
  2. Both this and serializeAndFlushCryptoModule are private and will be called in public methods only with olm notifications account path.

That said if serializeAndFlushCryptoModule fails on the very first write (first after last deletion of this file) to olm notifications account path, we will fail on the fist if in deserializeCryptoModule (the file does not exist). If it failed on n-th write, we will read correct content after last successful write to this file. So I think we can add this if statement and throw, but my understanding is that it is not necessary.

bartek added inline comments.
native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
46 ↗(On Diff #22879)

Yes, I understand that, my concern was the same as in D6777.
But you are right, if this file is only written by serializeAndFlushCryptoModule - this statement is unnecessary.

This revision is now accepted and ready to land.Feb 23 2023, 12:28 AM