Commit Graph

38 Commits

Author SHA1 Message Date
Harry
9498878a69
Support encrypting in memory bytes to in memory output 2024-05-01 17:40:42 -07:00
Harry
f5b92e518e
Read encrypted attachment files directly off disk using a virtual FileHandle 2024-05-01 16:49:50 -07:00
Ehren Kret
b6640fd2ab move signal core kit tests from ios app repo to signal core kit 2024-04-27 13:54:35 -05:00
Max Radermacher
ea99e9002f
Add async-await support to Promises 2023-09-25 12:49:33 -05:00
Max Radermacher
da1f1fd582
Remove some unused code 2023-09-24 20:21:32 -05:00
Pete Walters
8c92ef2634
Optimize allocations in replaceCharacters 2023-08-15 15:09:59 -05:00
Max Radermacher
e7ab68a542 Remove AES-GCM, AES-CTR, & OpenSSL-Universal 2023-02-13 11:30:41 -08:00
Harry
58287a4b0a
Use Schedulers for Promise methods
* Use Schedulers for Promise methods

* Always put the scheduler argument first

* Fix ordering in calls

* its hard to write code in github workspaces...
2023-02-07 11:35:45 -08:00
george-signal
2f866beb00
Change how excessive diacriticals are removed.
Fixes a bug where some emoji were mistaken for
zalgo, causing all diacritics in a message to get
stripped. Instead, replace "risky" characters with
too many diacritics with the unicode replacement
character, leaving others alone.
2022-07-20 11:19:38 -07:00
Jordan Rose
755746107a Call a Future's observers outside of the Future's state lock
Avoids a reentrancy deadlock when a promise's 'result' is used from
within an observer callback. This is a behavior change only in the
following scenario:

1. A promise is sealed and starts running its observers
2. While fulfilling observers, a new observer is added (on the same
   thread or from on another thread)

Previously, the future would wait until all existing observers have
been run, then run the new observer. Now, the new observer will run
immediately, since the only thing being checked is that the promise
has been sealed. We could do more work to preserve the old behavior,
but it's better to not depend on such intricacies in the first place.
2022-03-03 16:18:30 -08:00
Michelle Linington
a2f6bd08cc Long promise chains can overflow thread's stack
The issue:
`asyncIfNecessary` will always synchronously execute the provided
closure if the target queue and the current queue are the same.

Since promises chains can become extremely long, especially with any
sort of retry behavior, it's possible to exhaust the stack this way. The
overhead for each synchronous promise is ~2.5k of stack size per step.

The fix:
If we want to continue to use `asyncIfNecessary`, we should consider it
"necessary" to async if we're approaching the stack boundary of the
current thread.

This is a bit of a hack, but it seems to work in testing. It's also
reasonably safe. If this does introduce a bug, it'll just be that we're
too aggressive about asyncing. But asyncs are always correct,
synchronous execution of the promise closure is just a perf
optimization.
2021-09-17 23:42:17 -07:00
Matthew Chen
6d4302862a Fix broken tests. 2021-09-08 14:54:58 -03:00
Michelle Linington
1196a68ffc PR Feedback: Rename the function 2021-09-07 20:19:01 -07:00
Michelle Linington
fcc5dae8a6 Fix crash due to queue resurrection
When we're calling dispatch_get_current_queue(), ARC automatically
retains the result of the function and increments the external reference
count of the resulting dispatch queue.

The problem is dispatch queues assume that once their external reference
count goes to zero that the queue is no longer in use. By
re-incrementing, we trigger an assert within libdispatch.

This fix applies a bandaid to this issue. If we don't store the result
of the function in an ARC pointer, then we're not going to inadvetently
retain a dead queue. Instead, we'll use pointer comparisons to check for
equality:
- Since we're not going to use the queue for anything or persist it,
  there's no risk we accidentally extend the queue's lifetime in bad
  ways.
- If the queue is about to expire, we're still allowed to continue our
  block's work as long as we want.

I think it'd be great if we found an alternative to
dispatch_get_current_queue() that allows us to achieve the same
performance. I'll continue to think about this. In the meantime, this
appears to fix this crash.
2021-09-07 20:11:24 -07:00
Nora Trapp
6cf76bc71d Refactor:
* No longer maintain the last queue through the chain. Eventually we may want to
  do this, but for now it's not safe to do until we audit all our queue usage.
* Dispatch to the main queue by default if no queue is specified, matching the
  behavior of PromiseKit. Eventually, we may want to require an explicit queue
  to be provided on every element of the chain to avoid lots of extraneous work
  occuring on the main queue, but we'll need to do an audit of all our call
  sites.
* Cleanup generic usage to mitigate problems where Value can be a Promise. These
  are a tricky subset of issues that result in subtle bugs where, for example,
  you can have "firstly" block that returns a promise, but doesn't actually run
  the promise, instead it just returns the promise as a value to the next block
  in the chain. It requires some very delicate massaging of generics to get this
  to work properly implicitly. If only swift allowed "not" declerations for
  generics, so we could say a promise could be anything *but* another Thenable
  type.
2021-09-01 11:43:56 -07:00
Nora Trapp
13f591e3b8 Further reduce extraneous dispatches 2021-08-27 14:24:47 -07:00
Nora Trapp
cfbf3b0d52 PR Feedback 2021-08-27 12:34:13 -07:00
Nora Trapp
1b21c77d28 Add new promise library and tests 2021-08-26 13:55:39 -07:00
Nora Trapp
eea6884e55 Skip expected assertions during tests 2021-05-07 12:54:01 -07:00
Nora Trapp
64410ab6b3 Add streaming encryption and decryption APIs 2021-04-08 13:22:16 -07:00
Matthew Chen
d7f475e6de Fix bidi cleanup. 2020-10-08 10:36:57 -03:00
Matthew Chen
6baca55cef Fix bidi cleanup. 2020-10-08 10:11:57 -03:00
Matthew Chen
eaab643979 Add test around data parser. 2020-09-01 18:43:34 -03:00
Nora Trapp
e1d1a588cd allow different IV lengths for AESGCM256 2020-02-20 13:15:02 -08:00
Nora Trapp
3991e1f62e Add support for HMAC-SIV encryption. 2020-01-20 15:21:35 -08:00
Michael Kirk
cc9333115c new padding scheme 2019-05-14 09:42:39 -06:00
Michael Kirk
a84ec7ed6c Remove empty test 2018-11-11 10:17:03 -06:00
Matthew Chen
6302c18665 Respond to CR. 2018-10-01 09:41:02 -04:00
Matthew Chen
8a79083519 Respond to CR. 2018-10-01 09:31:24 -04:00
Matthew Chen
7a5ec2e774 Add AES-GCM encrypt with custom IV. 2018-09-28 14:20:55 -04:00
Matthew Chen
3e1f8cbf8e Update tests from master. 2018-09-28 13:28:49 -04:00
Matthew Chen
94176efe26 Update tests from master. 2018-09-28 10:48:02 -04:00
Matthew Chen
312eae37ff Fix rebase breakage. 2018-09-28 09:53:17 -04:00
Matthew Chen
6fb3449e41 Remove Xcode project and podfile. 2018-09-25 14:47:27 -04:00
Matthew Chen
2ebd17ef2c Fix build breakage from SMK. 2018-09-25 13:09:20 -04:00
Matthew Chen
d81dbb53a5 Get SignalCoreKit building in context of main app. 2018-09-21 15:43:01 -04:00
Matthew Chen
0d820a74e9 Apply Cocoapods to test project. 2018-09-21 13:36:53 -04:00
Matthew Chen
ac85091209 Initial code drop. 2018-09-21 12:47:57 -04:00