Compare commits

...

1032 Commits

Author SHA1 Message Date
Moxie Marlinspike
31eddbf346 Bump version to 2.3.0
// FREEBIE
2014-11-21 14:49:14 -08:00
Moxie Marlinspike
e9b383d277 Add jobs for pending push messages during migration.
// FREEBIE
2014-11-21 12:53:40 -08:00
Moxie Marlinspike
eeafb81c90 Fix escaping in danish translation.
// FREEBIE
2014-11-21 12:53:24 -08:00
Moxie Marlinspike
02e27c94f2 Update language translations.
// FREEBIE
2014-11-21 11:49:35 -08:00
Jake McGinty
167386ea49 make the light theme light
Fixes #2111
Tested on GB and LP
// FREEBIE
2014-11-20 21:59:15 -08:00
Jake McGinty
e31994ac77 proguard has guarded its last pro
// FREEBIE
2014-11-20 17:45:31 -08:00
Moxie Marlinspike
ea9a5decac Update gradle-witness and actually use spongycastle.
// FREEBIE
2014-11-20 16:46:35 -08:00
Moxie Marlinspike
1cb191a6ee Move targetSdkVersion back down to 19.
// FREEBIE
2014-11-20 15:58:32 -08:00
Jake McGinty
60737bdd7b proguard: don't warn for test classes
// FREEBIE
2014-11-19 14:52:02 -08:00
Moxie Marlinspike
2dded4888e No more push encoding pretense.
// FREEBIE
2014-11-19 14:45:12 -08:00
Jake McGinty
eaf89735b8 encapsulated delivery icon to separate from lock
and as a bonus some tweaked text sizes and colors
// FREEBIE
2014-11-19 12:56:44 -08:00
Jake McGinty
8fa2f92a91 use latest appcompat and build tools, add dagger pin
// FREEBIE
2014-11-18 17:03:10 -08:00
Moxie Marlinspike
174324e2a0 Potential fix for BroadcastReceiver crash.
// FREEBIE
2014-11-18 14:55:16 -08:00
Jake McGinty
bc3686058a optimize new assets
Thanks to @pejakm for pointing out the emoji optimization.
// FREEBIE
2014-11-18 11:27:10 -08:00
Jake McGinty
0110015c8b remove unused image resources
// FREEBIE
2014-11-18 11:27:10 -08:00
Jake McGinty
5ca8a6d421 materialize conversation item indicators
// FREEBIE
2014-11-18 11:27:08 -08:00
Jake McGinty
0fc9ff7490 add "elevation" window overlay for android 4.x too
// FREEBIE
2014-11-17 12:14:09 -08:00
Jake McGinty
08d939b010 fix AppCompat theme crash
Fixes #2084
// FREEBIE
2014-11-17 11:51:49 -08:00
Jake McGinty
020920d988 silly actionbar shadow issue
// FREEBIE
2014-11-17 11:28:57 -08:00
Moxie Marlinspike
bd3d9ac533 Update JobManager README.md
// FREEBIE
2014-11-17 09:17:14 -08:00
agrajaghh
85670d95ee Fix README.md formatting
// FREEBIE

Closes #2101
2014-11-17 08:57:21 -08:00
Moxie Marlinspike
3d1007d101 Added README
// FREEBIE
2014-11-16 17:24:05 -08:00
Moxie Marlinspike
35821d444e Move responsibility for Context injection out of JavaSerializer.
// FREEBIE
2014-11-16 17:23:33 -08:00
Moxie Marlinspike
3cd7c2d8e5 libjobqueue javadoc and scoping.
// FREEBIE
2014-11-16 15:53:51 -08:00
Moxie Marlinspike
5b08791086 Fix regression with providers being registered.
// FREEBIE
2014-11-14 15:44:49 -08:00
Jake McGinty
31b9dcb5eb stop crashes when sending sms
// FREEBIE
2014-11-15 02:14:37 +03:00
Jake McGinty
43adc75428 add icon back
// FREEBIE
2014-11-15 02:04:17 +03:00
Jake McGinty
67a4523ca7 update gradle+plugins, update gradle-witness
// FREEBIE
2014-11-14 13:07:04 +03:00
Moxie Marlinspike
b35b9be0c8 Add missing copyright headers from libtextsecure.
// FREEBIE
2014-11-12 18:37:16 -08:00
Moxie Marlinspike
9215322846 Abstract out TrustStore interface.
// FREEBIE
2014-11-12 17:09:59 -08:00
Moxie Marlinspike
cbebc040cc Make ProGuard with with Dagger 2014-11-12 16:03:58 -08:00
Moxie Marlinspike
bea26e83da Correctly process push messages with identity key conflicts. 2014-11-12 15:42:43 -08:00
Moxie Marlinspike
a85dbce041 Correctly handle PKWM via SMS. 2014-11-12 15:42:43 -08:00
Moxie Marlinspike
baaa3514d4 Fix delivery receipts in group messages.
Fixes #2056
Fixes #2067
Fixes #2087
2014-11-12 15:42:43 -08:00
Moxie Marlinspike
71fdaac1b2 Fix regressions for registration. 2014-11-12 15:42:43 -08:00
Moxie Marlinspike
fb31319e52 Put everything under either internal or api. 2014-11-12 15:42:43 -08:00
Moxie Marlinspike
08ed90c5ec Split out Util functions. 2014-11-12 15:42:43 -08:00
Moxie Marlinspike
0d102f76cc Move ListenableFutureTask up to parent. 2014-11-12 15:38:23 -08:00
Moxie Marlinspike
28cb1ed85b Move DirectoryUtil up to parent. 2014-11-12 15:29:59 -08:00
Moxie Marlinspike
cd9b20dc9d Move dependency up to parent. 2014-11-12 15:29:59 -08:00
Moxie Marlinspike
f09abff407 Refactor out old classes. 2014-11-12 15:29:59 -08:00
Moxie Marlinspike
f9934bd8e5 Modernize libtextsecure layout 2014-11-12 15:29:59 -08:00
Moxie Marlinspike
1182052c7f Rename library to libtextsecure 2014-11-12 15:29:58 -08:00
Moxie Marlinspike
0d06d50a65 Let's have JobManager only deal with checked exceptions.
Also, switch to Builder for JobManager construction.
2014-11-12 15:29:58 -08:00
Moxie Marlinspike
d9d4ec9d9d Fix some bugs with PKWM padding and attachment detection. 2014-11-12 15:29:58 -08:00
Moxie Marlinspike
9a6f65988f Add support for dependency injection, and accompanying tests. 2014-11-12 15:29:58 -08:00
Moxie Marlinspike
601e233d47 Add account management interface to libtextsecure api 2014-11-12 15:28:08 -08:00
Moxie Marlinspike
ae178fc4ec Move API around a little, eliminate TransportDetails interface. 2014-11-12 15:26:25 -08:00
Moxie Marlinspike
cafe03a70a Transition the outbound pipeline to JobManager jobs. 2014-11-12 15:26:25 -08:00
Moxie Marlinspike
99f42e2ee1 Move API around. 2014-11-12 15:21:32 -08:00
Moxie Marlinspike
a3f1d9cdfd Beginning of libtextsecure refactor.
1) Break out appropriate components.

2) Switch the incoming pipeline from SendReceiveService to
   the JobManager.
2014-11-12 15:21:32 -08:00
Jake McGinty
4cab657ebe clear pending slides when attachment reselected
Fixes #2012

// FREEBIE
2014-10-29 18:50:11 -07:00
Jake McGinty
db6f8618e6 padding workaround for bug in appcompat-v7 21.0.0
bug: https://code.google.com/p/android/issues/detail?id=77982

// FREEBIE
2014-10-29 18:28:20 -07:00
Jake McGinty
98af1fb6ee shorten blocks of text
// FREEBIE
2014-10-29 16:53:25 -07:00
Jake McGinty
ad1d55f12d enable proguard
// FREEBIE
2014-10-29 16:53:21 -07:00
Jake McGinty
7df49811b7 replace ABS with AppCompat
// FREEBIE
2014-10-29 16:51:55 -07:00
Jake McGinty
ff2ac8a66e refactor ListenableFutureTask and make saves async
// FREEBIE
2014-10-28 02:25:41 -05:00
Jake McGinty
53da1f849a in-app image media preview
// FREEBIE
2014-10-28 00:50:01 -05:00
Moxie Marlinspike
503d1ef452 Bump version to 2.2.0
// FREEBIE
2014-10-24 16:51:15 -07:00
Moxie Marlinspike
9accd92757 Updated language translations.
// FREEBIE
2014-10-24 13:18:52 -07:00
agrajaghh
306da92031 Test case and fix for deferred jobs.
Closes #2033
2014-10-24 12:08:03 -07:00
Moxie Marlinspike
e7b6a852c5 Fix bug caused by 1mod8 compatibility issue.
In the switch from v3, we bind identities in the message MAC
instead of doing the 1mod8 trick.  Since identity keys were
never set as 1mod8, it seemed like we could just remove it.

However, PreKeys are durable.  If an old client upgrades to v3,
it has a bunch of keys that *were* set to 1mod8 floating around.
The Curve25519 donna code re-sets the private key bits on every
operation, which results in a different key, and breaks the output
of an agreement.

So now we don't intentionally generate keys with 1mod8, but we
have to remove the donna code to honor existing 1mod8 keys for
the rest of time.  Trevor is squarely to blame.

// FREEBIE
2014-10-23 17:11:46 -07:00
Moxie Marlinspike
9dfaf19516 Merge pull request #2028 from mcginty/revert-generic-contenttype
revert content-type generics
2014-10-22 19:37:45 -07:00
Jake McGinty
34aece0b43 revert content-type generics
// FREEBIE
2014-10-22 19:37:04 -07:00
Moxie Marlinspike
9768de2d5e Short circuit self-send.
// FREEBIE
2014-10-22 18:28:03 -07:00
Moxie Marlinspike
c3eb0ea9db Check job requirements are satisfied in between retry iterations.
// FREEBIE
2014-10-21 13:50:38 -07:00
Moxie Marlinspike
4cdc0a3e61 Make signed prekey generation happen through the job queue. 2014-10-21 12:47:08 -07:00
Moxie Marlinspike
b568ce70b2 Make delivery receipts work correctly for groups. 2014-10-20 21:06:34 -07:00
Moxie Marlinspike
18b0601990 Dependency updates and gradle housekeeping. 2014-10-20 21:06:09 -07:00
Moxie Marlinspike
b308996885 Switch to using our own JobManager.
// FREEBIE
2014-10-20 19:13:06 -07:00
Moxie Marlinspike
73d896f378 Index shouldn't be unique. 2014-10-20 19:02:42 -07:00
Moxie Marlinspike
36ec1d84a1 Implement delivery receipts.
1) Support a "receipt" push message type.

2) Identify messages by timestamp.

3) Introduce a JobManager to handle the queue for network
   dependent jobs.
2014-10-20 19:02:42 -07:00
Moxie Marlinspike
8d6b9ae43e Incorporate PR feedback. Add license and eliminate duplicate code.
// FREEBIE
2014-10-20 18:38:52 -07:00
Moxie Marlinspike
a95cc0eba2 Switch to byte array.
// FREEBIE
2014-10-20 18:35:45 -07:00
Moxie Marlinspike
58d101ff2e Support for job "group ids."
A job can specify a group id, and jobs with the same group id
will run sequentially.
2014-10-20 18:35:45 -07:00
Moxie Marlinspike
544f06451f Persistent job queue, derivative of android-priority-jobqueue.
// FREEBIE
2014-10-20 18:35:45 -07:00
Moxie Marlinspike
20cf775b1e Fix up routing activity actions. 2014-10-20 14:55:34 -07:00
Moxie Marlinspike
5fcc135f81 Make sure senderkeys encrypt is correctly initialized. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
9a0ed659f7 Initial support for sender keys. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
54612159be Update ed25519 extract and tests 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
355d0be78a Introduce new simultaneous initiate strategy.
1) Fix bugs that prevented decrypt() from being non-transactional
   in some cases.

2) Introduce a new unified storage interface.

3) Transition simultaneous initiate from the "needs refresh"
   strategy to one that uses session state resurrection and
   promotion.
2014-10-20 12:25:40 -07:00
Moxie Marlinspike
73b75a4a27 Fix build. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
c4209a65e3 Don't assert on bad padding. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
9dce376780 Correctly handle formatting when "one time PreKey" is absent. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
07c61394e9 When processing PreKeyBundle, archive current session if it exists. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
3e287f930d Better thread safety for session building <-> use. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
7b1a37bd91 Make registration ID optionally extended. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
2db44a1578 Make generated PreKeyIds exclude both 0 and Medium.MAX_VALUE. 2014-10-20 12:25:40 -07:00
Moxie Marlinspike
006c9aae7b Only remove unsigned prekey if bundled message decrypts properly. 2014-10-20 12:25:39 -07:00
Moxie Marlinspike
b147a90463 This exception is never thrown. 2014-10-20 12:25:39 -07:00
Moxie Marlinspike
741171c49f Switch to CBC mode with a derived IV.
1) Since we're not CPU or space constrained (and are in fact
   padding), and since keystream reuse would be more catastrophic
   than IV reuse without chosen plaintext.
2014-10-20 12:25:39 -07:00
Moxie Marlinspike
c375ed8638 MIPS NDK support. Apparently there are mips devices... 2014-10-20 12:25:39 -07:00
Moxie Marlinspike
238f29c90a Updated to latest of Trevor's ref10-extract 2014-10-20 12:25:39 -07:00
Moxie Marlinspike
084f27a2e8 omg trevor 2014-10-20 12:25:39 -07:00
Moxie Marlinspike
27b5bf54cc Remove 1 mod 8. 2014-10-20 12:25:39 -07:00
Moxie Marlinspike
eda393b11c Minor refactoring and renaming. 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
c330eef7b9 Make PreKeyWhisperMessage decrypt more reliably atomic. 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
1eb3884b7a Update to latest ref10-extract ed25519 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
5ea3b3038e Remove verification tag.
1) Remove verification tag from PreKeyWhisperMessage.

2) Include sender and recipient identity keys in the MAC of
   each WhisperMessage.
2014-10-20 12:25:38 -07:00
Moxie Marlinspike
641ac9aed9 Rename axolotl terminology.
1) ephemeralKey -> ratchetKey

2) Have the caller specify Alice/Bob orientation.

3) Reorganize verification tag.

4) Remove verification tag from key exchange messages, replace
   with signatures in both directions.
2014-10-20 12:25:38 -07:00
Moxie Marlinspike
82bd75fb75 Fix padding problem. 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
c94a7b1eff Make sure "previous counter" is never negative. 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
4caebdcd06 Update tests for new API. 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
b3cece27d6 Update SessionCipher javadocs. 2014-10-20 12:25:38 -07:00
Moxie Marlinspike
819982af7b Rearrange decrypt API.
1) Change SessionBuilder to only establish sessions via
   KeyExchangeMessage and PreKeyBundles.

2) Change SessionCipher to decrypt either WhisperMessage
   or PreKeyWhisperMessage items, automatically building
   a session for the latter.

3) Change SessionCipher to tear down new sessions built
   with PreKeyWhisperMessages if the embedded WhsiperMessage
   fails to decrypt.
2014-10-20 12:25:38 -07:00
Moxie Marlinspike
42cf53e487 Rename "pendingPreKey" to "unacknowledgedPreKeyMessage" 2014-10-20 12:23:15 -07:00
Moxie Marlinspike
e0d2398ca5 Rename InitializationParameters -> AxolotlParameters 2014-10-20 12:23:14 -07:00
Moxie Marlinspike
3f299936bf Only create signed prekey if push registered. 2014-10-20 12:23:14 -07:00
Moxie Marlinspike
540592d71f Upgrade libaxolotl to the latest gradle plugin. 2014-10-20 12:23:14 -07:00
Moxie Marlinspike
5a9e5672d3 Updated README 2014-10-20 12:23:11 -07:00
Moxie Marlinspike
0a23b5fcd5 Added helper method for generating signed PreKeys. 2014-10-20 12:23:10 -07:00
Moxie Marlinspike
f0c22d593f Simplify/clarify internal interfaces and introduce optional types. 2014-10-20 12:23:10 -07:00
Moxie Marlinspike
5f5ddd7c26 Generate SignedPreKey records, improve SignedPreKey cleanup. 2014-10-20 12:23:08 -07:00
Moxie Marlinspike
144f269059 Upgrade curve25519-donna to latest. 2014-10-20 12:17:24 -07:00
Moxie Marlinspike
0d532afd8e Rename 'device key' to 'signed prekey'. 2014-10-20 12:17:24 -07:00
Moxie Marlinspike
07fd17ccda Add padding for push messages.
1) Use 'bit padding.'

1) By default, pad at 160 byte increments.
2014-10-20 12:17:23 -07:00
Moxie Marlinspike
fcaa3f0d73 Simplify HKDF interface. 2014-10-20 12:17:23 -07:00
Moxie Marlinspike
64b40df15b Add V3 support for KeyExchangeMessage case.
1) V3 KeyExchangeMessages can now contain signatures and
   verification tags.
2014-10-20 12:17:23 -07:00
Moxie Marlinspike
77ff9cece8 Add a 'verification tag' to incoming PreKeyWhisperMessage bundles. 2014-10-20 12:17:23 -07:00
Moxie Marlinspike
6326ef73f3 Split HKDF secret derivation and parsing. 2014-10-20 12:17:23 -07:00
Moxie Marlinspike
f29d1e6269 Add support for a compliant HKDF implementation. 2014-10-20 12:17:23 -07:00
Moxie Marlinspike
d6c5e92c9d Collapse RatchetingSessionV2 and RatchetingSessionV3. 2014-10-20 12:17:23 -07:00
Moxie Marlinspike
811479d168 Add first cut of protocol v3 support.
1) Use the new /v2/keys API for storing/retrieving prekey bundles.

2) For sessions built with PreKeyBundle and PreKeyWhisperMessage,
   use a v3 ratcheting session when available.
2014-10-20 12:17:23 -07:00
Moxie Marlinspike
2ed8d333d9 Add ed25519 2014-10-20 12:14:18 -07:00
Moxie Marlinspike
79020cd33c Better FS Locking. 2014-10-20 12:14:18 -07:00
Moxie Marlinspike
c8757c2134 Make helper static. 2014-10-20 12:14:18 -07:00
Moxie Marlinspike
2a65257182 Add serialization helpers for IdentityKeyPair. 2014-10-20 12:14:18 -07:00
Moxie Marlinspike
931605a1c4 Move identity key verification into libaxolotol. With tests. 2014-10-20 12:14:18 -07:00
Moxie Marlinspike
81ae9af2e4 Add "last resort" PreKey generation to KeyHelper. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
e84a0948e9 Update README 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
5239b3e8f8 Add basic README. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
a601c56af1 Collapse SessionRecord, SessionState, and PreKeyRecord interfaces. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
5a3c19fe3e Javadocs, and some minor refactoring. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
af45e5d544 SessionBuilder improvements, more extensive SessionBuilder tests. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
72af8b11c2 Move session construction and KeyExchangeMessage into libaxolotl.
1) Add plain two-way key exchange support libaxolotl by moving
   all the KeyExchangeMessage code there.

2) Move the bulk of KeyExchangeProcessor code to libaxolotl
   for setting up sessions based on retrieved prekeys, received
   prekeybundles, or exchanged key exchange messages.
2014-10-20 12:14:17 -07:00
Moxie Marlinspike
a1db221caf Collapse KeyExchangeMessage and KeyExchangeProcessor interfaces. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
14b8f97de2 Reorganize session store load/store operations. 2014-10-20 12:14:17 -07:00
Moxie Marlinspike
d902c12941 Break core ratchet out into libaxolotol.
1) Break the core cryptography functions out into libaxolotol.

2) The objective for this code is a Java library that isn't
   dependent on any Android functions.  However, while the
   code has been separated from any Android functionality,
   it is still an 'android library project' because of the
   JNI.
2014-10-20 12:10:02 -07:00
Moxie Marlinspike
fe3d91c40c Bump version to 2.1.10
// FREEBIE
2014-10-18 14:19:45 -07:00
Jake McGinty
31167d11dd use wildcard media types, don't crash on preview fail
// FREEBIE
2014-10-17 17:59:56 -07:00
Jake McGinty
6e3751a0c5 sane fallback for media selection on exception
Fixes #1763
// FREEBIE
2014-10-17 17:41:42 -07:00
Jake McGinty
b5941fb3fd actually fallback when mms local params unset
// FREEBIE
2014-10-15 17:14:12 -07:00
Moxie Marlinspike
cfccd367ad Bump version to 2.1.9
// FREEBIE
2014-10-13 19:02:37 -07:00
Moxie Marlinspike
2c8c6a410c Updated language translations.
// FREEBIE
2014-10-13 18:11:20 -07:00
Jake McGinty
2075bba86c switch back to BufferedInputStream
// FREEBIE
2014-10-13 15:38:27 -07:00
Jake McGinty
1d7b47c982 add CM APN list, remove non-MMS APN info
Fixes missing Verizon APN. Overall, smaller DB size but more APN info.
// FREEBIE
2014-10-13 12:33:54 -07:00
Jake McGinty
89fb80fcc5 MmsConnection refactor
- Use Apache HttpClient v4.x, only library that seems to like HTTP proxies
- Remove custom redirect logic in favor of library's

Fixes #1904
// FREEBIE
2014-10-13 12:26:38 -07:00
Moxie Marlinspike
f1d230ce6e Merge pull request #1964 from mcginty/maven-https
use https maven central
2014-10-01 17:16:11 -07:00
Jake McGinty
f51a5aa7eb use https maven central
// FREEBIE
2014-09-30 21:46:13 -07:00
Moxie Marlinspike
cf9c9bbfd7 Bumping version to 2.1.8
// FREEBIE
2014-09-15 19:34:30 -07:00
Jake McGinty
b8a3e87f3d custom redirect logic
// FREEBIE
2014-09-15 14:13:27 -07:00
Moxie Marlinspike
e5bad2746f Merge pull request #1917 from mcginty/mccmnc-crash
don't crash if we can't get an mccmnc
2014-09-15 09:32:28 -07:00
Jake McGinty
7316f17674 don't crash if we can't get an mccmnc
Fixes #1916
// FREEBIE
2014-09-14 17:46:07 -07:00
Veeti Paananen
609e69a801 Show date and year for ancient (> 1 year old) messages
The timestamp shown for very old messages only includes the time without
a date at all. Fix it. FREEBIE.
2014-09-08 15:08:46 -07:00
Moxie Marlinspike
d979593cbb Bump version to 2.1.7 2014-09-06 15:38:55 -07:00
Moxie Marlinspike
0808e00d0e Updated translations.
// FREEBIE
2014-09-06 14:54:32 -07:00
Moxie Marlinspike
2045c828be Merge pull request #1892 from mcginty/bitmap-memory
fallback to imprecise scaling if low memory
2014-09-06 14:53:56 -07:00
Jake McGinty
1b3bd32805 fallback to rough scaling if low memory
// FREEBIE
2014-09-05 13:00:26 -07:00
Moxie Marlinspike
877f2a25a9 Merge pull request #1887 from mcginty/mms-3xx
allow url client to follow redirects before checking response code
2014-08-29 15:23:00 -07:00
Jake McGinty
eb462f0345 force redirects, get inputstream first 2014-08-29 16:34:25 -05:00
Moxie Marlinspike
102b40543d Merge pull request #1886 from mcginty/mms-bad-pdu-logging
enable more verbose PDU parse logging
2014-08-29 14:33:25 -07:00
Jake McGinty
12077c6dad enable more verbose PDU parse logging
// FREEBIE
2014-08-29 16:29:36 -05:00
Jake McGinty
7441c191a7 Format outgoing MMS using SMIL.
// FREEBIE

Closes #1879
2014-08-29 14:29:24 -07:00
Lukas Barth
b355991b0b Remove superfluous repetition
//FREEBIE
2014-08-29 15:33:19 +02:00
Moxie Marlinspike
350eb438c0 Bump version to 2.1.6
// FREEBIE
2014-08-20 16:48:12 -07:00
Moxie Marlinspike
da7bbf4144 Merge pull request #1862 from mcginty/db-localization-ignore
disable localized collators in ApnDB
2014-08-20 14:39:50 -07:00
Jake McGinty
a0842f329f disable localized collators in ApnDB
// FREEBIE
2014-08-20 13:41:59 -07:00
Moxie Marlinspike
567224b4a6 Merge pull request #1861 from mcginty/cursor-leak
prevent another cursor leak
2014-08-20 12:32:24 -07:00
Jake McGinty
9b495d8c83 prevent another cursor leak
// FREEBIE
2014-08-20 12:29:40 -07:00
Moxie Marlinspike
8c55ea09d9 Updated language translations.
// FREEBIE
2014-08-20 10:53:16 -07:00
Moxie Marlinspike
5264ebed67 Avoid leaking cursor.
// FREEBIE

Closes #1838
2014-08-20 10:36:39 -07:00
Jake McGinty
7f51f9fd5b apntool and ApnDatabase
// FREEBIE
2014-08-20 10:36:39 -07:00
Moxie Marlinspike
40495a2261 Merge pull request #1854 from mcginty/content-description
improve some content descriptions
2014-08-19 21:00:20 -07:00
Jake McGinty
a6c1fdd914 improve some content descriptions
// FREEBIE
2014-08-19 19:10:15 -07:00
Jake McGinty
020d61dd6e migrate nav panel items to actionbar
Fixes #1819
Closes #1839
// FREEBIE
2014-08-19 15:20:57 -07:00
Jake McGinty
dee23b266f update support-v4 library
Fixes #1832
// FREEBIE
2014-08-14 23:29:25 -07:00
Moxie Marlinspike
4cf57fbb55 Bump version to 2.1.5
// FREEBIE
2014-08-13 16:47:47 -07:00
Moxie Marlinspike
85da05397a Update language translations.
// FREEBIE
2014-08-13 15:14:08 -07:00
Moxie Marlinspike
f4e9c4a710 Minor MMS cleanup.
// FREEBIE

Closes #1827
2014-08-13 14:40:19 -07:00
Jake McGinty
28e14f47cf use URLConnection for MMS because it's better
// FREEBIE
2014-08-13 12:36:47 -07:00
Jake McGinty
d2edda837a Update Play services and add checksum
Quoting Google employee: "5.0.77 had some serious issues, team didn't want
anyone using it"

// FREEBIE
2014-08-12 20:12:52 -07:00
Jake McGinty
213715a0dc braces around loop, proper spacing
// FREEBIE
2014-08-12 18:23:18 -07:00
Moxie Marlinspike
7b0479ff0f requestRouteToHost of URL rather than MMSC on MMS Download
// FREEBIE

Closes #1806
2014-08-12 17:31:28 -07:00
rymdhund
feabbb33d2 MMS Fixes
1) Respect proxyIfPossible flag and make sure to try all mms APNs

2) Reorder mmsc connection process
2014-08-12 17:30:19 -07:00
rymdhund
d3da409774 Add time to saved media filenames
see #1689
// FREEBIE
2014-08-12 16:09:26 -07:00
Moxie Marlinspike
edb04138c2 Merge pull request #1825 from mcginty/resource-removal
remove old, unused resources
2014-08-12 13:57:49 -07:00
Jake McGinty
8bf537bb09 remove old, unused resources
// FREEBIE
2014-08-12 12:12:08 -07:00
Moxie Marlinspike
b80593b5f5 Merge pull request #1821 from mcginty/mms-npe
prevent MMS notification NPE
2014-08-11 11:08:44 -07:00
Jake McGinty
b61e7839f4 prevent MMS notification NPE
// FREEBIE
2014-08-10 21:15:55 -07:00
Drew Hintz
7b41b1492e Shrink png files using pngout. Saves 608kB. FREEBIE. 2014-08-07 17:56:08 -07:00
Moxie Marlinspike
928b9687ef Bump version to 2.1.4
// FREEBIE
2014-08-04 20:48:02 -07:00
Jake McGinty
306c127803 fix EmojiLRU concurrency exception
// FREEBIE
2014-08-04 16:51:44 -07:00
Jake McGinty
239a11bfd2 fix unused argument
// FREEBIE
2014-08-04 15:30:52 -07:00
Jake McGinty
de63b0dd96 make reminder a custom view, make push reminder
// FREEBIE
2014-08-04 15:25:53 -07:00
Jake McGinty
eb4ac40051 don't use old emoji recents, broken
Fixes #1782
// FREEBIE
2014-08-04 15:23:43 -07:00
Moxie Marlinspike
dda4459e5a Bump version to 2.1.3
// FREEBIE
2014-08-02 23:43:45 -07:00
Moxie Marlinspike
8726dd51be Can't toast on this thread.
// FREEBIE
2014-08-02 23:15:57 -07:00
Moxie Marlinspike
e53bbe8453 Bumping version to 2.1.2
// FREEBIE
2014-08-01 16:14:02 -07:00
Moxie Marlinspike
ecb67cd84f Updated language translations.
// FREEBIE
2014-08-01 14:41:00 -07:00
Moxie Marlinspike
861d27279d Whoops, add GcmRegistrationService to Manifest.
// FREEBIE
2014-08-01 14:33:17 -07:00
Veeti Paananen
bef5b8f3e9 Occupy all vertical space for emoji grid
Fixes the recent emoji list leaving an empty gap at the bottom of the
drawer depending on the number of items shown.
2014-08-01 13:40:19 -07:00
Veeti Paananen
9e74b5c892 Remove gray placeholder squares while loading emoji 2014-08-01 13:40:19 -07:00
Veeti Paananen
3597915d17 Add a backspace key to the emoji drawer 2014-08-01 13:40:19 -07:00
Veeti Paananen
40ce0cebe0 Fix emoji backwards compatibility recents crash
The old emoji drawer stored emoji with a .png suffix. Replace it during
list deserialization.
2014-07-31 02:49:36 +03:00
jhertel
26d58047b5 Update BUILDING.md
Correction of a typo and a few style incongruences.

// FREEBIE
Closes #1750
2014-07-28 09:36:03 -07:00
Jake McGinty
7d688846f9 Move default SMS and system import to "reminders"
// FREEBIE
Closes #1730
2014-07-27 01:09:39 -07:00
McLoo
acc7c4c1c6 Null check for cipher text to prevent NPE on decryption
Fixes #1703
Closes #1728
// FREEBIE
2014-07-26 23:02:11 -07:00
Jake McGinty
530ad7bc86 new emoji drawer
// FREEBIE
Closes #1746
2014-07-26 13:35:03 -07:00
Jake McGinty
bea3c33223 disable passphrase creation on registration
// FREEBIE
Closes #1726
2014-07-25 17:46:50 -07:00
Moxie Marlinspike
9ef14a0f64 Upgrade to new GCM API. 2014-07-23 15:40:45 -07:00
Moxie Marlinspike
c632b32ff8 Bumping version to 2.1.1 2014-07-19 11:13:18 -07:00
Moxie Marlinspike
40698212bb Create a Curve25519 asymmetric master secret for users without.
Fixes #1701
2014-07-18 22:16:12 -07:00
Veeti Paananen
19ae5043cc Add number of messages to the notification number attribute
Although not used by stock Android, many custom ROM's (and possibly OEM
versions?) have a setting to display the "number" count of a notification
overlayed on the status bar icon. Add support for this.

Closes #1637
2014-07-16 11:50:42 -07:00
rymdhund
d1dd50e31c Add date to saved media filenames
Fixes #1689
Closes #1693
2014-07-16 11:46:18 -07:00
Jake McGinty
23a1c1c8fa Upgrade to latest Android gradle plugin
// FREEBIE
Closes #1660
2014-07-16 11:12:51 -07:00
Moxie Marlinspike
3a62a8b428 Bumping version to 2.1.0 2014-07-15 10:05:15 -07:00
Moxie Marlinspike
cfac27645b Update language translations.
// FREEBIE
2014-07-14 18:44:34 -07:00
Jake McGinty
f6e04d0f89 use latest android number as recipient number
Fixes #791
// FREEBIE
2014-07-14 16:22:15 -07:00
Jake McGinty
61d18f49ad Merge pull request #1678 from veeti/check-icon
Add xxhdpi check drawable for notifications
2014-07-07 16:09:44 -05:00
Veeti Paananen
f26f89d63d Add xxhdpi check drawable for notifications
Fixes blurry mark as read icon on Android Wear. FREEBIE.
2014-07-05 02:40:00 +03:00
Moxie Marlinspike
66aad852f8 Merge pull request #1642 from mcginty/canonical-bunk-addresses
don't try to load recipients for each filter text
2014-06-25 08:06:00 -07:00
Jake McGinty
da0eb5a779 no longer load a recipient for each filter text
// FREEBIE
2014-06-24 20:33:04 -07:00
Jake McGinty
a82d2dfc5c Revert "change out key cached icon to be more unique"
This reverts commit d6d76fa953.
2014-06-24 19:20:16 -07:00
McLoo
d429f9113b Replace XML serializer in plaintext export
Fixes #342

- using regex pattern/matcher to escape chars below 0x0020 and
  above 0xd7ff
- using String.Replace to escape XML entities
- changed XmlPullParser from Xml.newPullParser() to
  XmlPullParserFactory parser to fix import on GB
2014-06-24 13:02:36 -07:00
Moxie Marlinspike
8f85eb1822 Remove unused files.
Fixes #1522

// FREEBIE
2014-06-24 08:32:59 -07:00
Moxie Marlinspike
358c923891 Merge pull request #1630 from mcginty/remove-keys-list
remove ReviewIdentitiesActivity
2014-06-23 11:17:17 -07:00
Lukas Barth
2d9cd8eb52 Fixing race condition and other mistakes. Fixes #1603.
// FREEBIE
2014-06-23 11:16:37 -07:00
Moxie Marlinspike
db1d846833 Merge pull request #1631 from mcginty/disable-encrypted-export
temporarily disable encrypted backup
2014-06-23 07:18:50 -07:00
Jake McGinty
5121ab0eed temporarily disable encrypted backup
// FREEBIE
2014-06-22 16:40:02 -07:00
Jake McGinty
f63f95404e remove ReviewIdentitiesActivity
// FREEBIE
2014-06-22 16:21:30 -07:00
Jake McGinty
622d8975fc add section about submitting useful bug reports 2014-06-20 12:24:36 -07:00
Moxie Marlinspike
81365eff36 Merge pull request #1614 from mcginty/contact-list-security
move FLAG_SECURE to PassphraseRequiredMixin
2014-06-17 21:47:00 -07:00
Florian Walch
453610c39f Add Travis CI config.
//FREEBIE
2014-06-17 14:13:42 -07:00
Jake McGinty
5ce6dc954a move FLAG_SECURE to PassphraseRequiredMixin
Fixes #1402
// FREEBIE
2014-06-16 20:41:13 -07:00
Özgür Emir
c85a8bbb38 Always show the time of the received message. 2014-06-16 15:57:39 -07:00
agrajaghh
0f9a6e6296 add custom phone number type 2014-06-16 15:27:33 -07:00
phenx-de
d8cb893681 Fixes "subtitle is not updated when select all is pressed"
// FREEBIE
2014-06-16 09:33:35 -07:00
Michael Kaiser
1ad54e7b88 Fix more leaked service connections
PassphraseRequiredMixin might check for a bound service at a time where
the bind has been requested but the service connection has not been
established yet, and therefore fail to call unbindService, leading to a
leaked service connection. This fixes #1518.
2014-06-15 19:28:09 -07:00
Moxie Marlinspike
0d35e2bfa9 Fix the "Tap for X fallback" labels. 2014-06-13 17:48:56 -07:00
Moxie Marlinspike
983bf672cf Fix UI side of broken MMS fallback.
1) Actually tell the SendReceiveService to send the MMS if it is
   one.

2) Display the correct string (SMS vs MMS) in the fallback dialog.
2014-06-13 17:39:29 -07:00
Moxie Marlinspike
1c2e1a07f5 Fixes for outgoing SMS/MMS direct and fallback behavior.
1) Correct MMS fallback settings.

2) Prevent SMS/MMS messages from leaking out under certain
   circumstances when they shouldn't.
2014-06-13 17:15:46 -07:00
Moxie Marlinspike
2d739a324e Validate MMS delivery destination.
We can't depend on validated Recipients anymore, so this adds
parity to the validation the SMS transport does now.

Fixes #1592
2014-06-13 16:15:33 -07:00
Moxie Marlinspike
ba1055df8e Correct contextual send language.
1) Use "secure" and "insecure" vs "encrypted" and "unencrypted.

2) Use MMS instead of SMS where appropriate.

Fixes #1602
2014-06-13 15:24:38 -07:00
phenx-de
a54d20f3ef Add "%s selected" subtitle to Conversation List batch mode. 2014-06-13 09:35:36 -07:00
phenx-de
ea0fa58265 Add preview of encryption channel in compose text hint. 2014-06-12 16:32:31 -07:00
Moxie Marlinspike
359fe280e8 Fix for broken build (*ahem* @phenx-de *ahem*) =)
// FREEBIE
2014-06-12 16:27:51 -07:00
Jake McGinty
34e147838a use apply for preferences instead of commit
// FREEBIE
2014-06-12 14:45:51 -07:00
phenx-de
d8e6a93584 Use contextual action bar menu for conversation items. 2014-06-12 14:27:34 -07:00
phenx-de
5ae8a7a8c4 Improved the warning icon: Higher resolution, better size. 2014-06-12 14:24:08 -07:00
Moxie Marlinspike
0e6773b4b7 Remove directory refresh preference.
This is present on the contact screen now, so there's no longer
any need for it here.
2014-06-12 11:58:24 -07:00
McLoo
fb13d33e2e Show drafts emojified when Android version is below KitKat 2014-06-12 11:30:50 -07:00
Pascal Hartig
92fd8ededd Sort contacts case-insentively
This fixes the case sensitive ordering of contacts in the view
for creating new conversations.

Fix #1502
2014-06-12 10:56:46 -07:00
agrajaghh
8713a85beb Add notification for key change event.
Fixes #1460
2014-06-12 10:40:46 -07:00
Marek Wehmer
9b82411c3d Better share intent handling.
1) Guess mime type from share intent EXTRA_STREAM uri.

2) Always include EXTRA_TEXT (if present)
2014-06-12 10:23:56 -07:00
Jake McGinty
16764f74fe reorganize readme
// FREEBIE
2014-06-12 10:02:18 -07:00
Veeti Paananen
bd889d8fa9 Reword the very confusing screen security setting 2014-06-12 09:22:39 -07:00
Moxie Marlinspike
d51adab76b Use "date sent" as timestamp for push, "date received" for SMS.
The "sent time" is not reliable on SMS messages.  This switches
to using "sent time" by default for push messages, but "received
time" for SMS messages.
2014-06-12 08:59:54 -07:00
Chris V
b990202468 Allow passphrase unlock from "unlock" keyboard action. 2014-06-11 21:45:03 -07:00
Pascal Hartig
7208018097 Clear search when opening the drawer
Before this change opening the drawer while a filter was active
would hide the search bar but keep the conversation list filtered,
so there was no indication of an active filter.
2014-06-11 18:12:07 -07:00
Moxie Marlinspike
c719a48a2c Move media attachment long-click event to context menu.
Long-click on a media attachment will now bring up the normal
context menu for a ConversationItem long-click, but with the
addition of a "save attachment" option.

This allows users to long-click on messages with media in them
and still see the other contextual menu options.

// FREEBIE
2014-06-11 18:04:14 -07:00
Moxie Marlinspike
68747142d6 Add correct contextual menu options on 'Send' button.
[Send TextSecure message | Send unencrypted SMS | Send encrypted SMS]

// FREEBIE
2014-06-11 15:34:01 -07:00
Lukas Barth
7c9282f306 Cache circle cropped photos on Recipient. 2014-06-11 12:33:57 -07:00
Lukas Barth
fa3cb871d0 Use ACTION_OPEN_DOCUMENT for Android >= KitKat.
Fixes #926.

We have to do this, since with the new Storage Access Framework,
otherwise we can open the Uri only *once*. This would work well
unless someone saves a draft and goes back to the conversation -
then the Uri is opened again without the required permissions.

See:

https://developer.android.com/guide/topics/providers/document-provider.html#client

...for details.
2014-06-11 11:58:55 -07:00
Moxie Marlinspike
a19899a11f Merge pull request #1589 from jlund/cyanogen-error-message
Fixing a typo in the WhisperPush error message
2014-06-11 09:20:50 -07:00
Joshua Lund
667da3b2cf Fixing a typo in the WhisperPush error message
// FREEBIE
2014-06-10 20:56:45 -06:00
Moxie Marlinspike
1a86483b7f Merge pull request #1581 from mcginty/android-studio-060
Upgrade android plugin to stay compatible with latest Android Studio
2014-06-10 09:07:59 -07:00
Jake McGinty
de90222c95 Upgrade android plugin to stay compatible with latest Android Studio
// FREEBIE
2014-06-09 23:31:52 -07:00
Moxie Marlinspike
7cf84e904a Merge pull request #1573 from Jabro/master
Added APN Settings for T-Mobile UK
2014-06-09 09:44:50 -07:00
Jabro
12e92b9cdf Added APN Settings for T-Mobile UK
Fixes #1558
2014-06-09 12:43:19 +02:00
Moxie Marlinspike
4153c8dae9 No need to verify a local module.
// FREEBIE
2014-06-06 09:14:43 -07:00
Moxie Marlinspike
ef72702f0d Include gradle-witness plugin for verifying dependencies. 2014-06-05 10:19:28 -07:00
Moxie Marlinspike
f5e2010455 Merge pull request #1554 from thoughtbox/patch-8
Capitalisation according to Android guidelines
2014-06-05 09:06:19 -07:00
thoughtbox
bc769debe2 Capitalisation according to Android guidelines
Not all updated capitalisations were correct.
2014-06-05 09:24:31 +02:00
Moxie Marlinspike
df1c96a662 Do country code detection if we can't get the full number off SIM. 2014-06-03 19:16:27 -07:00
Corbin Souffrant
db356a0ec9 Fixed capitalization inconsistensies with Android guidelines.
Fixes #673
2014-06-03 18:51:21 -07:00
Michael Bennett
468eb3382c Add sorting by default phone number
Currently the order of numbers is times contacted -> displayName ->
phone type (mobile vs. home, etc.). This adds whether the number has
been saved as the default number for a contact to sort numbers belonging
to the same contact.

Fixes #580
2014-06-03 18:18:41 -07:00
Moxie Marlinspike
12d217991c Use dynamic PBE iteration count.
Fixes #184
Fixes #247
2014-06-03 17:59:11 -07:00
Ruben Pollan
5785860631 Support for multiple APN settings on the same provider 2014-06-03 16:24:20 -07:00
Moxie Marlinspike
addea8d340 Validate recipients at send time rather than when constructed.
Fixes #665
2014-06-03 14:58:19 -07:00
Moxie Marlinspike
59899b1caf Merge pull request #1550 from mcginty/email-send-fix
send email addresses as mms
2014-06-03 12:46:08 -07:00
Jake McGinty
829097d891 send email addresses as mms
// FREEBIE
2014-06-03 12:35:56 -07:00
Moxie Marlinspike
d95bb21065 More ideology.
// FREEBIE
2014-06-01 17:05:21 -07:00
Moxie Marlinspike
0fbe765447 Expand ideology.
//FREEBIE
2014-06-01 10:22:31 -07:00
Moxie Marlinspike
f190321e40 Add some ideology to contributing.md
//FREEBIE
2014-05-31 15:05:59 -07:00
Michael Kaiser
1cb4d479f1 Finish activity before restarting it
The current activity needs to be finished before calling startActivity.
Otherwise, activities with launchMode singleTask (ConversationListActivity)
will receive a new Intent instead of getting restarted. And in response
to the new Intent, they will run onResume once again and trigger a second restart.

Fixes #1292
2014-05-20 10:16:48 -07:00
McLoo
023d776e96 Reactivate a group if a contact gets readded
Fixes #723 //FREEBIE

Removes the own number from group on leaving, to receive a proper
re-added message
2014-05-19 13:18:28 -07:00
Jake McGinty
ce7b8ab75a new passphrase prompt activity
// FREEBIE
2014-05-19 12:16:42 -07:00
agrajaghh
82bb0c07e8 Fix AlertDialog Background on Android 2.3 2014-05-16 17:18:57 -07:00
Manuel
d8d5848dae Change draw selector to background 2014-05-16 11:43:47 -07:00
Jake McGinty
542e1984c1 sanely handle duplicate contacts in db
// FREEBIE
2014-05-16 09:16:20 -07:00
Jake McGinty
dff6997a65 don't call replace() on null formattedNumber
Fixes #1397
// FREEBIE
2014-05-16 09:13:50 -07:00
Moxie Marlinspike
5bfe64752e Merge pull request #1495 from mcginty/icon-cached
change out key cached icon to be more unique
2014-05-16 08:30:31 -07:00
Jake McGinty
d6d76fa953 change out key cached icon to be more unique
Fixes #651
// FREEBIE
2014-05-14 17:52:49 -07:00
Sebastian
03ecd79fe0 fix receiving utf-8 characters in multimedia push messages
Throw AssertionError instead of logging and trying to recover
2014-05-01 15:06:44 -07:00
Moxie Marlinspike
7a3d509ef4 Merge pull request #1437 from mcginty/mms-npe
prevent NPE in MMS logic
2014-05-01 13:05:01 -07:00
Jake McGinty
7a54f33f68 Merge pull request #1354 from agrajaghh/fix_empty_contact_filter
Fix empty contact filter not working properly
2014-05-01 14:18:25 -05:00
Jake McGinty
d4b4667d5a prevent NPE in MMS logic
Fixes #1434
// FREEBIE
2014-04-28 14:05:05 -07:00
thoughtbox
08d899e2e1 Slightly more verbose "no legacy support" message. 2014-04-28 11:02:48 -07:00
Jake McGinty
716519f4b8 Merge pull request #1383 from jocelynthode/master
Add time to messages when they are within the week
2014-04-27 19:19:49 -07:00
Moxie Marlinspike
02d3760b31 Merge pull request #1368 from mcginty/contact-select-header-dark
fix contact selection header theming
2014-04-24 18:47:13 -07:00
Jocelyn Thode
521fbc77c6 Add time to messages when they are within the week
//FREEBIE
2014-04-17 16:10:27 +02:00
Moxie Marlinspike
0574ec170a Display legacy message error when V1 message is received. 2014-04-16 11:47:51 -07:00
Moxie Marlinspike
cebad39422 Collapse some v2 interfaces now that there's no v1. 2014-04-16 11:47:51 -07:00
Moxie Marlinspike
1d07ca3e6f Remove V1 code. 2014-04-16 11:47:51 -07:00
Moxie Marlinspike
ca8c950553 Bump version to 2.0.8
// FREEBIE
2014-04-15 15:59:47 -07:00
Jake McGinty
7349378d8d fix contact selection header theming
Fixes #1343
// FREEBIE
2014-04-14 17:43:13 -07:00
Moxie Marlinspike
dc9a9b14b2 Merge pull request #1367 from mcginty/routing-undo
revert RoutingActivity flags
2014-04-14 15:02:42 -07:00
Jake McGinty
df9afc4e7f revert RoutingActivity flags
// FREEBIE
2014-04-14 14:49:15 -07:00
agrajaghh
e9a50ce6c3 fix empty contact filter 2014-04-13 15:00:04 +02:00
Moxie Marlinspike
4d52d2ee36 Bumping version to 2.0.7 2014-04-11 10:58:39 -07:00
Moxie Marlinspike
c21e5b74f1 Updated language translations. 2014-04-11 10:13:23 -07:00
Moxie Marlinspike
c5b3b27c49 Merge pull request #1339 from mcginty/broken-build
fix old code breaking build
2014-04-11 10:13:05 -07:00
Jake McGinty
ccb0cc6baf fix old code breaking build
// FREEBIE
2014-04-11 10:00:30 -07:00
Moxie Marlinspike
ef77dc9d6d Merge pull request #1324 from mcginty/actionbar-cleanup
use normal means to set actionbar icon
2014-04-10 17:57:53 -07:00
Jake McGinty
454673cd0c Update ActionBar title on language change
Fixes #1329
// FREEBIE
2014-04-10 17:55:03 -07:00
Jake McGinty
0dc6ec294b use normal means to set actionbar icon
// FREEBIE
2014-04-10 17:52:58 -07:00
Santoso Wijaya
12dac6ccc3 ShareActivity, destruction of RecipientsPanel
// FREEBIE
2014-04-10 13:16:14 -07:00
Jake McGinty
e2f7c1529a group and contact list fixes
1) Updating a group without changing the avatar will keep that
   avatar

2) Prohibit adding non-push users to an existing push group

3) Add Android contacts to the same database. Takes a small amount
   more time and memory, but allows queries to not be a hack, and
   enables us to dedupe numbers in JB and higher devices.

// FREEBIE
2014-04-10 11:14:06 -07:00
Jake McGinty
b715debefc mark auto-fallback to sms as forcedSms
// FREEBIE
2014-04-10 10:50:35 -07:00
Moxie Marlinspike
4438b4ae69 Add a TrustManager that blacklists via serial numbers. 2014-04-09 20:50:32 -07:00
Jake McGinty
7b3f2c169a Fix issue with weird exiting animation from conversation
Fixes #1312
// FREEBIE
2014-04-08 10:57:17 -07:00
Matt Enright
7ceaf59bcc Display send date for incoming messages
Fixes #597.
2014-04-05 14:39:58 -07:00
Moxie Marlinspike
4caff2e511 Merge pull request #1297 from McLoo/master
Stop recycled bitmap crashes
2014-04-05 13:38:45 -07:00
McLoo
5e8e13ed5a Stop recycled bitmap crashes
Fixes #792
2014-04-04 23:49:12 +02:00
Moxie Marlinspike
4ea481f9dc Bumping version to 2.0.6
// FREEBIE
2014-04-04 09:27:05 -07:00
Moxie Marlinspike
e94fa0d752 Updated language translations.
// FREEBIE
2014-04-03 16:02:36 -07:00
Moxie Marlinspike
817070e76f Merge pull request #1288 from mcginty/send-icons-redux-redux
remove lock coloring in send icons
2014-04-03 15:11:33 -07:00
Jake McGinty
92b90cd798 remove lock coloring in send icons
// FREEBIE
2014-04-03 14:05:34 -07:00
Moxie Marlinspike
33ecc4d690 Add null check. // FREEBIE 2014-04-03 14:01:15 -07:00
Jake McGinty
7d5e66eb6e fix send icon merge botch, encryption icons logic
// FREEBIE
2014-04-03 12:12:59 -07:00
Moxie Marlinspike
d4ac0c077d Merge pull request #1248 from mcginty/wrong-group-secure
outgoing group MMS should not be encrypted and considered push
2014-04-03 11:22:00 -07:00
Jake McGinty
cbe87aa05c outgoing group MMS should never be encrypted
// FREEBIE
2014-04-03 11:21:13 -07:00
Moxie Marlinspike
9e2f82954f Merge pull request #1260 from mcginty/message-layout-lint
Conversation item tweaks
2014-04-03 10:07:23 -07:00
Jake McGinty
d4d684b670 simplified layouts 2014-04-03 09:59:32 -07:00
Moxie Marlinspike
c43ef8bce0 Merge pull request #1233 from mcginty/send-icons
new send icons, fix logic for disabling/enabling the button
2014-04-03 09:58:10 -07:00
Jake McGinty
54a882a11d new send icons, fix logic for disabling/enabling
// FREEBIE
2014-04-03 09:49:50 -07:00
Moxie Marlinspike
73e2f6ce59 Merge pull request #1272 from mcginty/flag-secure
hide screen security when unsupported
2014-04-02 22:14:08 -07:00
Moxie Marlinspike
54d2184c72 Merge pull request #1205 from mcginty/contact-select
refactor and improve contact selection
2014-04-02 22:11:44 -07:00
Jake McGinty
832763f695 UX for unencrypted fallback case 2014-04-02 22:10:51 -07:00
Moxie Marlinspike
40629a3bcf Fix decryption corner case when passphrase is disabled. 2014-04-02 22:10:51 -07:00
Moxie Marlinspike
5a3daf4846 Curve25519 keys to 1 mod 8 for ephemerals. 2014-04-02 22:10:51 -07:00
Moxie Marlinspike
fd1a18d2d0 Don't display duplicate push messages. 2014-04-02 22:10:50 -07:00
Moxie Marlinspike
ad5d6d5bb7 Add refresh path for PreKey queue. 2014-04-02 22:10:50 -07:00
Moxie Marlinspike
926d3c929f Handle simultaneous initiate protocol case.
1) Modify SessionRecord to store a list of "previous" sessions
   in addition to the current active session.  Previous sessions
   can be used for receiving messages, but not for sending
   messages.

2) When a possible "simultaneous initiate" is detected, push the
   current session onto the "previous session" stack instead of
   clearing it and starting over.

3) Additionally, mark the new session created on a received
   possible "simultaneous initiate" as stale for sending.  The
   next outgoing message would trigger a full prekey refresh.

4) Work to do: outgoing messages on the SMS transport should
   probably not use the existing session if it's marked stale
   for sending.  These messages need to fail and notify the user,
   similar to how we'll handle SMS fallback to push users before
   a prekey session is created.
2014-04-02 22:10:50 -07:00
Moxie Marlinspike
edc20883eb Merge pull request #1281 from thoughtbox/patch-6
Changed MMS Proxy setting for 24201 (Telenor)
2014-04-02 09:14:32 -07:00
thoughtbox
0d7363e36e Changed MMS Proxy setting for 24201 (Telenor)
Going forward, Telenor will be using FQDN.
2014-04-02 12:47:05 +02:00
Jake McGinty
ca6d8a8a0d refactor and improve contact selection
* unify single and multi contact selection activities
* follow android listview design recommendations more closely
* add contact photos to selection
* change indicator for push to be more obvious
* cache circle-cropped bitmaps
* dedupe numbers when contact has multiple of same phone number

// FREEBIE
2014-04-01 14:56:45 -07:00
Moxie Marlinspike
c414334059 Merge pull request #1228 from backspace/support-commas-in-contact-names
Remove commas in names in recipient list string
2014-03-31 08:39:15 -07:00
Moxie Marlinspike
24a38985cf Merge pull request #1249 from mcginty/convo-scroll
scroll to the new message in conversation
2014-03-31 08:14:26 -07:00
Brian Conway
60f2d4d6b6 Add APN for Aio wireless (USA).
Source: http://www.aiowireless.com/support/Apps-and-Services/Bring-Your-Own-Device-BYOD/customer/Bring-Your-Own-Android.html
2014-03-31 08:09:10 -07:00
Jake McGinty
06659fd98f hide screen security when unsupported
// FREEBIE
2014-03-30 02:28:38 -07:00
Jake McGinty
3c9c5213a7 Merge pull request #946 from DorianScholz/groupavatar
Use standard intent to select group avatar.
2014-03-28 12:07:30 -07:00
Dorian Scholz
a183f8d387 Fix #641 by using standard intent to select group avatar.
The ACTION_GET_CONTENT used with cropping is not supported on all devices.
To make this work more reliably I removed the cropping and MediaStore.EXTRA_OUTPUT.
The image is now read via getContentResolver().openInputStream() which should work on all device including KitKat/CM11.
2014-03-27 12:44:56 +01:00
Jake McGinty
216446c55b scroll to the new message in conversation
// FREEBIE
2014-03-26 15:12:01 -07:00
Buck Doyle
bc143059f6 Remove separators from names in recipient list
Fixes #1225 and #1174
2014-03-25 11:11:20 -07:00
Jake McGinty
33000582ed one more try at that one..
// FREEBIE
2014-03-25 03:31:44 -07:00
Jake McGinty
e651f352bb fix NPE in isPushDestination
// FREEBIE
2014-03-24 17:02:39 -07:00
Buck Doyle
cab4a06974 Remove commas in names in recipient list string
Fixes #1225
2014-03-23 15:02:21 -07:00
martinstingl
ccc1f5e9d6 Added the dependency "Android SDK Build-tools".
//FREEBIE
2014-03-20 18:06:58 -07:00
Moxie Marlinspike
b860aeff85 Minor ConversationList scrolling optimization. 2014-03-16 14:36:21 -07:00
Martin Ranta
34c885f08d Fixed a few localization names. 2014-03-16 10:06:26 -07:00
Moxie Marlinspike
71ab6f5c7d Merge pull request #1178 from backspace/extract-input-settings-string
Extract Input Settings preference header string.
2014-03-16 10:02:59 -07:00
Buck Doyle
61fbf382eb Extract Input Settings preference header string.
Fixes #1159

FREEBIE
2014-03-15 22:18:14 -04:00
Moxie Marlinspike
8b21f3f7d6 Bump version to 2.0.5 2014-03-14 10:18:13 -07:00
Moxie Marlinspike
941d0089f4 Add languages to selector 2014-03-14 09:40:58 -07:00
Moxie Marlinspike
8b8c6dd45f Updated translations
//FREEBIE
2014-03-14 09:40:43 -07:00
Jake McGinty
938545444e Merge pull request #984 from mcginty/sms-prefs
more precise sms controls
2014-03-13 21:03:02 -07:00
Jake McGinty
d827ab1b36 more precise sms controls
// FREEBIE
2014-03-13 20:59:20 -07:00
Jake McGinty
4701e59197 Merge pull request #1076 from phenx-de/fix-big-fontsize
Fix conversation list view for larger text sizes.
2014-03-13 13:05:56 -07:00
Moxie Marlinspike
2b2da84918 Merge pull request #1140 from psm14/bugs/group_mms_local_number
Also check cc for duplicates in group MMS
2014-03-12 18:58:08 -07:00
Pat McLaughlin
d229a4274c Also check cc for duplicates 2014-03-12 20:49:55 -04:00
3xo
64711771f0 Fix locale when using country codes. 2014-03-12 16:56:24 -07:00
Moxie Marlinspike
ad54d2a05f Modify string tag.
//FREEBIE
2014-03-12 09:57:32 -07:00
Wikinaut
068c40336c added Google Play Store text 2014-03-11 14:18:23 -07:00
Jake McGinty
11cfc4f1a1 upgrade gradle version
// FREEBIE
2014-03-11 01:05:24 -07:00
phenx-de
f51989b23e Fix conversation list view for larger text sizes. 2014-03-10 10:32:32 +01:00
Moxie Marlinspike
0b4fe84a41 Format-neutral compare numbers in MMS group with local device.
Closes #1018
2014-03-07 13:05:35 -08:00
Moxie Marlinspike
b855a1805f Mark message details on pending messages as such.
Closes #1034
2014-03-07 12:39:16 -08:00
3xo
339193af12 Give user the opportunity to chose no LED-notification. 2014-03-07 12:04:19 -08:00
Jake McGinty
574f33c92d Merge pull request #1069 from phenx-de/color-cleanup
Moved colors to the right place.
2014-03-07 12:00:49 -08:00
Manuel
b6a9eb5bf2 Closes #913: Message ID is -1 when called in aggregate 2014-03-07 11:59:53 -08:00
phenx-de
54b43b7536 Moved colors to the right place. 2014-03-07 11:03:22 +01:00
Moxie Marlinspike
37c9fb7cd1 Merge pull request #1053 from shenki/master
ConversationFragment: enable back button to dismiss message detail dialog
2014-03-06 20:46:43 -08:00
Joel Stanley
667d22bace ConversationFragment: enable back button to dismiss
The ConversationFragment has a AlertDialog for showing the message
details, which sets the cancelable property to be false. This stops the
user from being able to use the back button to dismiss the dialog.
2014-03-06 15:32:51 +10:30
Moxie Marlinspike
3d782449ed Merge pull request #1025 from DorianScholz/sharetextplain
Only receive text/plain.
2014-03-05 09:50:57 -08:00
Moxie Marlinspike
003095b08c Merge pull request #1020 from lxgr/fix-screensec
Use the "screen security" preference for the conversation list
2014-03-05 09:12:33 -08:00
Jake McGinty
d121d9531e Merge pull request #992 from veeti/overdraw
Fix overdraw issues in the conversation view
2014-03-05 00:10:06 -08:00
Veeti Paananen
42aeca26f1 Fix overdraw issues in the conversation view
Remove the redundant window background and row backgrounds to improve
drawing performance.
2014-03-05 08:03:55 +02:00
Dorian Scholz
ea8a1bae46 Only receive text/plain.
At the moment only text/plain is handled in RoutingActivity, so set filter in manifest accordingly.
This prevents #316. But at some point sharing text/calendar or better */* would be nice...

// FREEBIE
2014-03-04 23:57:36 +01:00
Jake McGinty
054fcdca8d Merge pull request #1007 from SamWhited/issue998
s/Verify Recipient/Verify Identity/
2014-03-04 13:49:49 -08:00
Lukas Ribisch
278220cf18 Use the "screen security" preference for the conversation list
It was previously only used for ConversationListActivity. This should be all
the locations (according to a grep for FLAG_SECURE).

FREEBIE
2014-03-04 21:04:04 +01:00
Chris Glass
35eeaa9bd5 Added more build information to BUILDING.md
Added more instructions about setting up a development environment.
2014-03-04 08:44:54 -08:00
Moxie Marlinspike
fbf02603ce Bump version to 2.0.4 2014-03-04 08:39:31 -08:00
Sam Whited
fa423e4432 s/Verify Recipient/Verify Identity/ 2014-03-04 09:55:45 -05:00
Moxie Marlinspike
5caec4a146 Updated language translations. 2014-03-03 19:13:38 -08:00
Moxie Marlinspike
dc77c43435 Merge pull request #796 from mcginty/pending_messages
pending messages more accurately conveyed to user
2014-03-03 18:49:48 -08:00
Jake McGinty
827298d1a2 Merge pull request #975 from tinloaf/reloadcontactlist
Reload contact list after directory refresh // FREEBIE
2014-03-03 18:01:10 -08:00
Lukas Barth
48f5b932f7 Reload contact list after directory refresh // FREEBIE
I forgot that in my PR, it seems.
2014-03-03 21:18:38 +01:00
Jake McGinty
90169e9468 pending messages more accurately conveyed to user 2014-03-03 11:56:54 -08:00
Moxie Marlinspike
b5fe378bc9 Workaround for Android bug when swiped from recent tasks list.
Closes #168

https://code.google.com/p/android/issues/detail?id=53313
2014-03-03 11:45:05 -08:00
Moxie Marlinspike
0f53c9d170 Merge pull request #966 from backspace/add-video-sharing
Support videos from other apps. Fixes #949
2014-03-03 11:01:02 -08:00
Moxie Marlinspike
3474950830 Merge pull request #956 from tinloaf/refreshfromlist
Add possiblity to refresh the push directory directly from contact list
2014-03-03 10:09:32 -08:00
Lukas Barth
39ee363150 Add possiblity to refresh the push directory directly from the contact picking list. Fixes #835. Fixes #859.
Thanks benalbrecht for the icons.
2014-03-03 18:23:14 +01:00
Buck Doyle
411e3ceff6 Support videos from other apps. Fixes #949 2014-03-03 11:55:34 -05:00
Moxie Marlinspike
b7f8c3b3d3 Merge pull request #961 from cloudkicker/notification_preferences
Make notification preferences look normally
2014-03-03 08:53:00 -08:00
Moxie Marlinspike
3efa8e6899 Merge pull request #955 from benalbrecht/nocount
Use new icon from #905 for push message disable confirmation box
2014-03-03 08:33:10 -08:00
Vladislav Meshochkin
948f481530 Make notification preferences look normally 2014-03-03 19:22:51 +04:00
Benjamin Albrecht
716fdefa4c Use icon from #905 for push message disable confirmation box
//FREEBIE
2014-03-03 11:44:14 +01:00
Moxie Marlinspike
2dc893730a Auto-update every 12 hours instead.
// FREEBIE
2014-03-02 16:19:05 -08:00
Moxie Marlinspike
1af99ce155 Fix for periodic directory refresh.
// FREEBIE
2014-03-02 16:14:00 -08:00
Moxie Marlinspike
0850f1b0f1 Add libcurve25519 bins.
// FREEBIE
2014-03-02 16:06:37 -08:00
Florian Walch
1ddc45fd9c Build native code for multiple architectures.
* Include native libs without requiring intermediate .jar.
 * Fix build warnings; use latest build tools.
2014-03-02 16:06:37 -08:00
Moxie Marlinspike
977765c80f Merge pull request #941 from Wikinaut/add-new-string-ViewIdentityActivity_my_identity_fingerprint
add new string ViewIdentityActivity_my_identity_fingerprint
2014-03-02 15:50:18 -08:00
Thomas Gries
4b2d07ab35 add new string ViewIdentityActivity_my_identity_fingerprint 2014-03-03 00:45:42 +01:00
Jens Füllenbach
003ebe6364 Added the color white to the notification colors of the LED. 2014-03-02 14:11:31 -08:00
Benjamin Albrecht
2f7c005c23 Show confirmation box before disabling push messages 2014-03-02 14:09:54 -08:00
Moxie Marlinspike
367b481d07 Merge pull request #905 from benalbrecht/dialog_icons
Use modern icons in info and alert dialogs for ICS+
2014-03-02 14:01:52 -08:00
Moxie Marlinspike
5cd8c922d2 Merge pull request #648 from veeti/tweaks-and-polish
Assorted tweaks and polish
2014-03-02 14:01:20 -08:00
Moxie Marlinspike
a2fe8a9d5c Make default group avatar icon actually work. 2014-03-02 13:22:02 -08:00
Benedict Pregler
ee921a8f49 fixed some hardcoded strings 2014-03-02 13:22:02 -08:00
Benedict Pregler
e0394b4481 a little typo mistake 2014-03-02 13:22:02 -08:00
Veeti Paananen
de100f5be7 Add missing spaces 2014-03-02 09:40:45 +02:00
Veeti Paananen
a020a57be6 End conversation selection action mode if all deselected
This seems to be common convention in most apps.
2014-03-02 09:40:35 +02:00
Veeti Paananen
28f1a0a636 Replace the attachment dialog header icon with something modern 2014-03-02 09:40:35 +02:00
Veeti Paananen
5a807ffc28 Use unified touch highlight in import & export 2014-03-02 09:40:35 +02:00
Veeti Paananen
757cb1c846 Add touch highlight to contact photos 2014-03-02 09:40:35 +02:00
Veeti Paananen
4f066757e7 Use the touch highlight background for the emoji toggle 2014-03-02 09:40:35 +02:00
Veeti Paananen
633aa9b057 Fix the send button's touch highlight color
Introduce a generic touch highlight background drawable, and use the
proper shades of blue (and gray on v19+).
2014-03-02 09:40:35 +02:00
Jake McGinty
a5c26b2e16 Merge pull request #921 from liliakai/master
Add contributing.md // FREEBIE
2014-03-01 15:19:32 -08:00
lilia
ca561d76ff Add contributing.md // FREEBIE
This file is recognized by github and presented to users who are trying
to open issues and submit pull requests.

Hopefully this more prominent placement will help deter people from
opening issues/prs for translation fixes.
2014-03-01 15:11:21 -08:00
Jake McGinty
107d999ee7 make bithub price update // FREEBIE
thanks lilia
2014-03-01 11:57:46 -08:00
Benjamin Albrecht
0f6c7660cb Use modern icons in info and alert dialogs for ICS+ 2014-03-01 14:42:12 +01:00
Moxie Marlinspike
8ea4db03db Better support for local storage with passphrase disabled.
1) Never get into a state where messages aren't displayed
   unencrypted.

2) Fix bug where locked DB required launching twice.
2014-02-28 15:58:30 -08:00
Moxie Marlinspike
81ee9e31c5 Update behavior for incoming SMS path.
1) On KitKat, unencrypted SMS messages are never stored in
   TextSecure unless it is set as the system-wide default.

2) On KitKat, if TextSecure is set as the system-wide default,
   provide an option to change the default to a different app.

3) Don't store the TextSecure challenge on KitKat+ devices.
2014-02-28 13:40:35 -08:00
Moxie Marlinspike
a3e900ecbe Merge pull request #794 from SamWhited/issue788
Add option to disable screen security
2014-02-27 18:02:05 -08:00
Sam Whited
384fb3b2b5 Add option to disable screen security
See WhisperSystems/TextSecure#788
2014-02-27 19:00:39 -05:00
Moxie Marlinspike
d795aa30b3 Merge pull request #795 from benalbrecht/nocount
Don't show letter count when SMS mode is disabled
2014-02-27 14:12:27 -08:00
Jake McGinty
bac4d63312 Merge pull request #805 from wickedshimmy/fix-sender-details
Don't display sender in outgoing message details
2014-02-27 11:18:51 -08:00
Benjamin Albrecht
bf60f90019 Don't show letter count inside a push group or when SMS mode is disabled 2014-02-27 09:32:19 +01:00
Matt Enright
852ca2ac05 Don't display sender in outgoing message details
Because we don't know it. Fixes WhisperSystems#711.
2014-02-26 21:57:17 -05:00
Moxie Marlinspike
038bebfdbb Bump version to 2.0.3 // FREEBIE 2014-02-26 13:08:03 -08:00
Moxie Marlinspike
3b25b87aa8 Fix for NPE 2014-02-26 12:42:16 -08:00
Moxie Marlinspike
5a62856e46 Make SMS delivery reports optional. 2014-02-26 12:38:50 -08:00
Moxie Marlinspike
37a52df4e6 Fix bug that broke notifications for group messages. 2014-02-26 12:31:56 -08:00
Jake McGinty
d3148b6766 Merge pull request #764 from m0jo/master
Fix hpyerlinking recieved/sent date in messages
2014-02-26 09:46:42 -08:00
Tim Bücher
6fb85aff6d Fix hpyerlinking recieved/sent date in messages 2014-02-26 13:43:55 +01:00
Moxie Marlinspike
ed45067227 Bumping version to 2.0.2 // FREEBIE 2014-02-26 00:01:52 -08:00
Jake McGinty
0015711759 migrate logcat submit to preferences
// FREEBIE
2014-02-25 23:11:00 -08:00
Moxie Marlinspike
15390e477e Update translations.
// FREEBIE
2014-02-25 22:47:03 -08:00
Jake McGinty
a8c23413ba Merge pull request #745 from mcginty/logcat_submit
activity to submit logcat to pastebin
2014-02-25 22:20:34 -08:00
Jake McGinty
ce68429a9b activity to submit logcat to pastebin 2014-02-25 22:14:21 -08:00
Jake McGinty
1a9a88a5a1 Merge pull request #744 from backspace/change-sent-link-color
Make outgoing links readable
2014-02-25 21:23:41 -08:00
Moxie Marlinspike
7987362c25 Fix for bug where messages are stuck in pending state after upgrade. 2014-02-25 20:57:18 -08:00
Buck Doyle
5d42110d6c Make outgoing links readable 2014-02-25 22:46:49 -05:00
Moxie Marlinspike
dec7fd4c8a Fix for NPE with audio attachments. 2014-02-25 17:54:49 -08:00
Moxie Marlinspike
82df23dd41 Temporarily bring back end session. 2014-02-25 17:38:55 -08:00
Moxie Marlinspike
ce710b378f Fix for stalled retries. 2014-02-25 17:15:30 -08:00
Moxie Marlinspike
20fd881613 Display error code from server when already registered elsewhere. 2014-02-25 17:00:31 -08:00
Jake McGinty
5fa429b0d5 Merge pull request #676 from mcginty/emoji_density
Fix emoji density scaling issues
2014-02-25 16:28:43 -08:00
Jake McGinty
630dce04fc handle emoji density scaling more correctly 2014-02-25 16:24:33 -08:00
Moxie Marlinspike
0da1d8818e Merge pull request #729 from funk78/feature/use_getDeviceE164Number
FREEBIE reuse code
2014-02-25 15:15:26 -08:00
droidastic
c84285c639 FREEBIE reuse code 2014-02-25 23:56:18 +01:00
Moxie Marlinspike
5a525a2e58 Switch KCS priority to MIN on JB+. Eliminates icon in status bar! 2014-02-25 10:33:11 -08:00
Moxie Marlinspike
dda8a214a4 Merge pull request #668 from m0jo/master
Fix missing localozation strings for custom LED blink pattern.
2014-02-25 08:37:38 -08:00
Tim Bücher
bd167cbb17 Fix missing localozation strings for custom LED blink pattern. 2014-02-25 11:38:31 +01:00
Jake McGinty
a0aaa7d724 Explain why SMS fallback is disabled when it is 2014-02-25 01:23:22 -08:00
Moxie Marlinspike
25e03b3579 Bumping version to 2.0.1 2014-02-24 21:50:33 -08:00
Moxie Marlinspike
52ff4ecfd2 Fix to make emoji work in push groups. 2014-02-24 17:01:28 -08:00
Moxie Marlinspike
43c1576aab Fix for bad database migration. 2014-02-24 17:00:52 -08:00
Jake McGinty
23c607430d fix dark text input on dark background for conversation
// FREEBIE
2014-02-24 16:12:13 -08:00
Jake McGinty
829a92d371 contact selection reactive to dark theme
// FREEBIE
2014-02-24 14:43:38 -08:00
Moxie Marlinspike
559228af5b Fix for bug modifying immutable list. 2014-02-24 14:19:43 -08:00
Moxie Marlinspike
e8a0fac05b Fix for identity key mismatch on devices with V1 identities. 2014-02-24 14:19:17 -08:00
Moxie Marlinspike
7bb45d8a91 Bump version to 2.0 2014-02-24 08:58:33 -08:00
Moxie Marlinspike
fa0c783c64 Update language translations. 2014-02-24 02:17:15 -08:00
Moxie Marlinspike
377a332789 Tone down logging a bit. 2014-02-24 02:12:41 -08:00
Moxie Marlinspike
2ab8c77748 Correctly update group title. 2014-02-24 00:37:11 -08:00
Moxie Marlinspike
d5f0415907 Merge branch 'master' of github.com:WhisperSystems/TextSecure
Conflicts:
	src/org/thoughtcrime/securesms/GroupCreateActivity.java
	src/org/thoughtcrime/securesms/database/GroupDatabase.java
2014-02-24 00:23:40 -08:00
Moxie Marlinspike
5000957b99 Listen for group updates, fix group updates, and Recipient marshing 2014-02-24 00:19:54 -08:00
Jake McGinty
fc12f2cf8e disable subtitle for push groups
// FREEBIE
2014-02-23 23:59:13 -08:00
Jake McGinty
e3aed66ded avatar was getting nulled with any update, no more "unsetting"
// FREEBIE
2014-02-23 23:35:46 -08:00
Jake McGinty
f30304423d lose SD card dependency, fix NPEs
// FREEBIE
2014-02-23 23:35:41 -08:00
Jake McGinty
86b3de2a93 group updates do things
// FREEBIE
2014-02-23 21:18:08 -08:00
Jake McGinty
0ae1004142 Merge pull request #603 from WhisperSystems/idempotent_backgrounds
Fix bug with recycled ListItems.
2014-02-23 17:32:47 -08:00
Moxie Marlinspike
da344a0218 Fix bug with recycled ListItems. 2014-02-23 17:11:10 -08:00
Jake McGinty
aab34e491e fix bug where sdk < kitkat is unjustly punished 2014-02-23 16:04:09 -08:00
Moxie Marlinspike
e80de7de2b Fix bug where adding attachment duplicates recipient count. 2014-02-23 15:58:24 -08:00
Jake McGinty
3dd27ed59a push conversation messages are now blue
// FREEBIE
2014-02-23 15:29:07 -08:00
Moxie Marlinspike
ca2eecaedf Add advanced preference for refreshing push directory. 2014-02-23 15:12:40 -08:00
Moxie Marlinspike
e188f62d70 Shunt BCC messages directly to MMS transport. 2014-02-23 14:39:07 -08:00
Moxie Marlinspike
8093b14922 Be sure we don't let MMS out if the transport is disabled. 2014-02-23 14:38:41 -08:00
Moxie Marlinspike
636c50b3b8 Fix for creating non-push groups. 2014-02-23 14:38:03 -08:00
Moxie Marlinspike
9298dded15 Only disable inactive *push* group conversations. 2014-02-23 14:37:41 -08:00
Moxie Marlinspike
c36b5869fc Tweak create passphrase screen text. 2014-02-23 14:37:05 -08:00
Jake McGinty
46de25d658 conversation lock icon for dark theme
// FREEBIE
2014-02-22 22:22:39 -08:00
Jake McGinty
8794661433 fix "end session" inflation
// FREEBIE
2014-02-22 22:22:39 -08:00
Moxie Marlinspike
056dbd1a4e tweak text
//FREEBIE
2014-02-22 14:42:02 -08:00
Moxie Marlinspike
125a60290f Correctly handle key conflict resolution for incoming push. 2014-02-22 14:22:12 -08:00
Moxie Marlinspike
315cf2d8e4 Eliminate concept of group 'owner'. 2014-02-22 11:29:28 -08:00
Moxie Marlinspike
da57a689c1 Fill in some strings.
// FREEBIE
2014-02-22 11:10:30 -08:00
Moxie Marlinspike
9c9866e7ee Add 'leave group' functionality. Includes other bug fixes. 2014-02-22 10:54:43 -08:00
Moxie Marlinspike
a6e1d56cde Refactor group messaging protocol.
// FREEBIE
2014-02-21 17:51:52 -08:00
Jake McGinty
b855f8a163 fix single contact selection for contacts with multiple phones
// FREEBIE
2014-02-21 17:12:08 -08:00
Jake McGinty
7beab36c6a updates to conversation menu, and updating of group info
// FREEBIE
2014-02-21 11:33:31 -08:00
Jake McGinty
7667264789 add group photo placeholder assets (not currently used)
// FREEBIE
2014-02-20 23:09:28 -08:00
Moxie Marlinspike
ccd1691b22 Make 'push' status a type bit on both incoming and outgoing msgs. 2014-02-20 23:00:38 -08:00
Moxie Marlinspike
2026330f8a Remove dead code. 2014-02-20 18:27:43 -08:00
Moxie Marlinspike
3ca25de034 Fix for MMS decoding when no SIM is available. 2014-02-20 17:32:01 -08:00
Moxie Marlinspike
ff238a1ce9 Indicate a message was delivered via push in its delivery status. 2014-02-20 16:14:58 -08:00
Moxie Marlinspike
918f223149 Add preference to disable the SMS channel all together.
1) If the SMS fallback preference is disabled, no outgoing
   messages will succeed via the SMS transport.

2) If the SMS fallback preference is disabled, "mirroring" the
   SMS db state when not the default system SMS app is disabled.
2014-02-20 14:49:31 -08:00
Moxie Marlinspike
c5821f770a Don't prompt for auto-initiate if push registered (or active V2). 2014-02-20 12:55:02 -08:00
Moxie Marlinspike
5b22a7bdcb Create Curve25519 identities in the next release. 2014-02-20 12:46:51 -08:00
Moxie Marlinspike
2a74dc8d82 Update the conversation UI after aborting a V1 session. 2014-02-20 12:06:11 -08:00
Moxie Marlinspike
145e4335fc Only send round-trip key exchanges over SMS. 2014-02-20 12:06:11 -08:00
Moxie Marlinspike
1d4d9663db Fix for NPE 2014-02-20 12:06:11 -08:00
Jake McGinty
a0cbbd2d21 confirm session abort handler in ConversationItem
// FREEBIE
2014-02-20 11:42:15 -08:00
Jake McGinty
28b96204a9 make the menu titles a little less incorrect
// FREEBIE
2014-02-19 21:55:40 -08:00
Jake McGinty
c647820fb7 new default contact picture
// FREEBIE
2014-02-19 21:54:12 -08:00
Moxie Marlinspike
9614dc9055 Refactor group database model and flow.
1) Use existing DB types instead of adding new columns.

2) Store group attributes in message body, like everything else.
2014-02-19 21:07:47 -08:00
Jake McGinty
0cdc6fd87d embrace the darkness, don't open quickcontact for groups
// FREEBIE
2014-02-19 15:01:10 -08:00
Moxie Marlinspike
19dddd7adf Support for an 'end session' protocol message.
1) On the push side, this message is a flag in PushMessageContent.
   Any secure message with that flag will terminate the current
   sessin.

2) On the SMS side, there is an "end session" wire type and
   the convention that a message with this wire type must be
   secure and contain the string "TERMINATE."
2014-02-19 13:50:32 -08:00
Jake McGinty
0688dd0c2c repurpose ImageDivet for avatar, minor lint, fix bitmap decoding
// FREEBIE
2014-02-19 00:01:37 -08:00
Jake McGinty
649f037ed8 apply same fix used on DecryptingPartInputStream to AttachmentCipherInputStream // FREEBIE 2014-02-18 16:42:44 -08:00
Jake McGinty
9d9a0ec218 collection of fixes based on comments/small aesthetic stuff // FREEBIE 2014-02-18 16:42:44 -08:00
Jake McGinty
d19ab04bdd gradle wrapper 1.10, android plugin 0.8, android support 19.0.1 //
FREEBIE
2014-02-18 16:42:40 -08:00
Jake McGinty
e05bacd8c3 fixing avatar selection when some gallery apps won't return any extras
but still succeed // FREEBIE
2014-02-18 16:42:33 -08:00
Moxie Marlinspike
760c96171d Merge branch 'master' into groups 2014-02-18 13:53:35 -08:00
Moxie Marlinspike
3999171377 Introduce registration-time ID for detecting stale sessions.
1) At registration time, a client generates a random ID and
   transmits to the the server.

2) The server provides that registration ID to any client
   that requests a prekey.

3) Clients include that registration ID in any
   PreKeyWhisperMessage.

4) Clients include that registration ID in their sendMessage
   API call to the server.

5) The server verifies that the registration ID included in
   an API call is the same as the current registration ID
   for the destination device.  Otherwise, it notifies the
   sender that their session is stale.
2014-02-18 12:51:23 -08:00
Jake McGinty
abce678cb4 received group messages aren't processed as "meta" group stuff, oops. 2014-02-17 22:20:43 -08:00
Jake McGinty
fb75d90edc fix bug where it opened wrong thread for TS group creates 2014-02-17 22:04:08 -08:00
Jake McGinty
25324a45b3 Show something for unnamed groups, allow us to have different default photos for groups vs. individuals 2014-02-17 21:42:30 -08:00
Jake McGinty
877ed8f59c Show TS group titles properly, hide MMS options 2014-02-17 20:25:40 -08:00
Jake McGinty
54b087c458 MMS should open conversation also 2014-02-17 20:19:54 -08:00
Jake McGinty
ca51ddac7f re-privatize getRecipientForNumber 2014-02-17 20:19:35 -08:00
Jake McGinty
e15ff6193f unbreak group insertion for new installs 2014-02-17 20:10:37 -08:00
Jake McGinty
e8251800ab gb icon for new group changed 2014-02-17 18:17:23 -08:00
Jake McGinty
93329df530 avatar selection on gb fixed, disable push groups if not push registered 2014-02-17 17:33:20 -08:00
Jake McGinty
948f888670 group ui task refactor, small bug fixes 2014-02-17 16:36:31 -08:00
Jake McGinty
c19ac8ec1e less hacky way of converting ContactData to Recipients 2014-02-17 16:23:29 -08:00
Jake McGinty
04327e9ed7 refresh conversation fragment to new thread when created 2014-02-17 15:48:09 -08:00
Jake McGinty
e81526e581 error messaging for group creation issues 2014-02-17 15:48:09 -08:00
Jake McGinty
4f87c1e52e better intent sequence for single contact selection 2014-02-17 15:48:08 -08:00
Jake McGinty
725e943842 fixed date floating in funky location 2014-02-17 15:48:08 -08:00
Moxie Marlinspike
9bb327db42 Handle SMS fallback preferences correctly, and fix directory sync. 2014-02-17 15:31:42 -08:00
Moxie Marlinspike
94b54a6d63 Fix build. 2014-02-17 13:22:37 -08:00
Moxie Marlinspike
fe03a22926 Make group creation exceptions more accurate. 2014-02-17 13:19:49 -08:00
Moxie Marlinspike
d8e1df9233 Check prekey identity on mismatched devices too. 2014-02-17 12:41:06 -08:00
Moxie Marlinspike
6b5753337c Putting this functionality in the hands of the user was a bad idea. 2014-02-17 12:37:34 -08:00
Moxie Marlinspike
18f3314cd2 Fix for no paradigm. 2014-02-17 11:54:39 -08:00
Moxie Marlinspike
b9f4fba98a Handle identity key mismatch on outgoing group messages.
Additionally, make the group creation process asynchronous.
2014-02-17 11:43:37 -08:00
Jake McGinty
5810062b25 group action conversation items, tweaks to single contact selection 2014-02-16 21:09:15 -08:00
Moxie Marlinspike
e7e5bc0884 Verify identity keys on outgoing messages.
If PreKeyEntity identity key doesn't match local DB, fail
outgoing message and queue "incoming" identity key update
message for manual user approval.
2014-02-16 15:23:49 -08:00
Moxie Marlinspike
e2989373cd All push groups are 'secure' ConversationActivities. 2014-02-15 18:40:08 -08:00
Moxie Marlinspike
4e703d5a00 Correct retry logic for SMS JB+ and for push groups. 2014-02-15 18:31:25 -08:00
Moxie Marlinspike
b79bc4c234 Fix for non-group threading issue. 2014-02-15 11:44:47 -08:00
Moxie Marlinspike
a305bb80e6 Correctly display group members 2014-02-15 11:30:20 -08:00
Jake McGinty
8e3aa94a05 group member name tags, group convo iconography, tweaks 2014-02-15 04:21:56 -08:00
Jake McGinty
b2fdd74a1c fix error indicator visibility/placement for sent messages 2014-02-14 17:10:05 -08:00
Moxie Marlinspike
7d3a2acb29 Fix build 2014-02-14 16:41:06 -08:00
Jake McGinty
556b0dec1d pretty up the interface/colors a bit. 2014-02-14 16:21:48 -08:00
Jake McGinty
9b41675f8f single contact selection 2014-02-14 16:21:48 -08:00
Moxie Marlinspike
9438973eac Switch to protobuf enums for push signal type. 2014-02-14 16:20:47 -08:00
Moxie Marlinspike
2f98622948 Fix group migration. 2014-02-14 16:18:18 -08:00
Moxie Marlinspike
067799be06 Display group actions and correctly handle group delivery. 2014-02-14 15:59:57 -08:00
Moxie Marlinspike
7c46f3cbf8 Fill in group creation actions 2014-02-13 17:10:20 -08:00
Jake McGinty
41aa53dd66 masterSecret 2014-02-13 12:36:31 -08:00
Jake McGinty
b47076cf1b kill wrong finish() for mms creation 2014-02-13 12:18:17 -08:00
Jake McGinty
bb4a4d33c9 handlePush and handleMms prototypes 2014-02-13 12:15:26 -08:00
Jake McGinty
c5d010c86f Quick progressbar sample for network operations during group create 2014-02-13 11:44:07 -08:00
Jake McGinty
fe55ac57d9 strings, strings, strings 2014-02-12 18:12:58 -08:00
Jake McGinty
01a438de09 basic messaging when non-push users are added 2014-02-12 17:17:33 -08:00
Jake McGinty
b4a4e629f1 alignment and string work 2014-02-12 12:05:18 -08:00
Jake McGinty
9cd5a67ec5 directory changes to use number instead of token, group ui progress 2014-02-12 11:35:04 -08:00
Moxie Marlinspike
fc3411da83 Merge pull request #593 from backspace/patch-1
Link BitHub image to donation page. Fixes #591
2014-02-10 21:57:10 -08:00
Buck Doyle
dc85b23a06 Link BitHub image to description page. Fixes #591 2014-02-11 00:50:09 -05:00
Moxie Marlinspike
0af473d880 Merge branch 'groups' of github.com:WhisperSystems/TextSecure into groups 2014-02-03 11:52:27 -08:00
Moxie Marlinspike
0ace469d74 Support for multi-device.
1) In addition to the Recipient interface, there is now
   RecipientDevice.  A Recipient can have multiple corresponding
   RecipientDevices.  All addressing is done to a Recipient, but
   crypto sessions and transport delivery are done to
   RecipientDevice.

2) The Push transport handles the discovery and session setup
   of additional Recipient devices.

3) Some internal rejiggering of Groups.
2014-02-02 19:38:06 -08:00
Jake McGinty
ed3151bdb5 backward compatible navigation drawer toggle // FREEBIE 2014-02-01 19:40:46 -08:00
Jake McGinty
6157a0df7a Merge pull request #572 from cketti/black_startup_theme
Use black theme without actionbar for RoutingActivity
2014-02-01 18:54:50 -08:00
Jake McGinty
5a75ff9299 Merge pull request #537 from veeti/registration
Registration activity fixes
2014-01-26 01:02:41 -08:00
Jake McGinty
9fd2c4753e ui wip 2014-01-25 23:39:56 -08:00
cketti
c8ef21774d Use black theme without actionbar for RoutingActivity
The theme from the manifest is used for the startup animation.
Previously light background with a dark actionbar and the
green icon was displayed during the startup animation, then
the theme switched to whatever is configured in settings.
Now a black background without actionbar is used for the
startup animation. This was chosen because a black "flash" when
using the light theme is visually less distracting than a white
flash when using the dark theme.
2014-01-26 06:26:30 +01:00
Veeti Paananen
fc458770ea Reduce margin between registration text 2014-01-20 15:31:09 +02:00
Veeti Paananen
0d2ce2528c Use equal margins in the registration view 2014-01-20 15:13:11 +02:00
Veeti Paananen
6bfae9ebc9 Fix registration activity being cut off on small screens or large fonts 2014-01-20 15:13:11 +02:00
Jake McGinty
2f01569e45 Revert "Don't stick thread IDs in the Intent extra data. Always mark all threads read from notification."
This reverts commit 91b52bed18.
2014-01-18 18:25:51 -08:00
Moxie Marlinspike
d51ccb8ce2 Update gradle docs //FREEBIE 2014-01-18 10:44:06 -08:00
Moxie Marlinspike
49daa45dca wip 2014-01-14 00:26:43 -08:00
Moxie Marlinspike
63b90bb57f Merge pull request #541 from mcginty/resource_crunch
pngcrush and removal of unused layout
2014-01-12 12:09:09 -08:00
Jake McGinty
8f7c9d45aa pngcrush and removal of unused layout // FREEBIE 2014-01-11 10:55:52 -10:00
Moxie Marlinspike
4851a555e7 Merge pull request #540 from WhisperSystems/lint
Fixes more lint errors
2014-01-11 10:52:32 -08:00
Ruben Pollan
a0dd1689da Use minSdkVersion 9
'Array.copyOfRange' depends on API level 9

// FREEBIE
2014-01-11 08:47:28 -10:00
Moxie Marlinspike
63d217bd80 Merge pull request #539 from WhisperSystems/apndefaults
Add apn settings for some providers
2014-01-11 10:01:17 -08:00
Ruben Pollan
6cdd2aff0d Suppress lint errors 2014-01-11 01:34:11 -10:00
Ruben Pollan
1e77c9904a VerifyKeysActivity don't exists anymore 2014-01-10 21:51:53 -10:00
Ruben Pollan
c134709009 Add apn settings for some providers 2014-01-10 21:03:45 -10:00
Moxie Marlinspike
4a93f7d012 Merge pull request #538 from WhisperSystems/lint
Merge Don't fail build if lint gives errors
2014-01-10 20:57:46 -08:00
Ruben Pollan
29cdfd4b96 Fix some translation errors 2014-01-10 16:22:30 -10:00
Ruben Pollan
a14897f8b5 Don't fail build if lint gives errors 2014-01-10 16:20:25 -10:00
Moxie Marlinspike
9b6d4e3696 Merge pull request #532 from mcginty/visual_refresh
WBoC Visual Refresh
2014-01-09 21:08:15 -08:00
Jake McGinty
28c1c5006b icon, contact list and conversation redesign 2014-01-09 19:06:41 -10:00
Moxie Marlinspike
8ca60a8746 Merge pull request #536 from bozsco/fix-#487
Merge Automatically show keyboard when new SMS is composed
2014-01-09 14:40:33 -08:00
bozsco
e9a8c7474c Automatically show keyboard when new SMS is composed 2014-01-09 16:52:11 -05:00
Moxie Marlinspike
75ce00cb90 Merge pull request #495 from breser/issue469
Merge Fix issue #469: Hide "Clear Passphrase" if passphrase is disabled.
2014-01-07 22:02:23 -08:00
Ben Reser
149671095b Fix issue #469: Hide "Clear Passphrase" if passphrase is disabled. 2014-01-07 21:47:28 -08:00
Moxie Marlinspike
c488947248 Merge pull request #453 from irv/master
Merge Fix issue #433
2014-01-07 20:08:53 -08:00
Moxie Marlinspike
04b2c3772a Support skipping password creation at setup 2014-01-07 16:27:00 -08:00
Moxie Marlinspike
a4a3b4a453 Update registration strings 2014-01-07 15:16:23 -08:00
Moxie Marlinspike
5c97b1e864 Twiddle the auto initiate 2014-01-06 20:03:16 -08:00
Moxie Marlinspike
dde2d2564a Fix rebase errors 2014-01-06 19:49:35 -08:00
Moxie Marlinspike
71664926e9 Better handling for unregistered users on outgoing message. 2014-01-06 14:38:41 -08:00
Moxie Marlinspike
3c3028c8e3 Typo 2014-01-06 14:38:15 -08:00
Moxie Marlinspike
842df1ac39 Remove receiver chains that are 5 old. 2014-01-06 14:38:15 -08:00
Moxie Marlinspike
ff0dff745c Let's order 3DHE by Alice/Bob roles. 2014-01-06 14:38:15 -08:00
Moxie Marlinspike
d4188c4a1c SHA256 attachment MACs. 2014-01-06 14:38:14 -08:00
Moxie Marlinspike
f002072f38 New attachment API 2014-01-06 14:38:14 -08:00
Moxie Marlinspike
72be77b47e Catch bad prekeys 2014-01-06 14:38:14 -08:00
Moxie Marlinspike
327ee4ff62 Remove unnecessary classes, up prekey limit to 100 2014-01-06 14:38:14 -08:00
Moxie Marlinspike
1ab4e7e9de Library accepts push connection certificate as argument. 2014-01-06 14:38:14 -08:00
Moxie Marlinspike
ff5ad4b85d Updated copyright 2014-01-06 14:37:52 -08:00
Moxie Marlinspike
ce5f3c5157 Validate phone numbers when formatting. 2014-01-06 14:37:52 -08:00
Moxie Marlinspike
f7b71e5e28 Add info to MessageKey HKDF, change order of RootKey derivation. 2014-01-06 14:37:52 -08:00
Moxie Marlinspike
44092a3eff Support for Axolotl protocol.
1) Split code into v1 and v2 message paths.

2) Do the Axolotl protocol for v2.

3) Switch all v2 entities to protobuf.
2014-01-06 14:37:52 -08:00
Moxie Marlinspike
dc73bc2a5c Having calling code specify push URL to library. 2014-01-06 14:37:52 -08:00
Moxie Marlinspike
f8dda5afd6 Missing comma 2014-01-06 14:37:51 -08:00
Moxie Marlinspike
4380b46a35 Correctly update MMS security status. 2014-01-06 14:37:51 -08:00
Moxie Marlinspike
7e926d08ac Better relay handling. 2014-01-06 14:37:51 -08:00
Moxie Marlinspike
fde8d32848 Subtle rebase conflicts... 2014-01-06 14:37:51 -08:00
Moxie Marlinspike
f10d6a7b0b Lets use strict wildcard matching. 2014-01-06 14:36:23 -08:00
Moxie Marlinspike
320cc84392 Update production endpoint. 2014-01-06 14:36:23 -08:00
Moxie Marlinspike
dadabdfaa8 Make UI responsive to UniversalTransport upgrades. 2014-01-06 14:36:23 -08:00
Moxie Marlinspike
07b7696937 Update 'DJB' type not to conlict with NIST type 0x04. 2014-01-06 14:36:23 -08:00
Moxie Marlinspike
c38a8aa699 Migrate to Curve25519.
1) Generate a Curve25519 identity key.

2) Use Curve25519 ephemerals and identities for v2 3DHE agreements.

3) Initiate v2 key exchange messages.

4) Accept v1 key exchange messages.

5) TOFU Curve25519 identities.
2014-01-06 14:36:22 -08:00
Moxie Marlinspike
a03fff8b24 Add HKDF support for new sessions. 2014-01-06 14:36:22 -08:00
Moxie Marlinspike
dbc070cd65 Refactor the ciphertext message parsing and building. 2014-01-06 14:36:22 -08:00
Moxie Marlinspike
6e640db39c 204 is ok 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
44d59d0fd1 Correctly store destination SMS state. 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
51b9affe90 Add federation support for attachment retrieval. 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
246cd10454 Bundle e164 and relay into PushDestination 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
ca3c82f581 Simply PushServiceSocket constructor. 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
5b2caa0074 Make relay arguments consistent. 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
fa073e0b46 Update gradle plugin version 2014-01-06 14:36:21 -08:00
Moxie Marlinspike
7fd9946275 Fix release push service url 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
fa5ccc3f8a Support for server federation. 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
25a2ad7289 Add directory refreshing at 24hr intervals. 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
e7a21752d8 Switch code API to GET. 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
b010c5194a Support publishing AARs to maven local 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
eb4cc7f4e5 Add incoming message sources to active token dir. 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
1ac32346c1 Graduate to a rebased and gradle world. 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
2d083208cc Handle negative directory case and unlisted contacts. 2014-01-06 14:35:54 -08:00
Moxie Marlinspike
75cca3add1 Resign ourselves to a less sophisticated contact intersection method. 2014-01-06 14:35:53 -08:00
Moxie Marlinspike
073b1f69e3 Rollbacks, v2 sms-transport key exchanges, push identity conflicts.
1) Stop protocol rollbacks.

2) Handle v2 version key exchange messages.

3) Handle identity key conflicts on prekeybundle messages.
2014-01-06 14:35:53 -08:00
Moxie Marlinspike
5e6d39beea Move classes into library 2014-01-06 14:35:53 -08:00
Moxie Marlinspike
8f6590b738 Handle notifications and receiving push when locked. 2014-01-06 14:35:53 -08:00
Moxie Marlinspike
0dd36c64a4 Basic support for encrypted push-based attachments.
1) Move the attachment structures into the encrypted message body.

2) Encrypt attachments with symmetric keys transmitted in the
   encryptd attachment pointer structure.

3) Correctly handle asynchronous decryption and categorization of
   encrypted push messages.

TODO: Correct notification process and network/interruption
      retries.
2014-01-06 14:35:53 -08:00
Moxie Marlinspike
cddba2738f Make encoding/decoding more explicit. 2014-01-06 14:35:53 -08:00
Moxie Marlinspike
0cc5837d7f Support encrypted transport, properly handle multiple recipients.
1) Add encryption support for the transport layer.  This obscures
   metadata from the push messaging provider.

2) Better support the direction multiple destination messages is
   headed (one unique message per recipient).
2014-01-06 14:35:53 -08:00
Moxie Marlinspike
68ec0a3727 Add last resort key and signaling key. 2014-01-06 14:35:53 -08:00
Moxie Marlinspike
45e380a5bb move constants into library 2014-01-06 14:35:52 -08:00
Moxie Marlinspike
1bbcedabd4 Added SMS transport support for PreKeyBundle messages.
1) Added SMS transport support.

2) Keep track of whether a PreKeyBundle message has gotten
   a response, and send them as subsequent messages until
   one has been received.
2014-01-06 14:35:52 -08:00
Moxie Marlinspike
c3b8b62d32 Delete pre-key record when establishing agreement. 2014-01-06 14:35:52 -08:00
Moxie Marlinspike
43492b66c4 Rename EncryptedMessage 2014-01-06 14:35:52 -08:00
Moxie Marlinspike
90814be167 Fix up release parameters 2014-01-06 14:35:52 -08:00
Moxie Marlinspike
7f642666dd Basic support for prekeybundle message delivery and receipt. 2014-01-06 14:35:52 -08:00
Moxie Marlinspike
1cc2762656 Refactor relationship between SessionCipher and Message. 2014-01-06 14:35:52 -08:00
Moxie Marlinspike
d1969412fb Move PreKey ids to be Mediums, generate in circular buffer. 2014-01-06 14:35:51 -08:00
Moxie Marlinspike
edb89ee3e9 Encode prekey as full JSON rather than protobuf blobs.
1) Split prekey messages out into full JSON.

2) Add support for retrieving prekeys.
2014-01-06 14:35:51 -08:00
Moxie Marlinspike
499de2d2bf Move prekey jsonifcation into the push code, add identity key. 2014-01-06 14:35:51 -08:00
Moxie Marlinspike
b8f663b69c Move common crypto classes into TextSecureLibrary.
1) Move all the crypto classes from securesms.crypto.

2) Move all the crypto storage from securesms.database.keys

3) Replace the old imported BC code with spongycastle.
2014-01-06 14:35:51 -08:00
Moxie Marlinspike
2042ca6cb7 Generate "prekeys" at push registration time.
This generates a large number of key exchange messages and
registers them with the server during signup.
2014-01-06 14:34:47 -08:00
Moxie Marlinspike
cfb7b8fcba Consider unregistered if authorization fails.
This should only occur if another device has registered with the
same number, effectively making the current device unregistered.
2014-01-06 14:34:46 -08:00
Moxie Marlinspike
03ff55db97 Actually set the preference to unregistered 2014-01-06 14:33:53 -08:00
Moxie Marlinspike
0e899b93d4 Reset Release 2014-01-06 14:33:53 -08:00
Moxie Marlinspike
fb378a6e00 Change attachment retrieval interface 2014-01-06 14:33:53 -08:00
Moxie Marlinspike
9287d413ac Support for incoming attachments.
1) Refactored MMS layer to use abstracted types.

2) Added support for retrieving attachment IDs.
2014-01-06 14:33:52 -08:00
Moxie Marlinspike
4bb337a3a0 Revised support for outgoing attachments 2014-01-06 14:33:52 -08:00
Moxie Marlinspike
fd045f2354 Refactor MMS send/download to be synchronous.
1) Make the radio change a synchronous action with a timeout.

2) Move the send logic into an MmsTransport, in preparation for
   UniversalTransport composition.

3) Move the download logic into a synchronous receiver.
2014-01-06 14:33:52 -08:00
Moxie Marlinspike
53803630d4 Enable TextSecure universal transport. 2014-01-06 14:33:52 -08:00
Moxie Marlinspike
d7070e7ecf Inserted the Registration activity into initial setup flow.
1) Added push messaging toggle to preferences.

2) Added push messaging registration screen to setup flow.

3) Migrated rest of SharedPreferences accessors to
   TextSecurePreferences.
2014-01-06 14:30:03 -08:00
Moxie Marlinspike
52e5274a2f Add registration notification support. 2014-01-06 14:21:51 -08:00
Moxie Marlinspike
4c615546e8 update gitignore 2014-01-06 14:21:50 -08:00
Moxie Marlinspike
1d1492b15c Remove from VCS 2014-01-06 14:21:50 -08:00
Moxie Marlinspike
0ed9da9a2c Strings and slight cleanup 2014-01-06 14:21:50 -08:00
Moxie Marlinspike
26dadfcb7a Move trust store to raw resource from asset. 2014-01-06 14:21:50 -08:00
Moxie Marlinspike
1ac06312a0 Move directory and push service socket into library. 2014-01-06 14:21:50 -08:00
Moxie Marlinspike
a200d29514 Move most of Util into library 2014-01-06 14:21:50 -08:00
Moxie Marlinspike
21eee19380 Split into library project and add shared preferences layer of indirection. 2014-01-06 14:20:59 -08:00
Moxie Marlinspike
2539723410 Fix string 2014-01-06 14:19:06 -08:00
Moxie Marlinspike
0958c30400 Stringify 2014-01-06 14:19:06 -08:00
Moxie Marlinspike
7eef93c829 Stringify and clean layout 2014-01-06 14:19:05 -08:00
Moxie Marlinspike
3634ba0b55 Registration with voice verification. 2014-01-06 14:18:30 -08:00
Moxie Marlinspike
6ca029f64a Plugin 0.7, Gradle 1.9, AS 4.0 2014-01-06 14:13:12 -08:00
Moxie Marlinspike
7bf96ec7d7 Merge pull request #524 from thoughtbox/master
Merge Allow for "Enable Enter key" translation
2014-01-02 15:35:56 -08:00
thoughtbox
389fdaed32 Enter key string.xml references
To allow for translations
2014-01-02 18:58:54 +01:00
thoughtbox
8186694555 Change to string refs for Enter
To allow for translation
2014-01-02 18:53:50 +01:00
Moxie Marlinspike
b98d5ca244 Merge pull request #501 from veeti/notification
Improve password caching notification UI & UX
2014-01-01 13:51:26 -08:00
Veeti Paananen
eb1b762a76 Improve password caching notification UI & UX
On Jelly Bean and above:

- Use the standard notification style for a better and consistent visual
  appearance

- Use the JB notification actions API for the locking action

- Use a lower notification priority to prioritize other notifications
  over TextSecure

On ICS:

- Use the existing custom notification layout

Everywhere:

- Allow opening the app itself from the notification

- Simplify strings: don't talk about a "cached passphrase" but about the
  app being "unlocked"/"locked"
2013-12-22 04:48:39 +02:00
Moxie Marlinspike
ca92b4d904 Merge pull request #493 from niktrix/patch-1
set unread message count in notifications.
2013-12-18 13:21:10 -08:00
nicky g
a0c821f6ac set unread message count in notifications.
was not able to squash commit requesting new pull
2013-12-19 02:44:42 +05:30
Moxie Marlinspike
d260cdcc9f Add giffgaff APN defaults. // FREEBIE 2013-12-17 16:57:40 -08:00
Moxie Marlinspike
496d5e21d2 Add Slovenia APN defaults 2013-12-17 16:53:35 -08:00
Moxie Marlinspike
bba49fcb76 Merge pull request #446 from veeti/settings
Show LED and ringtone setting values in their summaries
2013-12-16 20:17:54 -08:00
Veeti Paananen
6eb094c87e Show LED and ringtone setting values in their summaries
As instructed in the Android design guidelines. Also removed unnatural
capitalization.
2013-12-17 03:13:22 +02:00
Moxie Marlinspike
23e8035edd Merge pull request #486 from jlund/strings-update
Incredibly minor cleanup of the strings file
2013-12-16 15:02:03 -08:00
Joshua Lund
0fed5593a8 Incredibly minor cleanup of the strings file 2013-12-16 15:11:17 -07:00
Moxie Marlinspike
60f5363da0 Merge pull request #485 from veeti/tabswipe
Add tab swiping to contacts picker
2013-12-16 12:50:41 -08:00
Veeti Paananen
bee964dcf8 Improve appearance of "no contacts" indicators by centering them.
Also remove pointless scroll views.
2013-12-16 22:27:10 +02:00
Veeti Paananen
f18324e2d6 Add tab swiping in the contact picker 2013-12-16 22:17:52 +02:00
Moxie Marlinspike
e7f4a6039c Merge pull request #479 from kyleconroy/new_icon
Add a new icon
2013-12-16 11:05:43 -08:00
Moxie Marlinspike
fccb4cc0cf Add bithub payout slug. 2013-12-16 09:58:56 -08:00
Andy Irving
91b52bed18 Don't stick thread IDs in the Intent extra data. Always mark all threads read from notification. 2013-12-14 16:55:24 +00:00
Kyle Conroy
f91cfe1c44 Update icon with more distinct drop shadow. Make the lock flat. 2013-12-13 11:33:02 -08:00
Kyle Conroy
c8422a8942 Lighten the drop shadow on the icon 2013-12-12 16:54:36 -08:00
Kyle Conroy
f74119a58c Add new icons 2013-12-12 16:30:14 -08:00
Moxie Marlinspike
ce4f935fa6 Bump version to 1.0.6 2013-12-07 11:47:14 -08:00
Moxie Marlinspike
ee0a84ec16 kn_IN 2013-12-07 11:31:08 -08:00
Moxie Marlinspike
7d931f5e6b Updated translations 2013-12-07 11:22:33 -08:00
Moxie Marlinspike
1740f9a7cd Merge pull request #443 from veeti/unlock
Clean up password unlock layout
2013-12-07 11:16:19 -08:00
Moxie Marlinspike
94913f34da Merge pull request #459 from thoughtbox/master
Add summary information to "Sound" setting in preferences.
2013-12-07 11:08:11 -08:00
Moxie Marlinspike
15284cd4d9 Merge pull request #460 from thejeshgn/patch-1
Added Kannada to languages
2013-12-07 11:05:02 -08:00
Moxie Marlinspike
7c2fb74af4 Fix for bug that could drop unencrypted MMS on KitKat. 2013-12-07 11:03:26 -08:00
Moxie Marlinspike
7489f3463a Change the way notifications work for non-default KitKat.
Messages that are not "secure" (encrypted or key exchange) are
automatically marked as read if TextSecure isn't the default
KitKat SMS app.

This change in functionality allows people who aren't using
TextSecure as a default SMS app on KitKat to still receive
notifications when they get incoming encrypted messages.
2013-12-07 11:03:25 -08:00
Thejesh GN
ed73bd57a1 Added Kannada to languages 2013-12-05 13:37:43 +05:30
Moxie Marlinspike
99d295abc5 Merge pull request #454 from veeti/highlights
Update card highlight style
2013-12-04 14:19:54 -08:00
thoughtbox
b56a4f9740 Update strings.xml to reference Sound summary in Settings. 2013-12-04 22:47:54 +01:00
thoughtbox
cc5981594f Add summary to "Sound" preference (1 of 2) 2013-12-04 22:46:30 +01:00
Veeti Paananen
37fb8fe445 Update card highlight style
Out with orange, in with blue and gray (on >= 4.4).
2013-12-04 01:19:53 +02:00
Andy Irving
7f44b029fe use PendingIntent.FLAG_UPDATE_CURRENT in calls to PendingIntent.getActivity() to avoid re-using the same extra data on every intent. 2013-12-03 21:48:16 +00:00
Moxie Marlinspike
b2bd19d787 Bumping version to 1.0.5 2013-12-03 08:30:15 -08:00
Moxie Marlinspike
c2b809c7c6 Fix for long multipart message bug on some ROMs. 2013-12-03 08:21:31 -08:00
Moxie Marlinspike
e0aa7fd359 Let unencrypted messages through. 2013-12-03 08:10:58 -08:00
Moxie Marlinspike
3a5f9748ff Merge pull request #449 from thoughtbox/patch-4
Update strings.xml
2013-12-03 07:56:18 -08:00
thoughtbox
33fd6414b8 Update strings.xml
Removed emoticon from QuickResponse and changed the wording slightly of the "default SMS app" setting.
2013-12-03 11:08:36 +01:00
Moxie Marlinspike
ce4b8701fb Merge pull request #445 from veeti/null
Fix crash when no SMS package is set
2013-12-02 23:23:29 -08:00
Veeti Paananen
10580a7f20 Fix crash when no SMS package is set 2013-12-03 09:06:16 +02:00
Moxie Marlinspike
d89ef70060 Bump version number to 1.0.4 2013-12-02 21:44:28 -08:00
Moxie Marlinspike
aad82e314d Fix duplicate MMS bug in KitKat.
1) Fix for typo that caused duplicate incoming MMS.

2) Only pay attention to "use for all" properties in < KitKat.
2013-12-02 21:39:09 -08:00
Moxie Marlinspike
8f7f1ea49c Bump version to 1.0.3 2013-12-02 17:34:07 -08:00
Moxie Marlinspike
0c0db28358 Fix string case 2013-12-02 17:11:16 -08:00
Veeti Paananen
89ae5ed4ed Clean up password unlock layout
Remove unnecessary and redundant nested layouts, fix the alignment of
the unlock button to the right edge of the screen, use cleaner margins
and replace the deprecated fill_parent sizes with match_parent.
2013-12-02 23:19:42 +02:00
Moxie Marlinspike
afa20058b8 Updated langauge translations 2013-12-02 13:09:33 -08:00
Moxie Marlinspike
9dc3730142 Merge pull request #441 from veeti/gradle-version
Update to the latest Android Gradle plugin
2013-12-02 12:57:53 -08:00
Moxie Marlinspike
504ec976c0 Merge pull request #440 from veeti/styles 2013-12-02 12:57:32 -08:00
Moxie Marlinspike
fda01796ab Merge pull request #421 from wsot/master
Fix issue #410: DecryptingPartInputStream could return more data than re...
2013-12-02 12:43:23 -08:00
Moxie Marlinspike
b0216e1494 Finish KitKat compatibility details.
1) The system does actually enforce having a BROADCAST_SMS
   permission on the SMS receiver. Break out the "delivered"
   parts of this into a separate Receiver, so the permission
   won't trip up GB devices.

2) The system does actually enforce having "quick response"
   intents.  Add a no-op for now.

3) Add a "make default" prompt.

4) Update settings to reflect what's going on in KitKat.
2013-12-02 12:31:59 -08:00
Gabe Conradi
e81756f443 Proper SMS support for KitKat. 2013-12-02 08:32:34 -08:00
Veeti Paananen
56fd6e7035 Update to the latest Android Gradle plugin 2013-12-01 01:48:24 +02:00
Veeti Paananen
9ddfa6499c Gingerbread pls go
Look like an Android app from 2013.

Remove the redundant Gingerbread button styles from buttons to
automatically use the Holo theme on phones that don't run a 3+ year old
operating system.

Create a new style for horizontal progress bars that uses the Holo
progress bar style on v11 and above.
2013-12-01 01:36:21 +02:00
Simeon Morgan
4931d7327b Switch to two-space indentation, remove inline comments. 2013-11-14 17:53:38 +11:00
Simeon Morgan
adfa3c1b10 Optimised use of buffers when decrypting to avoid unnecessary array copying properly. 2013-11-12 13:37:57 +11:00
Simeon Morgan
3cc6344c8b Optimised use of buffers when decrypting to avoid unnecessary array copying 2013-11-12 13:31:30 +11:00
Simeon Morgan
546dd5485c Fix issue #410: DecryptingPartInputStream could return more data than requested, causing segfaults in BitmapFactory on Android 4.4. 2013-11-12 12:57:47 +11:00
Moxie Marlinspike
f9c7687ce2 Bump version to 1.0.2 2013-10-21 10:30:09 -07:00
Moxie Marlinspike
b0e0011060 Add URI permissions to fix crash on 4.x environments. 2013-10-21 10:21:48 -07:00
Moxie Marlinspike
9c0db4c259 Bump version to 1.0.1 2013-10-20 19:15:36 -07:00
Moxie Marlinspike
9cf1751c49 Added hebrew and danish to language selector 2013-10-20 19:13:32 -07:00
Moxie Marlinspike
981c9a1543 Updated language translations 2013-10-20 19:13:15 -07:00
Moxie Marlinspike
73bf21602a Move ReceiveKeyActivity back to themed dialog activity. 2013-10-20 19:12:53 -07:00
Moxie Marlinspike
8d8a6ab998 Switch menu contact image to be a menu image. 2013-10-20 17:18:59 -07:00
Moxie Marlinspike
798e3c0656 Merge pull request #384 from meskio/383_batch_selection
Add deselect to batch selection mode
2013-10-20 16:59:41 -07:00
Moxie Marlinspike
891e3aeb97 Merge pull request #381 from meskio/add_contact
New 'add contact info' option on the conversation contextual menu
2013-10-20 16:58:58 -07:00
rhodey
2c2a03e5e2 Enhanced MMS configuration prompts and processing.
1) Added a new message status to MmsDatabase to
   signify a pending MMS download which requires
   APN settings.

2) Added a database method to query MMS messages
   based on status.

3) Added login to SendReceiveService for processing
   of MMS pending APN information.

4) Moved all APN/MMS settings into ApnPreferencesActivity
   and transformed PromptApnActivity into a simple
   informational activity.

5) Added logic to check for APN settings on send and
   receive of all MMS (media, group, email) and direct
   user to PromptApnActivity then ApnPreferencesActivity
   if necessary.

6) Vocab/grammar adjustments.
2013-10-20 16:56:34 -07:00
Ruben Pollan
c7b39eca11 Add deselect to batch selection mode 2013-10-20 18:25:01 +02:00
Ruben Pollan
3d690faff0 New 'add contact info' option on the conversation contextual menu
This option is used to add phone numbers from the contact list on the
messages.
2013-10-17 02:28:36 +02:00
Moxie Marlinspike
f3fdde6040 Merge pull request #376 from meskio/extension_saving_attachment
Set the right extension on saving an attachment
2013-10-15 07:35:14 -07:00
Moxie Marlinspike
f49c62793b Merge pull request #377 from meskio/resend_message_on_fail2
Allow to resend a failed message
2013-10-15 06:32:12 -07:00
Moxie Marlinspike
f27c7c4178 Merge branch 'thoughtbox-patch-1'
Conflicts:
	res/values/strings.xml
2013-10-15 06:28:18 -07:00
Moxie Marlinspike
ee6a74cb66 Merge pull request #379 from thoughtbox/patch-3
update to in-thread notification description
2013-10-15 06:26:13 -07:00
thoughtbox
cfc255a7b7 update to in-thread notification description
I felt that the description of what "in-thread notification" could be difficult to understand for some. This is better, I think (though I'm not fully satisfied).
2013-10-13 20:08:56 +02:00
thoughtbox
615ca931d4 Update strings.xml
I think it should be "in-thread" rather than "in thread".
2013-10-13 19:47:22 +02:00
Ruben Pollan
04eafd5fab Allow to resend a failed message
Add an option to the context menu of the message to resend it if it has
failed.
2013-10-13 15:39:15 +02:00
Ruben Pollan
73b1e3f3d4 Set the right extension on saving an attachment 2013-10-13 14:45:04 +02:00
Moxie Marlinspike
8d115562f0 Merge branch 'master' of github.com:WhisperSystems/TextSecure 2013-10-13 04:07:45 -07:00
Moxie Marlinspike
f26b9070f2 Update PRNG fix code sample.
Google updated their code sample to account for restrictive
SELinux configurations on some devices.
2013-10-13 04:06:58 -07:00
Moxie Marlinspike
2cbc4d3b0a Merge pull request #372 from meskio/key_notification
Upgrade notification KeyCachingService code to use NotificationCompat.Builder
2013-10-12 09:20:48 -07:00
Moxie Marlinspike
ee8c8530bf Merge pull request #373 from d3sre/issues-273
Issues 273
2013-10-12 09:17:51 -07:00
Moxie Marlinspike
763e4b1b27 Merge pull request #367 from nikolai-r/master
add option to disable audible inthread notifications
2013-10-12 09:15:54 -07:00
Desiree Sacher
4f49216103 corrected class info of NullPointerException messages 2013-10-12 15:32:45 +02:00
Desiree Sacher
ed4c8cd799 extended log of encrypted and plaintext messages NullPointerException 2013-10-12 15:29:03 +02:00
Ruben Pollan
4826dbcc34 Upgrade notification KeyCachingService code to NotificationCompat.Builder 2013-10-12 15:04:16 +02:00
Nikolai Rusakov
2cf7f82f07 closes #367 - add option to disable audible inthread notifications 2013-10-11 22:19:35 +00:00
Moxie Marlinspike
1c8f8666ba Make the switch to gradle!
1) ABS is now published as an AAR, so we can eliminate all local
   dependencies and bundled jars.

2) Upgrade to ABS 4.4.0 (The Last Release) and deal with the loss
   of Sherlock.Dialog by faking it with our own themes.

3) Remove all traces of ant. The modern world is here.
2013-10-10 13:52:24 -07:00
Shaun Walbridge
91dd558f7a ActionBarSherlock verisons now stored as tags
The current release of `ActionBarSherlock` uses tags to store its relases, so the clone command fails. Instead, clone HEAD and switch to the 4.2.0 tag.
2013-10-10 01:50:02 -07:00
joshua stein
99e3e596bb Correctly preserve MMS image aspect ratios. 2013-10-10 01:43:48 -07:00
rhodey
f23fc9b3dd Merge pull request #358 from WhisperSystems/issue353
"Select Ringtone" preference in "Notifications" section of TextSecure settings now reads "Sound" to better reflect the selection of audio presented.
2013-10-01 12:21:39 -07:00
rhodey
1149d8b625 Switched string constant name for notification sound from preferences__select_reingtone to preferences_sound to match the new value of the constant, 'Sound'. 2013-09-30 15:25:50 -07:00
rhodey
282e40db40 Changed language in notification section of settings from 'select ringtone' to 'sound'. 2013-09-30 14:55:55 -07:00
rhodey
27fadf70f0 Merge pull request #320 from svramusi/master
Tested and merged, thanks @svramusi !
2013-09-01 22:10:45 -07:00
Steve R
45f4faaf4c Fix for timeout interval bug
Regardless of which theme is used, the text color for the timeout
  interval was being set to black. This made it difficult to
  read when using the Dark Theme.
2013-08-23 00:05:19 -04:00
Moxie Marlinspike
f58f79a459 Bumping version to 1.0 2013-08-16 10:16:13 -07:00
Moxie Marlinspike
124bcf2624 Added bulgarian and greek 2013-08-16 08:38:43 -07:00
Moxie Marlinspike
69bfb20531 Updated language translations 2013-08-16 08:32:14 -07:00
Moxie Marlinspike
b14d9d84ad Fix for Android PRNG bug.
There is apparently an Android vulnerability with the PRNG it
provides through the JCE. This uses their suggested code to patch
the PRNG, and provides the option to regenerate identity keys.

http://android-developers.blogspot.com/2013/08/some-securerandom-thoughts.html
2013-08-15 11:27:14 -07:00
Moxie Marlinspike
8ecf972534 Bumping version to 0.9.9.9 2013-08-10 20:29:31 -07:00
Moxie Marlinspike
8281ef18d4 Fix for ShortBufferException problem introduced in Android 4.3
Not really sure how it's possible for the system to give us an
extra block of data, but it does if both the input and output
buffers are sized the same during the first decrypt.  This
fixes things, but I wish I better understood why it was broken.
2013-08-10 09:09:00 -07:00
Moxie Marlinspike
4722b7f005 bumping version to 0.9.9.8 2013-07-22 16:15:22 -07:00
Moxie Marlinspike
af19da3ab2 Added romanian language support 2013-07-22 15:53:52 -07:00
Moxie Marlinspike
4240dc80a1 Updated language translations 2013-07-22 15:52:10 -07:00
Moxie Marlinspike
7bd520cb41 Fix for batch selection bug 2013-07-22 15:30:12 -07:00
Moxie Marlinspike
7d07d56fc3 Fix for 'bad encrypted message' errors.
1) There was a regression in the outgoing multipart transport
   logic, such that the same 'identifier' byte would be used
   for all messages (0).  This now works correctly.

2) Added some additional heuristics on the receiving side.
   Now mutlipart containers are only valid for 1hr, and are
   considered invalid if the container size is different from
   the multipart message size.
2013-07-22 15:04:31 -07:00
Moxie Marlinspike
4281df7a28 display emoji correctly on devices of all densities 2013-07-15 17:33:30 -07:00
Moxie Marlinspike
c827f0a2a7 Merge pull request #249 from joeykrim/patch-1
Small clarification in the comments on the types of SMS to ignore
2013-07-14 11:33:23 -07:00
joeykrim
8464bc775a Removed extra comparisons by converting original phrase to uppercase, then comparing
Removed previous multiple comparisons that were variations of capitalizing the same phrase by converting the original phrase to all uppercase and then comparing
2013-07-13 16:41:09 -04:00
Moxie Marlinspike
0ff5056365 Merge pull request #262 from joeykrim/patch-4
Moved Preferences Disabled passphrase title and summary text into strings.xml
2013-07-13 10:58:34 -07:00
Moxie Marlinspike
f66710a7ea Merge pull request #260 from joeykrim/patch-2
Changed new Thread() to use new AsyncTask()
2013-07-13 10:55:09 -07:00
joeykrim
10fd757cb4 Changed Disable passphrase summary and title text to reference strings.xml 2013-07-12 23:15:40 -04:00
joeykrim
719d791962 Added Disable Passphrase title and summary strings from Preference.xml 2013-07-12 23:11:27 -04:00
joeykrim
c89cac8785 Changed new Thread() to use new AsyncTask()
Changed new Thread() to use new AsyncTask() - same as was done in src/org/thoughtcrime/securesms/service/KeyCachingService.java - d97252d8d6
2013-07-12 22:40:14 -04:00
Moxie Marlinspike
dfa710a6fc Don't use ConnectivityManager checkRouteToHost for IPv6
T-Mobile LTE now uses IPv6 addresses for their MMSC, which are
incompatible with ConnectivityManager's checkRouteToHost.
2013-07-12 15:25:34 -07:00
joeykrim
87e8214bae Small clarification in the comments on the types of SMS to ignore 2013-07-08 10:16:25 -04:00
Moxie Marlinspike
bccf4895f6 Bumping version to 0.9.9.7 2013-07-02 18:59:17 -07:00
Moxie Marlinspike
184537e691 Updated language translations 2013-07-02 16:50:49 -07:00
Moxie Marlinspike
d97252d8d6 Add ability to disable local encryption passphrase. 2013-07-01 10:15:36 -07:00
Moxie Marlinspike
68b82c168e Add in-app language selection support. 2013-06-29 18:03:55 -07:00
Moxie Marlinspike
4977092f7a Add support for soft keyboard 'enter' key. 2013-06-29 15:37:47 -07:00
Moxie Marlinspike
7f532fc37f Fix dark theme recipients editor font color. 2013-06-29 15:34:18 -07:00
Moxie Marlinspike
767d790b3d Dark theme fixes.
1) Make the conversation background all black with no column.

2) Fix the font color on identity key review.
2013-06-29 10:33:58 -07:00
Moxie Marlinspike
93c222fe9c Added "recent emoji" panel as an LRU cache. 2013-06-29 09:51:08 -07:00
Moxie Marlinspike
71e161c792 Switched to new emoji lookup pattern, added rendering support. 2013-06-28 16:56:30 -07:00
Moxie Marlinspike
2e31cfed11 Basic support for composing emoji 2013-06-27 20:57:27 -07:00
Moxie Marlinspike
2db274080c Bumping version to 0.9.9.6 2013-06-26 09:25:32 -07:00
Moxie Marlinspike
408672b0b8 Fix or invisible delivery status regression with MMS. 2013-06-26 09:19:50 -07:00
Moxie Marlinspike
4d723a21f6 Bumping version to 0.9.9.5 2013-06-26 08:56:36 -07:00
Moxie Marlinspike
d6f7b4cc5a Updated language translations. 2013-06-26 08:12:55 -07:00
Moxie Marlinspike
288b416988 Fix NPEs 2013-06-25 13:20:29 -07:00
Moxie Marlinspike
e00914c977 Fix QR Code Regression. 2013-06-25 10:48:18 -07:00
Moxie Marlinspike
614e962110 Remove unused resources. 2013-06-25 10:47:59 -07:00
Moxie Marlinspike
aa25f94291 Enhanced import/export support.
1) Allow imports from the stock SMS database at any time.

2) Provide plaintext export support, in a format compatible with
   the "SMS Backup And Restore" app.

3) Fix the DB weirdness on encrypted restore that previously
   required killing the app.
2013-06-24 21:02:30 -07:00
Moxie Marlinspike
903ab92f5f Basic navigation drawer support. 2013-06-22 21:44:12 -07:00
Moxie Marlinspike
5263ac1f1a Theme Support
1) Broke out the UI elements of the major Activites into stylable
   attributes.

2) Created a 'light' and 'dark' theme for the newly stylable attrs.

3) Touched up some of the UI spacing.

4) Implemented dynamic theme switching support.
2013-06-21 12:14:40 -07:00
Moxie Marlinspike
2ffc70a95b Bumping version to 0.9.9.4 2013-06-18 17:07:36 -07:00
Moxie Marlinspike
0e4eef9785 Updated translations 2013-06-18 16:51:02 -07:00
Moxie Marlinspike
6c164df815 Lighter check 2013-06-18 16:43:41 -07:00
Moxie Marlinspike
2928abc98f Catch attempts to dial on devices with no dialer. 2013-06-18 16:43:41 -07:00
Moxie Marlinspike
38565488a4 Merge pull request #208 from richo/features/submodule
Easier development setup
2013-06-18 13:13:39 -07:00
Richo Healey
bf03b31dde add BUILDING instructions 2013-06-18 19:38:26 +10:00
Moxie Marlinspike
8524cc5598 Resolved a few MMS issues.
1) Fixed the "Unsupported Encoding!" problem.

2) Workaround for the Sprint issue, where the MMSC is adding a single
   extra byte to the end of each encrypted message.

3) Fixed the "large blob of base64 text" on encrypted MMS problem.
2013-06-15 09:06:15 -07:00
Moxie Marlinspike
d2a78ea84c Fix for contrived NPE on invalid recipient during conversation compose. 2013-06-01 12:42:45 -07:00
Moxie Marlinspike
ea98fe2d4f Merge pull request #181 from thoughtbox/patch-2
Some minor language.
2013-05-31 11:30:24 -07:00
Moxie Marlinspike
ad1d927437 Fix for NPE when group selection fragment is no longer attached to activity. 2013-05-30 20:35:56 -07:00
Moxie Marlinspike
0534f9d95a Fix for NPE on null FROM in MMS header. 2013-05-30 20:29:13 -07:00
Moxie Marlinspike
dda5bc8838 Add a 'mark as read' button to expanded notifications. 2013-05-30 12:39:56 -07:00
thoughtbox
a1e82ab403 Update strings.xml
Minor edits.
2013-05-27 21:27:00 +02:00
Moxie Marlinspike
8c1ca6c9e0 Clean up identity key view activity 2013-05-23 18:54:16 -07:00
Moxie Marlinspike
95eb62190a Remove checkboxes from the multi-select UI 2013-05-23 18:37:04 -07:00
Moxie Marlinspike
3743c57edd Clean up list of identity keys. 2013-05-23 17:47:42 -07:00
Moxie Marlinspike
5e2b31af60 Add appropriate text for manual case when identity is trusted. 2013-05-23 17:17:28 -07:00
Moxie Marlinspike
24fc93e9ae Switch to a more heavily TOFU model for identity keys.
1) There is no longer a concept of "verified" or "unverified."
   Only "what we saw last time" and "different from last time."

2) Let's eliminate "verify session," since we're all about
   identity keys now.

3) Mark manually processed key exchanges as processed.
2013-05-23 16:36:24 -07:00
Moxie Marlinspike
ef7977128b Bumping version to 0.9.9.3 2013-05-21 18:11:18 -07:00
Moxie Marlinspike
e080449383 Fix for NPE on import 2013-05-21 13:25:44 -07:00
Moxie Marlinspike
a0a6c3f211 Handle failed bitmap decoding 2013-05-21 10:32:48 -07:00
Moxie Marlinspike
3df67a1643 Properly return unknown recipient from SMS db on empty. 2013-05-21 10:23:27 -07:00
Moxie Marlinspike
018f5eccf3 Bumping version to 0.9.9.2 2013-05-17 12:57:14 -07:00
Moxie Marlinspike
b99cca8bfa Fix for NPE on failed icon click. 2013-05-17 12:53:16 -07:00
Moxie Marlinspike
d8e3e4c683 Bumping version to 0.9.9.1 2013-05-16 14:13:10 -07:00
Moxie Marlinspike
c86e414c5f Include (somehow missed) support for send/receive encrypted MMS. 2013-05-16 13:48:44 -07:00
Moxie Marlinspike
e5f634ba45 Fix for NPE 2013-05-16 13:18:06 -07:00
Moxie Marlinspike
be34f30719 Lower maximum size of cursor window on DB upgrade.
On some systems, the DB upgrade was failing because there were
too many rows for the cursor window.  This moves some looping
operations into single update statements by using the substr()
command, and chunks the rest using a series of LIMITs.
2013-05-16 13:16:42 -07:00
Moxie Marlinspike
f44ee4a41a Translation updates 2013-05-15 14:22:27 -07:00
Moxie Marlinspike
ad6760b62c Correctly handle deferred processing of key exchange message when locked. 2013-05-15 14:09:13 -07:00
Moxie Marlinspike
3d49e90779 Add Virgin Mobile US to ApnDefaults. 2013-05-10 09:57:09 -07:00
Moxie Marlinspike
ef554ed265 Remove leaky logging. 2013-05-10 09:01:33 -07:00
Moxie Marlinspike
5c8fa148ca Limit UniversalTransport to SMS for now. 2013-05-07 18:25:36 -07:00
Moxie Marlinspike
5d910a2997 Store last seen application version number at install time. 2013-05-07 16:31:11 -07:00
Moxie Marlinspike
e07c1a8e92 Handle failed MMS connectivity state appropriately. 2013-05-07 15:09:24 -07:00
Moxie Marlinspike
43214a854c Fix for IllegalArgumentException with null URL host. 2013-05-06 19:45:05 -07:00
Moxie Marlinspike
ff41c6763d Fix for detached illegalstateexception 2013-05-06 19:33:31 -07:00
Moxie Marlinspike
6fedc6b737 Fix for double-click NPE? 2013-05-06 19:27:09 -07:00
Moxie Marlinspike
7090ca4a42 Don't remote-encrypt key exchange messages 2013-05-06 19:09:36 -07:00
Moxie Marlinspike
81107a98eb Send m-notifyresp-ind after retrieving MMS 2013-05-06 19:09:06 -07:00
Moxie Marlinspike
a057b628eb Added Rogers APN defaults 2013-05-06 14:18:34 -07:00
Moxie Marlinspike
01658cc454 Fix for notification preference regression 2013-05-06 14:07:28 -07:00
Moxie Marlinspike
1aa84b145f Add 'mark all as read' option 2013-05-06 13:59:40 -07:00
Moxie Marlinspike
4af7fdabda String resources reorganization 2013-05-06 12:49:19 -07:00
Moxie Marlinspike
b1b9846971 merge liliakai-settings 2013-05-06 12:48:16 -07:00
Moxie Marlinspike
68ee1c8e62 Make a general category, move notification settings back inline. 2013-05-06 12:45:11 -07:00
Moxie Marlinspike
c35aa09806 Filter MMS weirdness 2013-05-06 12:33:42 -07:00
Moxie Marlinspike
50fae64330 Replace LinkedHashMap with a SoftReference LRUCache. Add Slide cache. 2013-05-06 12:22:03 -07:00
Moxie Marlinspike
a362c8755a Don't check for auto-initiation on group threads. 2013-05-06 08:40:56 -07:00
Moxie Marlinspike
0b172cebce Use DB sending type rather than in-memory hashtable. 2013-05-06 08:40:56 -07:00
Moxie Marlinspike
79c554fcc7 Fixed group in-thread notifications 2013-05-06 08:40:56 -07:00
Moxie Marlinspike
723fb4ffdd MMS and Group Messaging Improvements
1) Display the individual sender name in a group conversation.

2) Add an "address" column to MmsDatabase and keep FROM there.

3) Remove all blocking operations from MmsDatabase.Reader path.

4) Strip SMIL and other undisplayable parts from part count.

5) Fix places where messages weren't being correctly decrypted.
2013-05-06 08:40:55 -07:00
Moxie Marlinspike
2305a648fb Minor refactoring 2013-05-06 08:40:55 -07:00
Moxie Marlinspike
e80882b83b Locally encrypted messages no longer show as ciphertext notifications. 2013-05-06 08:40:55 -07:00
Moxie Marlinspike
7c47ea5cec Make MMS more asynchronous and consistent with new SMS types.
1) We now delay MMS notifications until a payload is received,
   or there's an error downloading the payload.  This makes
   group messages more consistent.

2) All "text" parts of an MMS are combined into a second text
   record, which is stored in the MMS row directly rather than
   as a distinct part.  This allows for immediate text loading,
   which means there's no chance a ConversationItem will resize.

   To do this, we need to include MMS in the big DB migration
   that's already staged for this application update.  It's also
   an "application-level" migration, because we need the MasterSecret
   to do it.

3) On conversation display, all image-based parts now have their
   thumbnails loaded asynchronously.  This allows for smooth-scrolling.
   The thumbnails are also scaled more accurately.
2013-05-06 08:40:55 -07:00
Moxie Marlinspike
dd0aecc811 First cut at group messaging refactor. 2013-05-06 08:40:55 -07:00
Moxie Marlinspike
83e260436b Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum.  There has always been
   a fairly clean insertion layer that handles encrypting message bodies,
   but the process of decrypting message bodies has always been less than
   ideal.  Here we introduce a "Reader" interface that will decrypt message
   bodies when appropriate and return objects that encapsulate record state.

   No more MessageDisplayHelper.  The MmsSmsDatabase interface is also more
   sane.

2) We finally rid ourselves of the technical debt associated with TextSecure's
   initial usage of the default SMS DB.  In that world, we weren't able to use
   anything other than the default "Inbox, Outbox, Sent" types to describe a
   message, and had to overload the message content itself with a set of
   local "prefixes" to describe what it was (encrypted, asymetric encrypted,
   remote encrypted, a key exchange, procssed key exchange), and so on.

   This includes a major schema update that transforms the "type" field into
   a bitmask that describes everything that used to be encoded in a prefix,
   and prefixes have been completely eliminated from the system.

   No more Prefix.java

3) Refactoring of the MultipartMessageHandler code.  It's less of a mess, and
   hopefully more clear as to what's going on.

The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-05-06 08:40:55 -07:00
Moxie Marlinspike
303d1acd45 Initial client support for GCM message send/receive 2013-05-06 08:40:55 -07:00
Moxie Marlinspike
2f39283da3 Initial GCM registration 2013-05-06 08:40:55 -07:00
Moxie Marlinspike
f2475491fe Fix for NPE on null encrypted MMS messages. 2013-04-23 14:49:32 -07:00
Lilia Markham
14d88f615c Sentence case settings
Let's be consistent and conformant with android style guide for settings
labels.
2013-04-08 20:16:16 -07:00
Lilia Markham
815613cfaa Reorganize settings menu
Mostly xml work, with one small hack to fix the sub menu themes, found
here: http://code.google.com/p/android/issues/detail?id=4611#c35
2013-04-08 20:16:12 -07:00
Lilia Markham
e3c5e837e1 Remove sign key exchange preference
Yet another setting that most users will never touch. Workaround for
those who would is to use a different identity key per device.

Let this be a sacrifice to the android settings design pattern gods.
2013-03-27 20:57:28 -07:00
Lilia Markham
40eca5e0f6 Remove whitespace tag preference
The vast majority of users will never uncheck this option. Those who
would can send an unencrypted untagged message through the system sms
app. It would then be stored locally in the clear, but it was already
transmitted in the clear and likely stored on the recipient's side in
the clear, so the security gains of locally encrypting are low, and
again, this seems an extremely rare edge case.

By android design pattern specs for the settings menu, we should kill
this preference.
2013-03-27 20:54:42 -07:00
Lilia Markham
eae499052b Remove MMS delivery report setting
No good reason to have this cluttering up the menu when it is disabled
and not implemented.
2013-03-27 20:00:54 -07:00
Lilia Markham
5cd044a6cc Swap settings and clear passphrase menu options
Android design pattern best practice recommends placing the settings
menu item below all other items because it's not frequently needed.

In that spirit, I've also moved the clear passphrase option to be first
since it is likely to be used more often than database import/export.
2013-03-27 19:42:14 -07:00
Moxie Marlinspike
c3e21f3f75 Bumping version to 0.9.8 2013-03-19 18:12:54 -07:00
Moxie Marlinspike
45b044f3e4 Updated language translations 2013-03-18 21:16:58 -07:00
Moxie Marlinspike
fcea8ebc3f Added Telenor Norway to APN Defaults 2013-03-17 11:38:44 -07:00
cavanm
8e2288205c Use APN defaults when no other APN information is available.
Provides an in-app source for APN info for use in the case that the
device store is unavailable and the user hasn't provided local
connection parameters.

Only covers T-Moble USA, AT&T, and Verizon right now. Only T-Mobile is
tested. Other carriers can be added and tested on an ongoing basis.
2013-03-17 11:31:17 -07:00
Moxie Marlinspike
fb21c09dbe Catch NPE thrown by APN provider. 2013-03-17 11:19:36 -07:00
Moxie Marlinspike
2d92b99fb3 Bumping version to 0.9.7 2013-03-15 09:27:07 -07:00
Moxie Marlinspike
09ce848b16 Remove default disabled tint from send button. 2013-03-15 07:47:09 -07:00
Moxie Marlinspike
5df88cc0a7 Scrub recipients for MMS messages so they'll be valid PLMN. 2013-03-14 15:59:28 -07:00
Moxie Marlinspike
0a769da9de Bumped version to 0.9.6 2013-03-14 10:10:40 -07:00
Moxie Marlinspike
4f8078c28a Updated language translations 2013-03-14 08:51:10 -07:00
Moxie Marlinspike
ecaaff50da Switch UA to Android default and added x-wap-profile header 2013-03-14 08:44:42 -07:00
Moxie Marlinspike
cdd6d59e6e Remove send button smart enable/disabled.
Temporarily remove this functionality, since it doesn't account for
attachments yet.
2013-03-13 17:45:32 -07:00
Jake McGinty
674cd68ebd Modern-style Android chat icons (incl. secure icon)
Make the send-button appearance more similar to the default Android
messenger application
2013-03-10 16:05:35 -07:00
Moxie Marlinspike
b05c840616 Fix for MMS send bug with an APN proxy. 2013-03-10 15:47:13 -07:00
Moxie Marlinspike
6687aa0911 Merge branch 'issue139' of https://github.com/liliakai/TextSecure into no_conversation_scroll 2013-03-10 14:54:32 -07:00
Moxie Marlinspike
58961fe0a8 Minor spelling correction. 2013-03-10 14:50:55 -07:00
Moxie Marlinspike
bb3777aa68 Fix for viewing group recipients without contact information. 2013-03-07 17:47:57 -08:00
Lilia Markham
5dabe1069d Avoid auto-scroll after deleting a message
See WhisperSystems/TextSecure#139

This fix involves setting transcriptMode to normal on conversation view,
which resolves the issue but comes with the side effect that if you
have scrolled away from the bottom of the list, new incoming messages
will not trigger auto-scroll as they arrive.
2013-03-05 01:33:55 -08:00
Moxie Marlinspike
07c59d969a Prompt user for APN details when missing.
If TextSecure is running on a device without APN details, we prompt
the user to manually specify them when the user goes to send an MMS
message.
2013-03-04 17:43:04 -08:00
Moxie Marlinspike
fa8208de33 Bumped version to 0.9.5 2013-03-03 22:56:53 -08:00
Moxie Marlinspike
9c4d973bef Updated language translations 2013-03-03 18:59:22 -08:00
Moxie Marlinspike
01fdb1115d We don't support unknown content lengths yet. 2013-03-03 18:50:13 -08:00
Moxie Marlinspike
2e55e9cdca Guard NPE 2013-03-03 18:49:55 -08:00
Moxie Marlinspike
6230abb524 Add synchronized access to cache 2013-03-03 18:49:39 -08:00
Moxie Marlinspike
ef6a5c69af Tweak MMS retrieval and submission.
1) Only attempt direct connect outside of MMS radio mode on CDMA.

2) Don't switch back to normal radio state if pending messages remain.
2013-03-03 18:44:58 -08:00
Moxie Marlinspike
27e039c4a6 Bumped version to 0.9.4 2013-03-03 18:44:04 -08:00
Moxie Marlinspike
48576dbb58 Catch mysterious SMS too large exception. 2013-02-26 22:57:09 -08:00
Moxie Marlinspike
5ca7b1080c Fix for concurrentmodificationexception on race condition. 2013-02-26 22:56:48 -08:00
Moxie Marlinspike
eb9b2ef318 Fix for NPE on null mms bytes. 2013-02-26 22:56:15 -08:00
Moxie Marlinspike
6bd0f35787 Sometimes querying the APN DB throws this exception as well. 2013-02-26 22:55:23 -08:00
Moxie Marlinspike
2397176d9e Search support in ConversationList for <3.0 devices.
Switch to the newly-introduced ActionBarSherlock SearchView.
2013-02-24 19:37:37 -08:00
Moxie Marlinspike
c7e6a2afeb Bump version to 0.9.3 2013-02-24 13:54:51 -08:00
Moxie Marlinspike
4730ef1324 Updated language translations. 2013-02-24 13:35:41 -08:00
Moxie Marlinspike
34822557a6 Catch exception triggered by bug in telephony provider during import. 2013-02-24 11:59:43 -08:00
Moxie Marlinspike
bac6b78b11 Clear passphrase field on invalid entry. 2013-02-21 14:47:18 -08:00
Moxie Marlinspike
5bf5b404a1 Fix for notification NPE on unknown sender. 2013-02-20 20:44:38 -08:00
Moxie Marlinspike
f73adfc8f5 Change MMS network request pattern.
Currently we're flipping the radio in "MMS" mode, and connecting through
any proxies specified in the APN.  This always work, or at least doesn't
seem to work on Sprint, since the configured mms proxy rejects proxy
requests.

Instead we try the following in this order:

1) Connect over normal data connection directly to MMSC.
2) Connect over MMS radio connection to MMSC.
3) Connect over MMS radio connection with any configured proxy to MMSC.

Hopefully this doesn't fuck up shit on other unknown networks.
2013-02-20 18:10:33 -08:00
Moxie Marlinspike
df05508a6f Switch to AndroidHttpClient and explicit targeting. 2013-02-20 10:25:53 -08:00
Moxie Marlinspike
1e2adadae2 Resource cleanup 2013-02-19 10:36:48 -08:00
Moxie Marlinspike
6c1572e0ec Layout touchup 2013-02-19 10:36:04 -08:00
Moxie Marlinspike
1ff4fd842c Pass on incoming messages until DB is imported. 2013-02-17 15:09:01 -08:00
Moxie Marlinspike
5eb04328d3 Improve passphrase and onboarding UI. Abstract out routing.
1) Update the create, prompt, and change passphrase activities.
   They are no longer dialog themed, and should look a little
   less ugly.

2) Update the import DB activity to be less ugly and more robust.

3) Abstract all of the state handling stuff out of
   ConversationListActivity.  This is now handled by RoutingActivity,
   which all launch intents move through.
2013-02-17 15:09:01 -08:00
Moxie Marlinspike
9e3da08d45 Bump version to 0.9.2 2013-02-14 20:50:29 -08:00
Moxie Marlinspike
0a7181670c Radio updates happen frequently on some phones, switch to dynamic. 2013-02-14 20:42:29 -08:00
Moxie Marlinspike
d0d85ea52c Fix for duplicate message bug. 2013-02-14 19:15:40 -08:00
Moxie Marlinspike
c38bcc72c8 Bumped version to 0.9.1 2013-02-12 21:45:36 -08:00
Moxie Marlinspike
114d4ae798 Updated support-v4 to r11, which fixes:
http://code.google.com/p/android/issues/detail?id=36502

(Can you believe that shit?)
2013-02-12 21:31:01 -08:00
Moxie Marlinspike
3fac2ae97e Bumped version to 0.9 2013-02-12 14:07:10 -08:00
Moxie Marlinspike
3d1ade7554 Update language translations. 2013-02-12 11:53:43 -08:00
Moxie Marlinspike
c2dcf7ae74 Refactor MasterSecret initialization, access, and timeout paths.
1) Consolidate all of the KeyCachingService interaction into a single
   mixin. Activities extend delegates which call through to the mixin.

2) Switch Activity increment/decrement triggers from onStop to onPause
   in order to account for some screen locks that don't stop activities.
2013-02-10 17:30:51 -08:00
Moxie Marlinspike
90280a62ae Poor man's styling. 2013-02-09 17:43:31 -08:00
Moxie Marlinspike
2277dbd572 Localize ok/cancel 2013-02-09 17:38:33 -08:00
Moxie Marlinspike
471ef16a5b Support for robust delivery.
1) If a message fails to be delivered, post a notification in the
   status bar if that thread is not active and visible.

2) If a message fails to be delivered because there is no service,
   keep retrying every time service becomes available again.
2013-02-09 15:17:55 -08:00
Moxie Marlinspike
71f43075a9 Distinguish unread threads with background color. 2013-02-09 10:03:38 -08:00
Moxie Marlinspike
0a8c62e0e3 Include incoming message body in notifications.
1) Refactor the master secret reset logic to properly interact with
   services.

2) Add support for "BigText" and "Inbox" style notifications.

3) Decrypt message bodies when unlocked, display 'encrypted' when
   locked.
2013-02-08 16:27:43 -08:00
Moxie Marlinspike
10865bc75f Update README to reflect Play Store location. 2013-02-07 12:05:36 -08:00
Moxie Marlinspike
c426ed728a Bumped version to 0.8.6 2013-02-06 16:57:42 -08:00
Moxie Marlinspike
d1d0f8afe5 Fix attachment icon for GB devices 2013-02-06 16:45:14 -08:00
Moxie Marlinspike
49ea135e37 Don't auto-set thread to read on send. 2013-02-06 16:40:09 -08:00
Moxie Marlinspike
8dad82323d Fix for missing format string params in Tibetan translation. 2013-02-06 16:08:50 -08:00
Moxie Marlinspike
295abf8da3 Updated translations 2013-02-06 15:46:29 -08:00
Moxie Marlinspike
a29120d911 Fix for IndexOutOfBoundException (race condition on Recipients resolution) 2013-02-04 22:09:17 -08:00
Moxie Marlinspike
b044a68168 Fix for mysterious 'anonymous sender' NPE. 2013-02-04 21:51:25 -08:00
Moxie Marlinspike
01a5c889b0 Export stray strings for localization. 2013-02-04 11:12:03 -08:00
Moxie Marlinspike
dcf73cd009 Fix for 'group message' regression. 2013-02-04 11:03:19 -08:00
Moxie Marlinspike
bf92de394b Add support for resuming compose drafts. 2013-02-04 00:13:07 -08:00
Moxie Marlinspike
209711ae40 Fix notification behavior.
1) Don't add a notification item to the notification bar if the thread the
   message is for is active and visible.

2) Only sound the notification ringtone at 1/4th volume if the thread the
   message is for is active and visible.

3) Auto-clear the notification in the notification bar when a thread becomes
   visible from a screen-off situation.

4) Make notification updates asynchronous.
2013-02-03 18:41:34 -08:00
Moxie Marlinspike
288e2b5572 Suppport receiving 'share' actions from other apps. 2013-02-02 20:37:40 -08:00
Moxie Marlinspike
6bdb0e2d66 Bump version to 0.8.5 2013-01-14 13:13:59 -08:00
Moxie Marlinspike
ebdeea1401 Updated language files from transifex 2013-01-14 12:20:32 -08:00
Moxie Marlinspike
232e7bba2d A conversation can't be trimmed to 0. 2013-01-14 12:10:57 -08:00
Moxie Marlinspike
fe43ef65ab Support for auto-deleting old messages beyond a certain conversation thread length. 2013-01-09 21:06:56 -08:00
Moxie Marlinspike
a185750bb7 Preserve ConversationList scroll state in between onPause/onResume. 2013-01-09 20:39:05 -08:00
Moxie Marlinspike
5cb02445e8 Add support for "delivery notifications." Currently SMS-only. 2013-01-06 21:38:36 -08:00
Moxie Marlinspike
118560cf0d Fix for DB creation and migration with new date schema changes. 2013-01-06 18:47:20 -08:00
Moxie Marlinspike
2204584d8f Improve locking and performance on asynchronous contact loading. 2013-01-06 15:46:26 -08:00
Moxie Marlinspike
25f75cb3d2 Change wording around local APN configuration preference. 2013-01-06 14:41:07 -08:00
Moxie Marlinspike
83f90ddd4e Display both sent and received time in message details.
1) We record time sent in SMS database (date_sent).

2) We record time received in MMS database (date_received).

3) We union this information correctly in MmsSmsDatabase.
2013-01-06 13:13:14 -08:00
Moxie Marlinspike
ead97953e8 Add proxy port option to local APN settings. 2013-01-05 15:48:29 -08:00
Moxie Marlinspike
5f16da8fca Bumping version to 0.8.4 2013-01-02 13:47:42 -08:00
Moxie Marlinspike
61b6d11911 Remove permission to fix bug on 2.3.X devices. 2013-01-02 13:42:56 -08:00
Moxie Marlinspike
68c29f283d Fall back to user-configured MMS params on SecurityException 2013-01-02 10:06:34 -08:00
Moxie Marlinspike
8e720e0ede Bumping version to 0.8.3 2013-01-01 15:42:02 -08:00
Moxie Marlinspike
abd7fc67da Fix NoClassDefFound errors on 2.2 devices. 2013-01-01 15:38:09 -08:00
Moxie Marlinspike
e8c6acdec9 Bumped version to 0.8.2 2013-01-01 13:04:17 -08:00
Moxie Marlinspike
b805c4db4e Fix for NPE on empty MMS PDU 2013-01-01 12:54:12 -08:00
Moxie Marlinspike
62cad05acb Updated language translations 2013-01-01 12:42:14 -08:00
Moxie Marlinspike
61d4192798 Refactor ContactPhotoFactory to handle changing local contact URIs. 2012-12-30 16:42:33 -08:00
Moxie Marlinspike
9b45e6068b Better asynchronous loading for Recipient information.
1) Switch back from AsyncTasks to an Executor and Futures.

2) Make the Executor operate LIFO.

3) Make the Executor thread a BACKGROUND_PRIORITY thread.
2012-12-27 12:00:14 -08:00
Moxie Marlinspike
9939830551 Refactor recipient access.
1) Refactor recipient class to support asynchronous loading operations.

2) Refactor recipient factory to simplify recipient access.

3) Consoliate everything into one recipient provider that is capable of
doing async lookups and intelligent caching.
2012-12-24 08:40:37 -08:00
Moxie Marlinspike
f685cb550b Collapse NewRecipientProvider into RecipientProvider 2012-12-12 03:56:38 -08:00
Moxie Marlinspike
54fad30f9f Add ability to specify APN information in TextSecure settings.
1) Add configuration options for APN information in TextSecure settings.

2) Fall back to TextSecure settings if system settings are unavailable
while sending/receiving MMS.

3) Catch sqlite exception when devices randomly don't have the same
APN db or table structure.
2012-12-08 16:49:57 -08:00
Moxie Marlinspike
10885fa8db Merge pull request #101 from charlesmunger/master
Merge SMS broadcast receiver permission.
2012-12-06 15:42:51 -08:00
Charles Munger
28326d1c10 Now requires permission for SMS broadcast reciever.
This should prevent other applications from sending spoofed SMS messages
via a broadcast intent.
2012-12-06 14:59:35 -08:00
Moxie Marlinspike
84a29df1ee Switch passphrase creation to async task. 2012-12-01 16:02:56 -08:00
Moxie Marlinspike
0e5ff9bdac Fix for occasional NPE 2012-12-01 16:02:55 -08:00
Moxie Marlinspike
575341704e Proper recipient bracket parsing 2012-12-01 16:02:55 -08:00
Moxie Marlinspike
fa5e993191 Weird NPE 2012-12-01 16:02:55 -08:00
Moxie Marlinspike
c83d57aa59 Merge pull request #94 from thoughtbox/Change-default-behaviour-when-receiving-"flash"-messages
Changes default behaviour for CLASS 0 messages
2012-11-24 19:25:53 -08:00
Tor Houghton
4ced1a0f18 Changes default behaviour for CLASS 0 messages
"Flash" messages are no longer handled by TS.

Sorry for the multiple pulls -- previous request had a cut+paste typo.
2012-11-24 14:29:31 +01:00
Moxie Marlinspike
1496688ba0 Bump version to 0.8.1 2012-11-20 21:26:02 -08:00
Moxie Marlinspike
01f5ec5ab8 Align date for GB devices. Compromise nice checkbox alignment. 2012-11-20 20:56:21 -08:00
Moxie Marlinspike
158cf53d2c Update translations 2012-11-20 20:54:07 -08:00
Moxie Marlinspike
9bf434cb3b The <= GB QuickContactBadge is ugly. Let's do something nicer for them.
Unfortunately GB is 50% of the TS userbase, best not to neglect them.
2012-11-20 20:14:30 -08:00
Moxie Marlinspike
80a6c65790 We need READ_CALL_LOG if targetSDK is > 15. What a drag. 2012-11-20 19:09:46 -08:00
Moxie Marlinspike
c66e221598 Signal that we don't want screenshots of unlocked activities. 2012-11-20 18:49:56 -08:00
Moxie Marlinspike
47c83d2747 When retrieving MMS, continue on with best-effort in absence of APNs. 2012-11-18 14:52:33 -08:00
Moxie Marlinspike
5050b43234 Merge pull request #86 from thoughtbox/Fix-for-'forward'-string-reference
Fix reference to "forward" prefix
2012-11-05 22:17:53 -08:00
Tor Houghton
e8ffce53fe Fix reference to "forward" prefix
Code was erroneously referencing the string ID, rather than the
contents of the string (sorry!).
2012-11-05 18:45:04 +01:00
Moxie Marlinspike
d8cd09d46b Bumped version to 0.8 2012-11-03 14:36:49 -07:00
Moxie Marlinspike
09dcb9ac66 Updated translation files from Transifex 2012-10-31 18:18:45 -07:00
Moxie Marlinspike
acffda1ab8 formatting 2012-10-31 18:03:09 -07:00
Moxie Marlinspike
6b18f66e19 disambiguate send 2012-10-31 18:00:59 -07:00
Moxie Marlinspike
f26dbb2f34 disambiguate 2012-10-31 17:56:39 -07:00
Moxie Marlinspike
93c0fffc31 We need to force plaintext on key exchange messages. 2012-10-29 20:53:04 -07:00
Moxie Marlinspike
c5ed820590 Create DB indexes for optimized queries. 2012-10-29 18:01:09 -07:00
Moxie Marlinspike
3a9908b40d formatting 2012-10-29 17:34:14 -07:00
Moxie Marlinspike
187ec95817 Add collating support for group SMS/MMS messages.
1) When sending an SMS or MMS to multiple recipients, only show one
ConversationItem, but provide statistics on the number of recipients
delivered to.

2) Still break up the messages for secure and insecure messages.
2012-10-29 16:51:42 -07:00
Moxie Marlinspike
3a8d29e279 Major reorganization of view/model interactions.
Mostly, the inheritance graph for MessageRecord/MmsMessageRecord was
all messed up, and each class was overloaded for things it shouldn't
have been.

1) Broke MessageRecord/MmsMessageRecord up into: DisplayRecord, ThreadRecord,
MessageRecord, SmsMessageRecord, NotificationMmsMessageRecord, and
MediaMmsMessageRecord.

2) Updated all the adapters/views to keep pace with that change.
2012-10-28 18:24:21 -07:00
Moxie Marlinspike
0b3e939ac8 Improve support for "me" contact.
1) Add >= ICS profile support (the system-supported "me" contact).

2) Improve <= Gingerbread support for me contact by auto-detecting
contacts that have the same number as the SIM card.

3) Tie in identity key import/export support to the "me" contact.

4) Don't display a "me" selection option in preference if it can
be auto-detected.

5) Refactor out the ContactAccessorNewApi back into the base class.
2012-10-22 19:17:08 -07:00
Moxie Marlinspike
c13a3a8181 Fix "Group Threads" so that messages are encrypted when possible.
1) Change the MessageSender logic so that individual SMS messages
are encrypted whenever there is a secure session, unless the UI
explicitly specifies otherwise.

2) Change the MMS logic so that messages to a recipient with a
secure session are all sent individually, instead of including
those recipients into the batch plaintext message.
2012-10-21 17:41:44 -07:00
Moxie Marlinspike
1bd260b981 Improve UI for group SMS ConversationActivity
1) Change title to indicate it's a group message, and specify
the number of recipients.

2) Add an ActionBar icon to display a list of the recipients.
2012-10-21 14:34:09 -07:00
Moxie Marlinspike
05ce6d6cac Added Play Store description to strings file (for translation). 2012-10-15 19:58:16 -07:00
Moxie Marlinspike
e29993e48f Bump version to 0.7.4 2012-10-15 19:56:12 -07:00
Moxie Marlinspike
f2aa393974 Updated completed language translations. 2012-10-15 18:31:15 -07:00
Moxie Marlinspike
2c82e7b343 Updated PDU processing code.
The code we use for PDU parsing and composing comes straight from
the Android framework, but it's an internal API, so we duplicate
the code here.  These changes represent updates that have been
made as of the JB release.
2012-10-13 10:33:56 -07:00
Moxie Marlinspike
7beb8e489b Merge pull request #76 from thoughtbox/Localisation-change
Support translation of 'FWD' prefix.
2012-10-12 19:22:36 -07:00
Tor Houghton
73bde7accd Localisation change
Localisation of the message prefix when forwarding a message (in
Norwegian, this would be "VS:" for instance).
2012-10-12 12:00:34 +02:00
Tor Houghton
192ffb4d2f Ignore .DS_Store 2012-10-12 11:55:43 +02:00
Moxie Marlinspike
82f8ba3584 Removed tabs 2012-09-30 19:56:29 -07:00
Moxie Marlinspike
030b39cd9c Updated attachment selection dialog.
1) Added nice-looking holo-themed graphics for each attachment type.

2) Removed old un-scaled graphics.

3) Stringified the attachment types.
2012-09-30 18:58:40 -07:00
Moxie Marlinspike
3cf77b6fd0 Display contact icons correctly in MMS ConversationItems 2012-09-30 12:28:03 -07:00
Moxie Marlinspike
cf9dc51f31 Initial fixes for MMS retrieval.
1) Parse the APN information based on what the ConnectionManager
tells us.

2) Accept email addresses as a valid Recipient format.
2012-09-30 11:46:45 -07:00
Moxie Marlinspike
59e7226183 Support ant signing builds 2012-09-29 16:14:13 -07:00
Moxie Marlinspike
f743af32de javac wants us to be more explicit 2012-09-28 16:11:11 -07:00
Moxie Marlinspike
090068ea66 Update version to 0.7.3 for repackaging. 2012-09-28 14:31:15 -07:00
1425 changed files with 153557 additions and 26708 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.ai binary

12
.gitignore vendored
View File

@@ -5,7 +5,17 @@ project.properties
bin/
gen/
.idea/
TextSecure.iml
*.iml
out
tests
lint.xml
local.properties
ant.properties
.DS_Store
build.log
build-log.xml
.gradle
build
signing.properties
library/lib/
library/obj/

7
.travis.yml Normal file
View File

@@ -0,0 +1,7 @@
language: android
android:
components:
- platform-tools
- build-tools-19.1.0
- android-19
- extra-android-m2repository

View File

@@ -1,6 +1,6 @@
[main]
host = https://www.transifex.com
lang_map = fr_CA:fr-rCA,pt_BR:pt-rBR,pt_PT:pt,zh_CN:zh-rCN,zh_HK:zh-rHK,zh_TW:zh-rTW,da_DK:da-rDK,de_DE:de,fr_FR:fr,es_ES:es,hu_HU:hu,sv_SE:sv-rSE
lang_map = fr_CA:fr-rCA,pt_BR:pt-rBR,pt_PT:pt,zh_CN:zh-rCN,zh_HK:zh-rHK,zh_TW:zh-rTW,da_DK:da-rDK,de_DE:de,tr_TR:tr,fr_FR:fr,es_ES:es,hu_HU:hu,sv_SE:sv-rSE,bg_BG:bg,el_GR:el,kn_IN:kn-rIN,cs_CZ:cs
[textsecure-official.master]

View File

@@ -1,128 +1,234 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.thoughtcrime.securesms"
android:versionCode="27"
android:versionName="0.7.2">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
xmlns:tools="http://schemas.android.com/tools"
package="org.thoughtcrime.securesms"
android:versionCode="84"
android:versionName="2.3.0">
<permission android:name="org.thoughtcrime.securesms.ACCESS_SECRETS"
android:label="Access to TextSecure Secrets"
android:protectionLevel="signature" />
<uses-permission android:name="org.thoughtcrime.securesms.ACCESS_SECRETS"></uses-permission>
<uses-permission android:name="android.permission.BROADCAST_WAP_PUSH"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_MMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
android:label="Access to TextSecure Secrets"
android:protectionLevel="signature" />
<activity android:name=".ConversationListActivity"
android:label="@string/app_name"
<uses-permission android:name="org.thoughtcrime.securesms.ACCESS_SECRETS"/>
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.WRITE_PROFILE"/>
<uses-permission android:name="android.permission.BROADCAST_WAP_PUSH"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="org.thoughtcrime.securesms.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="org.thoughtcrime.securesms.permission.C2D_MESSAGE" />
<application android:name=".ApplicationContext"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/TextSecure.LightTheme">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".RoutingActivity"
android:theme="@style/NoAnimation.Theme.BlackScreen"
android:launchMode="singleTask"
android:uiOptions="splitActionBarWhenNarrow"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="text/plain" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
<activity android:name=".RegistrationProblemsActivity"
android:theme="@style/TextSecure.Light.Dialog"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".CountrySelectionActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ImportExportActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".PromptMmsActivity"
android:label="Configure MMS Settings"
android:windowSoftInputMode="stateUnchanged"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".MmsPreferencesActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ShareActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:noHistory="true"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ConversationListActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ConversationActivity"
android:windowSoftInputMode="stateUnchanged"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".GroupCreateActivity"
android:windowSoftInputMode="stateVisible"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".DatabaseMigrationActivity"
android:theme="@style/NoAnimation.Theme.AppCompat.Light.DarkActionBar"
android:launchMode="singleTask"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".DatabaseUpgradeActivity"
android:theme="@style/NoAnimation.Theme.AppCompat.Light.DarkActionBar"
android:launchMode="singleTask"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".PassphraseCreateActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__create_passphrase"
android:launchMode="singleInstance"
android:windowSoftInputMode="stateUnchanged"
android:theme="@style/TextSecure.IntroTheme"
android:launchMode="singleTop"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".PassphrasePromptActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__enter_passphrase"
android:launchMode="singleInstance"
android:windowSoftInputMode="stateVisible"
android:launchMode="singleTop"
android:theme="@style/TextSecure.IntroTheme"
android:windowSoftInputMode="stateAlwaysVisible"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ContactSelectionActivity"
android:label="@string/AndroidManifest__select_contacts"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".NewConversationActivity"
android:label="@string/AndroidManifest__select_contacts"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".PushContactSelectionActivity"
android:label="@string/AndroidManifest__select_contacts"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".AutoInitiateActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:theme="@style/TextSecure.Light.Dialog"
android:label="@string/AndroidManifest__textsecure_detected"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ViewIdentityActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__public_identity_key"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".PassphraseChangeActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__change_passphrase"
android:launchMode="singleInstance"
<activity android:name=".ViewLocalIdentityActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".VerifyKeysActivity"
android:label="@string/AndroidManifest__verify_session"
<activity android:name=".PassphraseChangeActivity"
android:label="@string/AndroidManifest__change_passphrase"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".VerifyIdentityActivity"
android:label="@string/AndroidManifest__verify_identity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".SaveIdentityActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__save_identity"
android:windowSoftInputMode="stateVisible"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ReviewIdentitiesActivity"
android:label="@string/AndroidManifest__manage_identity_keys"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ReceiveKeyActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__complete_key_exchange"
<activity android:name=".ReceiveKeyActivity"
android:label="@string/AndroidManifest__complete_key_exchange"
android:theme="@style/TextSecure.Light.Dialog"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ApplicationPreferencesActivity"
<activity android:name=".ApplicationPreferencesActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".VerifyImportedIdentityActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__verify_imported_identity"
<activity android:name=".RegistrationActivity"
android:windowSoftInputMode="stateUnchanged"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".RegistrationProgressActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".LogSubmitActivity"
android:label="@string/AndroidManifest__log_submit"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".MediaPreviewActivity"
android:label="@string/AndroidManifest__media_preview"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".DummyActivity"
android:theme="@android:style/Theme.NoDisplay"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
android:excludeFromRecents="true"
android:alwaysRetainTaskState="false"
android:stateNotNeeded="true"
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true" />
<service android:enabled="true" android:name=".service.GcmRegistrationService"/>
<service android:enabled="true" android:name=".service.ApplicationMigrationService"/>
<service android:enabled="true" android:name=".service.KeyCachingService"/>
<service android:enabled="true" android:name=".service.SendReceiveService"/>
<service android:enabled="true" android:name=".service.RegistrationService"/>
<service android:enabled="true" android:name=".service.DirectoryRefreshService"/>
<service android:enabled="true" android:name=".service.PreKeyService"/>
<service android:name=".service.QuickResponseService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
<!-- <receiver android:name=".service.BootListener" -->
<!-- android:enabled="true" -->
@@ -132,34 +238,72 @@
<!-- </intent-filter>-->
<!-- </receiver>-->
<receiver android:name=".gcm.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="org.thoughtcrime.securesms" />
</intent-filter>
</receiver>
<receiver android:name=".service.SmsListener"
android:permission="android.permission.BROADCAST_SMS"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1001">
<action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
<intent-filter>
<action android:name="org.thoughtcrime.securesms.services.MESSAGE_SENT"></action>
<action android:name="android.provider.Telephony.SMS_DELIVER"/>
</intent-filter>
</receiver>
<receiver android:name=".service.SmsDeliveryListener"
android:exported="true">
<intent-filter>
<action android:name="org.thoughtcrime.securesms.services.MESSAGE_SENT"/>
</intent-filter>
</receiver>
<receiver android:name=".service.MmsListener"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="1001">
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED"></action>
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED"/>
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER"/>
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<provider android:name=".providers.PartProvider"
<receiver android:name=".notifications.MarkReadReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="org.thoughtcrime.securesms.notifications.CLEAR"/>
</intent-filter>
</receiver>
<provider android:name=".providers.PartProvider"
android:grantUriPermissions="true"
android:authorities="org.thoughtcrime.provider.securesms" />
<receiver android:name=".service.RegistrationNotifier"
android:exported="false">
<intent-filter>
<action android:name="org.thoughtcrime.securesms.REGISTRATION_EVENT" />
</intent-filter>
</receiver>
<receiver android:name=".service.DirectoryRefreshListener">
<intent-filter>
<action android:name="org.whispersystems.whisperpush.DIRECTORY_REFRESH"/>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="org.thoughtcrime.securesms.tests" android:label="Tests for My App" />
</manifest>

67
BUILDING.md Normal file
View File

@@ -0,0 +1,67 @@
Building TextSecure
=====================
Basics
------
TextSecure uses [Gradle](http://gradle.org) to build the project and to maintain
dependencies.
Building TextSecure
-------------------
The following steps should help you (re)build TextSecure from the command line.
1. Checkout the source somewhere on your filesystem with
git clone https://github.com/WhisperSystems/TextSecure.git
2. Make sure you have the [Android SDK](https://developer.android.com/sdk/index.html) installed somewhere on your system.
3. Ensure the "Android Support Repository" and "Android SDK Build-tools" are installed from the Android SDK manager.
4. Create a local.properties file at the root of your source checkout and add an sdk.dir entry to it.
sdk.dir=\<path to your sdk installation\>
5. Execute Gradle:
./gradlew build
Re-building native components
-----------------------------
Note: This step is optional; native components are contained as binaries (see [library/libs](library/libs)).
1. Ensure that the Android NDK is installed.
Execute ndk-build:
cd library
ndk-build
Afterwards, execute Gradle as above to re-create the APK.
Setting up a development environment
------------------------------------
[Android Studio](https://developer.android.com/sdk/installing/studio.html) is the recommended development environment.
1. Install Android Studio.
2. Make sure the "Android Support Repository" is installed in the Android Studio SDK.
3. Make sure the latest "Android SDK build-tools" is installed in the Android Studio SDK.
4. Create a new Android Studio project. from the Quickstart pannel (use File > Close Project to see it), choose "Checkout from Version Control" then "git".
5. Paste the URL for the TextSecure project when prompted (https://github.com/WhisperSystems/TextSecure.git).
6. Android studio should detect the presence of a project file and ask you whether to open it. Click "yes".
7. Default config options should be good enough.
8. Project initialisation and build should proceed.
Contributing code
-----------------
Code contributions should be sent via github as pull requests, from feature branches [as explained here](https://help.github.com/articles/using-pull-requests).
Mailing list
------------
Development discussion happens on the whispersystems mailing list.
[To join](https://lists.riseup.net/www/info/whispersystems)
Send emails to whispersystems@lists.riseup.net

View File

@@ -1,57 +1,73 @@
TextSecure
=================
# TextSecure [![Build Status](https://travis-ci.org/WhisperSystems/TextSecure.svg?branch=master)](https://travis-ci.org/WhisperSystems/TextSecure)
A secure text messaging application for Android.
TextSecure is a messaging app for easy private communicate with friends.
TextSecure is a replacement for the standard text messaging application, allowing you to send and receive text messages as normal. Additionally, TextSecure provides:
TextSecure can use either data (WiFi/3G/4G) or SMS to communicate securely, and all TextSecure
messages can also be encrypted locally on your device.
1. *Local Encryption* -- All text messages, regardless of destination, that are sent or received with TextSecure are stored in an encrypted database on your phone.
2. *Wire Encryption* -- When communicating with a recipient who is also using TextSecure, text messages are encrypted during transmission.
Currently available on the Play store.
Bug tracker
-----------
*[![Play Store Badge](https://developer.android.com/images/brand/en_app_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms)*
Have a bug? Please create an issue here on GitHub!
## Contributing Bug reports
We use GitHub for bug tracking. Please search the existing issues for your bug and create a new one if the issue is not yet tracked!
https://github.com/WhisperSystems/TextSecure/issues
## Contributing Translations
Interested in helping to translate TextSecure? Contribute here:
Documentation
-------------
https://www.transifex.com/projects/p/textsecure-official/
Looking for documentation? Check out the wiki!
## Contributing Code
Instructions on how to setup your development environment and build TextSecure can be found in [BUILDING.md](https://github.com/WhisperSystems/TextSecure/blob/master/BUILDING.md).
https://github.com/WhisperSystems/TextSecure/wiki
If you're new to the TextSecure codebase, we recommend going through our issues and picking out a simple bug to fix (check the "easy" label in our issues) in order to get yourself familiar.
Mailing list
------------
For larger changes and feature ideas, we ask that you propose it on the mailing list for a high-level discussion before implementation.
Have a question? Ask on our mailing list!
This repository is set up with [BitHub](https://whispersystems.org/blog/bithub/), so you can make money for committing to TextSecure. The current BitHub price for an accepted pull request is:
[![Current BitHub Price](https://bithub.herokuapp.com/v1/status/payment/commit/)](https://whispersystems.org/blog/bithub/)
## Contributing Ideas
Have something you want to say about Open Whisper Systems projects or want to be part of the conversation? Get involved in the mailing list!
whispersystems@lists.riseup.net
https://lists.riseup.net/www/info/whispersystems
Translation
------------
## Contributing Funds
[![Donate](https://coinbase.com/assets/buttons/donation_large-6ec72b1a9eec516944e50a22aca7db35.png)](https://whispersystems.org/blog/bithub/)
Interested in helping to translate TextSecure? Contribute here:
You can add funds to BitHub to directly help further development efforts.
https://www.transifex.com/projects/p/textsecure-official/
Help
====
## Support
For troubleshooting and questions, please visit our support center!
Cryptography Notice
------------
http://support.whispersystems.org/
This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software.
BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.
## Documentation
Looking for documentation? Check out the wiki!
https://github.com/WhisperSystems/TextSecure/wiki
# Legal things
## Cryptography Notice
This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software.
BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.
See <http://www.wassenaar.org/> for more information.
The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms.
The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms.
The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.
License
---------------------
## License
Copyright 2011 Whisper Systems
Copyright 2013-2014 Open Whisper Systems
Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html

View File

@@ -0,0 +1,118 @@
package org.thoughtcrime.securesms.database;
import android.test.InstrumentationTestCase;
import static org.fest.assertions.api.Assertions.assertThat;
public class CanonicalAddressDatabaseTest extends InstrumentationTestCase {
private static final String AMBIGUOUS_NUMBER = "222-3333";
private static final String SPECIFIC_NUMBER = "+49 444 222 3333";
private static final String EMAIL = "a@b.fom";
private static final String SIMILAR_EMAIL = "a@b.com";
private static final String GROUP = "__textsecure_group__!000111222333";
private static final String SIMILAR_GROUP = "__textsecure_group__!100111222333";
private static final String ALPHA = "T-Mobile";
private static final String SIMILAR_ALPHA = "T-Mobila";
private CanonicalAddressDatabase db;
public void setUp() throws Exception {
super.setUp();
this.db = CanonicalAddressDatabase.getInstance(getInstrumentation().getTargetContext());
}
public void tearDown() throws Exception {
}
/**
* Throw two equivalent numbers (one without locale info, one with full info) at the canonical
* address db and see that the caching and DB operations work properly in revealing the right
* addresses. This is run twice to ensure cache logic is hit.
*
* @throws Exception
*/
public void testNumberAddressUpdates() throws Exception {
final long id = db.getCanonicalAddressId(AMBIGUOUS_NUMBER);
assertThat(db.getAddressFromId(id)).isEqualTo(AMBIGUOUS_NUMBER);
assertThat(db.getCanonicalAddressId(SPECIFIC_NUMBER)).isEqualTo(id);
assertThat(db.getAddressFromId(id)).isEqualTo(SPECIFIC_NUMBER);
assertThat(db.getCanonicalAddressId(AMBIGUOUS_NUMBER)).isEqualTo(id);
assertThat(db.getCanonicalAddressId(AMBIGUOUS_NUMBER)).isEqualTo(id);
assertThat(db.getAddressFromId(id)).isEqualTo(AMBIGUOUS_NUMBER);
assertThat(db.getCanonicalAddressId(SPECIFIC_NUMBER)).isEqualTo(id);
assertThat(db.getAddressFromId(id)).isEqualTo(SPECIFIC_NUMBER);
assertThat(db.getCanonicalAddressId(AMBIGUOUS_NUMBER)).isEqualTo(id);
}
public void testSimilarNumbers() throws Exception {
assertThat(db.getCanonicalAddressId("This is a phone number 222-333-444"))
.isNotEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("222-333-444"))
.isNotEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("222-333-44"))
.isNotEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("222-333-4"))
.isNotEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("+49 222-333-4444"))
.isNotEqualTo(db.getCanonicalAddressId("+1 222-333-4444"));
assertThat(db.getCanonicalAddressId("1 222-333-4444"))
.isEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("1 (222) 333-4444"))
.isEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("+12223334444"))
.isEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("+1 (222) 333.4444"))
.isEqualTo(db.getCanonicalAddressId("222-333-4444"));
assertThat(db.getCanonicalAddressId("+49 (222) 333.4444"))
.isEqualTo(db.getCanonicalAddressId("222-333-4444"));
}
public void testEmailAddresses() throws Exception {
final long emailId = db.getCanonicalAddressId(EMAIL);
final long similarEmailId = db.getCanonicalAddressId(SIMILAR_EMAIL);
assertThat(emailId).isNotEqualTo(similarEmailId);
assertThat(db.getAddressFromId(emailId)).isEqualTo(EMAIL);
assertThat(db.getAddressFromId(similarEmailId)).isEqualTo(SIMILAR_EMAIL);
}
public void testGroups() throws Exception {
final long groupId = db.getCanonicalAddressId(GROUP);
final long similarGroupId = db.getCanonicalAddressId(SIMILAR_GROUP);
assertThat(groupId).isNotEqualTo(similarGroupId);
assertThat(db.getAddressFromId(groupId)).isEqualTo(GROUP);
assertThat(db.getAddressFromId(similarGroupId)).isEqualTo(SIMILAR_GROUP);
}
public void testAlpha() throws Exception {
final long id = db.getCanonicalAddressId(ALPHA);
final long similarId = db.getCanonicalAddressId(SIMILAR_ALPHA);
assertThat(id).isNotEqualTo(similarId);
assertThat(db.getAddressFromId(id)).isEqualTo(ALPHA);
assertThat(db.getAddressFromId(similarId)).isEqualTo(SIMILAR_ALPHA);
}
public void testIsNumber() throws Exception {
assertThat(CanonicalAddressDatabase.isNumberAddress("+495556666777")).isTrue();
assertThat(CanonicalAddressDatabase.isNumberAddress("(222) 333-4444")).isTrue();
assertThat(CanonicalAddressDatabase.isNumberAddress("1 (222) 333-4444")).isTrue();
assertThat(CanonicalAddressDatabase.isNumberAddress("T-Mobile123")).isTrue();
assertThat(CanonicalAddressDatabase.isNumberAddress("333-4444")).isTrue();
assertThat(CanonicalAddressDatabase.isNumberAddress("12345")).isTrue();
assertThat(CanonicalAddressDatabase.isNumberAddress("T-Mobile")).isFalse();
assertThat(CanonicalAddressDatabase.isNumberAddress("T-Mobile1")).isFalse();
assertThat(CanonicalAddressDatabase.isNumberAddress("Wherever bank")).isFalse();
assertThat(CanonicalAddressDatabase.isNumberAddress("__textsecure_group__!afafafafafaf")).isFalse();
assertThat(CanonicalAddressDatabase.isNumberAddress("email@domain.com")).isFalse();
}
}

View File

@@ -0,0 +1,153 @@
package org.thoughtcrime.securesms.jobs;
import android.test.AndroidTestCase;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.dependencies.AxolotlStorageModule;
import org.whispersystems.libaxolotl.ecc.Curve;
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
import org.whispersystems.textsecure.api.TextSecureAccountManager;
import org.whispersystems.textsecure.api.push.SignedPreKeyEntity;
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
public class CleanPreKeysJobTest extends AndroidTestCase {
public void testSignedPreKeyRotationNotRegistered() throws IOException, MasterSecretJob.RequirementNotMetException {
TextSecureAccountManager accountManager = mock(TextSecureAccountManager.class);
SignedPreKeyStore signedPreKeyStore = mock(SignedPreKeyStore.class);
MasterSecret masterSecret = mock(MasterSecret.class);
when(accountManager.getSignedPreKey()).thenReturn(null);
CleanPreKeysJob cleanPreKeysJob = new CleanPreKeysJob(getContext());
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(accountManager, signedPreKeyStore));
objectGraph.inject(cleanPreKeysJob);
cleanPreKeysJob.onRun(masterSecret);
verify(accountManager).getSignedPreKey();
verifyNoMoreInteractions(signedPreKeyStore);
}
public void testSignedPreKeyEviction() throws Exception {
SignedPreKeyStore signedPreKeyStore = mock(SignedPreKeyStore.class);
TextSecureAccountManager accountManager = mock(TextSecureAccountManager.class);
SignedPreKeyEntity currentSignedPreKeyEntity = mock(SignedPreKeyEntity.class);
MasterSecret masterSecret = mock(MasterSecret.class);
when(currentSignedPreKeyEntity.getKeyId()).thenReturn(3133);
when(accountManager.getSignedPreKey()).thenReturn(currentSignedPreKeyEntity);
final SignedPreKeyRecord currentRecord = new SignedPreKeyRecord(3133, System.currentTimeMillis(), Curve.generateKeyPair(), new byte[64]);
List<SignedPreKeyRecord> records = new LinkedList<SignedPreKeyRecord>() {{
add(new SignedPreKeyRecord(2, 11, Curve.generateKeyPair(), new byte[32]));
add(new SignedPreKeyRecord(4, System.currentTimeMillis() - 100, Curve.generateKeyPair(), new byte[64]));
add(currentRecord);
add(new SignedPreKeyRecord(3, System.currentTimeMillis() - 90, Curve.generateKeyPair(), new byte[64]));
add(new SignedPreKeyRecord(1, 10, Curve.generateKeyPair(), new byte[32]));
}};
when(signedPreKeyStore.loadSignedPreKeys()).thenReturn(records);
when(signedPreKeyStore.loadSignedPreKey(eq(3133))).thenReturn(currentRecord);
CleanPreKeysJob cleanPreKeysJob = new CleanPreKeysJob(getContext());
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(accountManager, signedPreKeyStore));
objectGraph.inject(cleanPreKeysJob);
cleanPreKeysJob.onRun(masterSecret);
verify(signedPreKeyStore).removeSignedPreKey(eq(1));
verify(signedPreKeyStore, times(1)).removeSignedPreKey(anyInt());
}
public void testSignedPreKeyNoEviction() throws Exception {
SignedPreKeyStore signedPreKeyStore = mock(SignedPreKeyStore.class);
TextSecureAccountManager accountManager = mock(TextSecureAccountManager.class);
SignedPreKeyEntity currentSignedPreKeyEntity = mock(SignedPreKeyEntity.class);
when(currentSignedPreKeyEntity.getKeyId()).thenReturn(3133);
when(accountManager.getSignedPreKey()).thenReturn(currentSignedPreKeyEntity);
final SignedPreKeyRecord currentRecord = new SignedPreKeyRecord(3133, System.currentTimeMillis(), Curve.generateKeyPair(), new byte[64]);
List<SignedPreKeyRecord> records = new LinkedList<SignedPreKeyRecord>() {{
add(currentRecord);
}};
when(signedPreKeyStore.loadSignedPreKeys()).thenReturn(records);
when(signedPreKeyStore.loadSignedPreKey(eq(3133))).thenReturn(currentRecord);
CleanPreKeysJob cleanPreKeysJob = new CleanPreKeysJob(getContext());
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(accountManager, signedPreKeyStore));
objectGraph.inject(cleanPreKeysJob);
verify(signedPreKeyStore, never()).removeSignedPreKey(anyInt());
}
public void testConnectionError() throws Exception {
SignedPreKeyStore signedPreKeyStore = mock(SignedPreKeyStore.class);
TextSecureAccountManager accountManager = mock(TextSecureAccountManager.class);
MasterSecret masterSecret = mock(MasterSecret.class);
when(accountManager.getSignedPreKey()).thenThrow(new PushNetworkException("Connectivity error!"));
CleanPreKeysJob cleanPreKeysJob = new CleanPreKeysJob(getContext());
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(accountManager, signedPreKeyStore));
objectGraph.inject(cleanPreKeysJob);
try {
cleanPreKeysJob.onRun(masterSecret);
throw new AssertionError("should have failed!");
} catch (IOException e) {
assertTrue(cleanPreKeysJob.onShouldRetry(e));
}
}
@Module(injects = {CleanPreKeysJob.class})
public static class TestModule {
private final TextSecureAccountManager accountManager;
private final SignedPreKeyStore signedPreKeyStore;
private TestModule(TextSecureAccountManager accountManager, SignedPreKeyStore signedPreKeyStore) {
this.accountManager = accountManager;
this.signedPreKeyStore = signedPreKeyStore;
}
@Provides TextSecureAccountManager provideTextSecureAccountManager() {
return accountManager;
}
@Provides
AxolotlStorageModule.SignedPreKeyStoreFactory provideSignedPreKeyStore() {
return new AxolotlStorageModule.SignedPreKeyStoreFactory() {
@Override
public SignedPreKeyStore create(MasterSecret masterSecret) {
return signedPreKeyStore;
}
};
}
}
}

View File

@@ -0,0 +1,101 @@
package org.thoughtcrime.securesms.jobs;
import android.test.AndroidTestCase;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.whispersystems.textsecure.api.TextSecureMessageSender;
import org.whispersystems.textsecure.api.push.PushAddress;
import org.whispersystems.textsecure.api.push.exceptions.NotFoundException;
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
import java.io.IOException;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.thoughtcrime.securesms.dependencies.TextSecureCommunicationModule.TextSecureMessageSenderFactory;
public class DeliveryReceiptJobTest extends AndroidTestCase {
public void testDelivery() throws IOException {
TextSecureMessageSender textSecureMessageSender = mock(TextSecureMessageSender.class);
long timestamp = System.currentTimeMillis();
DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(getContext(),
"+14152222222",
timestamp, "foo");
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(textSecureMessageSender));
objectGraph.inject(deliveryReceiptJob);
deliveryReceiptJob.onRun();
ArgumentCaptor<PushAddress> captor = ArgumentCaptor.forClass(PushAddress.class);
verify(textSecureMessageSender).sendDeliveryReceipt(captor.capture(), eq(timestamp));
assertTrue(captor.getValue().getRelay().equals("foo"));
assertTrue(captor.getValue().getNumber().equals("+14152222222"));
}
public void testNetworkError() throws IOException {
TextSecureMessageSender textSecureMessageSender = mock(TextSecureMessageSender.class);
long timestamp = System.currentTimeMillis();
Mockito.doThrow(new PushNetworkException("network error"))
.when(textSecureMessageSender)
.sendDeliveryReceipt(any(PushAddress.class), eq(timestamp));
DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(getContext(),
"+14152222222",
timestamp, "foo");
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(textSecureMessageSender));
objectGraph.inject(deliveryReceiptJob);
try {
deliveryReceiptJob.onRun();
throw new AssertionError();
} catch (IOException e) {
assertTrue(deliveryReceiptJob.onShouldRetry(e));
}
Mockito.doThrow(new NotFoundException("not found"))
.when(textSecureMessageSender)
.sendDeliveryReceipt(any(PushAddress.class), eq(timestamp));
try {
deliveryReceiptJob.onRun();
throw new AssertionError();
} catch (IOException e) {
assertFalse(deliveryReceiptJob.onShouldRetry(e));
}
}
@Module(injects = DeliveryReceiptJob.class)
public static class TestModule {
private final TextSecureMessageSender textSecureMessageSender;
public TestModule(TextSecureMessageSender textSecureMessageSender) {
this.textSecureMessageSender = textSecureMessageSender;
}
@Provides TextSecureMessageSenderFactory provideTextSecureMessageSenderFactory() {
return new TextSecureMessageSenderFactory() {
@Override
public TextSecureMessageSender create(MasterSecret masterSecret) {
return textSecureMessageSender;
}
};
}
}
}

View File

@@ -0,0 +1,33 @@
package org.thoughtcrime.securesms.util;
import android.test.AndroidTestCase;
import junit.framework.AssertionFailedError;
import org.whispersystems.textsecure.api.util.InvalidNumberException;
import org.whispersystems.textsecure.api.util.PhoneNumberFormatter;
import static org.fest.assertions.api.Assertions.assertThat;
public class PhoneNumberFormatterTest extends AndroidTestCase {
private static final String LOCAL_NUMBER = "+15555555555";
public void testFormatNumberE164() throws Exception, InvalidNumberException {
assertThat(PhoneNumberFormatter.formatNumber("(555) 555-5555", LOCAL_NUMBER)).isEqualTo(LOCAL_NUMBER);
assertThat(PhoneNumberFormatter.formatNumber("555-5555", LOCAL_NUMBER)).isEqualTo(LOCAL_NUMBER);
assertThat(PhoneNumberFormatter.formatNumber("(123) 555-5555", LOCAL_NUMBER)).isNotEqualTo(LOCAL_NUMBER);
}
public void testFormatNumberEmail() throws Exception {
try {
PhoneNumberFormatter.formatNumber("person@domain.com", LOCAL_NUMBER);
throw new AssertionFailedError("should have thrown on email");
} catch (InvalidNumberException ine) {
// success
}
}
@Override
public void setUp() throws Exception {
super.setUp();
}
}

View File

@@ -0,0 +1,9 @@
package org.thoughtcrime.securesms.util;
import android.test.AndroidTestCase;
import static org.fest.assertions.api.Assertions.assertThat;
public class UtilTest extends AndroidTestCase {
}

View File

@@ -0,0 +1,28 @@
package org.thoughtcrime.securesms.service;
import android.content.Intent;
import android.test.InstrumentationTestCase;
import static org.fest.assertions.api.Assertions.*;
public class MmsReceiverTest extends InstrumentationTestCase {
private MmsReceiver mmsReceiver;
public void setUp() throws Exception {
super.setUp();
mmsReceiver = new MmsReceiver(getInstrumentation().getContext());
}
public void tearDown() throws Exception {
}
public void testProcessMalformedData() throws Exception {
Intent intent = new Intent();
intent.setAction(SendReceiveService.RECEIVE_MMS_ACTION);
intent.putExtra("data", new byte[]{0x00});
mmsReceiver.process(null, intent);
}
}

2
apntool/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.db
*.db.gz

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

81
apntool/apntool.py Normal file
View File

@@ -0,0 +1,81 @@
import sys
import argparse
import sqlite3
import gzip
from progressbar import ProgressBar, Counter, Timer
from lxml import etree
parser = argparse.ArgumentParser(prog='apntool', description="""Process Android's apn xml files and drop them into an easily
queryable SQLite db. Tested up to version 9 of their APN file.""")
parser.add_argument('-v', '--version', action='version', version='%(prog)s v1.0')
parser.add_argument('-i', '--input', help='the xml file to parse', default='apns.xml', required=False)
parser.add_argument('-o', '--output', help='the sqlite db output file', default='apns.db', required=False)
parser.add_argument('--quiet', help='do not show progress or verbose instructions', action='store_true', required=False)
parser.add_argument('--no-gzip', help="do not gzip after creation", action='store_true', required=False)
args = parser.parse_args()
try:
connection = sqlite3.connect(args.output)
cursor = connection.cursor()
cursor.execute('SELECT SQLITE_VERSION()')
version = cursor.fetchone()
if not args.quiet:
print("SQLite version: %s" % version)
print("Opening %s" % args.input)
cursor.execute("PRAGMA legacy_file_format=ON")
cursor.execute("PRAGMA journal_mode=DELETE")
cursor.execute("PRAGMA page_size=32768")
cursor.execute("VACUUM")
cursor.execute("DROP TABLE IF EXISTS apns")
cursor.execute("""CREATE TABLE apns(_id INTEGER PRIMARY KEY, mccmnc TEXT, mcc TEXT, mnc TEXT, carrier TEXT, apn TEXT,
mmsc TEXT, port INTEGER, type TEXT, protocol TEXT, bearer TEXT, roaming_protocol TEXT,
carrier_enabled INTEGER, mmsproxy TEXT, mmsport INTEGER, proxy TEXT, mvno_match_data TEXT,
mvno_type TEXT, authtype INTEGER, user TEXT, password TEXT, server TEXT)""")
apns = etree.parse(args.input)
root = apns.getroot()
pbar = ProgressBar(widgets=['Processed: ', Counter(), ' apns (', Timer(), ')'], maxval=len(list(root))).start() if not args.quiet else None
count = 0
for apn in root.iter("apn"):
if apn.get("mmsc") == None:
continue
sqlvars = ["?" for x in apn.attrib.keys()] + ["?"]
mccmnc = "%s%s" % (apn.get("mcc"), apn.get("mnc"))
values = [apn.get(attrib) for attrib in apn.attrib.keys()] + [mccmnc]
keys = apn.attrib.keys() + ["mccmnc"]
cursor.execute("SELECT 1 FROM apns WHERE mccmnc = ? AND apn = ?", [mccmnc, apn.get("apn")])
if cursor.fetchone() == None:
statement = "INSERT INTO apns (%s) VALUES (%s)" % (", ".join(keys), ", ".join(sqlvars))
cursor.execute(statement, values)
count += 1
if not args.quiet:
pbar.update(count)
if not args.quiet:
pbar.finish()
connection.commit()
print("Successfully written to %s" % args.output)
if not args.no_gzip:
gzipped_file = "%s.gz" % (args.output,)
with open(args.output, 'rb') as orig:
with gzip.open(gzipped_file, 'wb') as gzipped:
gzipped.writelines(orig)
print("Successfully gzipped to %s" % gzipped_file)
if not args.quiet:
print("\nTo include this in the distribution, copy it to the project's assets/databases/ directory.")
print("If you support API 10 or lower, you must use the gzipped version to avoid corruption.")
except sqlite3.Error, e:
if connection:
connection.rollback()
print("Error: %s" % e.args[0])
sys.exit(1)
finally:
if connection:
connection.close()

3
apntool/requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
argparse>=1.2.1
lxml>=3.3.3
progressbar-latest>=2.4

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
artwork/ic_group_photo.psd Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
artwork/ic_send.psd Normal file

Binary file not shown.

Binary file not shown.

31036
artwork/icon.ai Normal file

File diff suppressed because one or more lines are too long

BIN
artwork/icon_gigantic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Binary file not shown.

BIN
assets/databases/apns.db Normal file

Binary file not shown.

BIN
assets/emoji_0_wrapped.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 KiB

BIN
assets/emoji_1_wrapped.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

BIN
assets/emoji_2_wrapped.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

BIN
assets/emoji_3_wrapped.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

BIN
assets/emoji_4_wrapped.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

163
build.gradle Normal file
View File

@@ -0,0 +1,163 @@
buildscript {
repositories {
maven {
url "https://repo1.maven.org/maven2"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.2'
classpath files('libs/gradle-witness.jar')
}
}
apply plugin: 'com.android.application'
apply from: 'strip_play_services.gradle'
apply plugin: 'witness'
repositories {
maven {
url "https://repo1.maven.org/maven2"
}
maven {
url "https://raw.github.com/whispersystems/maven/master/preferencefragment/releases/"
}
maven {
url "https://raw.github.com/whispersystems/maven/master/gson/releases/"
}
maven {
url "https://raw.github.com/whispersystems/maven/master/smil/releases/"
}
}
dependencies {
compile 'se.emilsjolander:stickylistheaders:2.2.0'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'org.w3c:smil:1.0.0'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile ('com.android.support:support-v4-preferencefragment:1.0.0@aar'){
exclude module: 'support-v4'
}
compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
androidTestCompile 'com.squareup:fest-android:1.0.8'
androidTestCompile 'com.google.dexmaker:dexmaker:1.1'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.1'
compile project(':libtextsecure')
compile project(':jobqueue')
}
dependencyVerification {
verify = [
'se.emilsjolander:stickylistheaders:89146b46c96fea0e40200474a2625cda10fe94891e4128f53cdb42375091b9b6',
'com.google.android.gms:play-services:32e7d1834a1cf8fa4b17e8d359db580c286e26c1eefbf84fdb9996eac8d74919',
'com.astuetz:pagerslidingtabstrip:f1641396732c7132a7abb837e482e5ee2b0ebb8d10813fc52bbaec2c15c184c2',
'org.w3c:smil:085dc40f2bb249651578bfa07499fd08b16ad0886dbe2c4078586a408da62f9b',
'org.apache.httpcomponents:httpclient-android:6f56466a9bd0d42934b90bfbfe9977a8b654c058bf44a12bdc2877c4e1f033f1',
'com.github.chrisbanes.photoview:library:8b5344e206f125e7ba9d684008f36c4992d03853c57e5814125f88496126e3cc',
'com.android.support:appcompat-v7:b760fd3d0b0b0547a1bcef9031b40939f31049ba955f04c8fdc5aa09a25d19e9',
'com.madgag.spongycastle:prov:b8c3fec3a59aac1aa04ccf4dad7179351e54ef7672f53f508151b614c131398a',
'com.android.support:support-v4-preferencefragment:5470f5872514a6226fa1fc6f4e000991f38805691c534cf0bd2778911fc773ad',
'com.squareup.dagger:dagger:789aca24537022e49f91fc6444078d9de8f1dd99e1bfb090f18491b186967883',
'com.madgag.spongycastle:core:8d6240b974b0aca4d3da9c7dd44d42339d8a374358aca5fc98e50a995764511f',
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
'com.google.protobuf:protobuf-java:e0c1c64575c005601725e7c6a02cebf9e1285e888f756b2a1d73ffa8d725cc74',
'com.googlecode.libphonenumber:libphonenumber:eba17eae81dd622ea89a00a3a8c025b2f25d342e0d9644c5b62e16f15687c3ab',
'org.whispersystems:gson:08f4f7498455d1539c9233e5aac18e9b1805815ef29221572996508eb512fe51',
'com.android.support:support-v4:126a4c291f41f75f3fff4968e9d397bc8454cdff4d8f994cbe0524e3bad76e72',
'com.android.support:support-annotations:7e37f00e3d932c4d9a6dd84604a99133bb5ae7d81cbd1aee69861fcf2f91e5e9',
]
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
android {
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled false
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
androidTest {
java.srcDirs = ['androidTest/java']
resources.srcDirs = ['androidTest/java']
aidl.srcDirs = ['androidTest/java']
renderscript.srcDirs = ['androidTest/java']
}
}
}
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
lintOptions {
abortOnError false
}
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
def Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()){
props.load(new FileInputStream(propFile))
if (props !=null &&
props.containsKey('STORE_FILE') &&
props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') &&
props.containsKey('KEY_PASSWORD'))
{
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
}else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}

30
contributing.md Normal file
View File

@@ -0,0 +1,30 @@
##Translations
Please do not submit issues or pull requests for translation fixes. Anyone can update the translations in [Transifex](https://www.transifex.com/projects/p/textsecure-official/). Please submit your corrections there.
## Submitting useful bug reports
1. Search our issues first to make sure this is not a duplicate.
1. Read the [Submitting useful bug reports guide](https://github.com/WhisperSystems/TextSecure/wiki/Submitting-useful-bug-reports) before posting a bug.
## Development Ideology
Truths which we believe to be self-evident:
1. **The answer is not more options.** If you feel compelled to add a
preference that's exposed to the user, it's very possible you've made
a wrong turn somewhere.
1. **The user doesn't know what a key is.** We need to minimize the points
at which a user is exposed to this sort of terminology as extremely as
possible.
1. **There are no power users.** The idea that some users "understand"
concepts better than others has proven to be, for the most part, false.
If anything, "power users" are more dangerous than the rest, and we
should avoid exposing dangerous functionality to them.
1. **If it's "like PGP," it's wrong.** PGP is our spirit guide for what
not to do.
1. **It's an asynchronous world.** Be wary of anything that is
anti-asynchronous: ACKs, protocol confirmations, or any protocol-level
"advisory" message.
1. **There is no such thing as time.** Protocol ideas that require synchronized
clocks are doomed to failure.

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
#Fri Nov 14 10:44:11 MSK 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip

164
gradlew vendored Executable file
View File

@@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
jobqueue/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

238
jobqueue/README.md Normal file
View File

@@ -0,0 +1,238 @@
# JobManager
An Android library that facilitates scheduling persistent jobs which are executed when their
prerequisites have been met. Similar to Path's android-priority-queue.
## The JobManager Way
Android apps often need to perform blocking operations. A messaging app might need to make REST
API calls over a network, send SMS messages, download attachments, and interact with a database.
The standard Android way to do these things are with Services, AsyncTasks, or a dedicated Thread.
However, some of an app's operations might need to wait until certain dependencies are available
(such as a network connection), and some of the operations might need to be durable (complete even if the
app restarts before they have a chance to run). The standard Android way can result in
a lot of retry logic, timers for monitoring dependencies, and one-off code for making operations
durable.
By contrast, the JobManager way allows operations to be broken up into Jobs. A Job represents a
unit of work to be done, the prerequisites that need to be met (such as network access) before the
work can execute, and the characteristics of the job (such as durable persistence).
Applications construct a `JobManager` at initialization time:
```
public class ApplicationContext extends Application {
private JobManager jobManager;
@Override
public void onCreate() {
initializeJobManager();
}
private void initializeJobManager() {
this.jobManager = JobManager.newBuilder(this)
.withName("SampleJobManager")
.withConsumerThreads(5)
.build();
}
...
}
```
This constructs a new `JobManager` with 5 consumer threads dedicated to executing Jobs. A
Job looks like this:
```
public class SampleJob extends Job {
public SampleJob() {
super(JobParameters.newBuilder().create());
}
@Override
public onAdded() {
// Called after the Job has been added to the queue.
}
@Override
public void onRun() {
// Here's where we execute our work.
Log.w("SampleJob", "Hello, world!");
}
@Override
public void onCanceled() {
// This would be called if the job had failed.
}
@Override
public boolean onShouldRetry(Exception exception) {
// Called if onRun() had thrown an exception to determine whether
// onRun() should be called again.
return false;
}
}
```
A Job is scheduled simply by adding it to the JobManager:
```
this.jobManager.add(new SampleJob());
```
## Persistence
To create durable Jobs, the JobManager needs to be given an interface responsible for serializing
and deserializing Job objects. A `JavaJobSerializer` is included with JobManager that uses Java
Serialization, but you can specify your own serializer if you wish:
```
public class ApplicationContext extends Application {
private JobManager jobManager;
@Override
public void onCreate() {
initializeJobManager();
}
private void initializeJobManager() {
this.jobManager = JobManager.newBuilder(this)
.withName("SampleJobManager")
.withConsumerThreads(5)
.withJobSerializer(new JavaJobSerializer())
.build();
}
...
}
```
The Job simply needs to declare itself as durable when constructed:
```
public class SampleJob extends Job {
public SampleJob() {
super(JobParameters.newBuilder()
.withPersistence()
.create());
}
...
```
Persistent jobs that are enqueued will be serialized to disk to ensure that they run even if
the App restarts first. A Job's onAdded() method is called after the commit to disk is complete.
## Requirements
A Job might have certain requirements that need to be met before it can run. A requirement is
represented by the `Requirement` interface. Each `Requirement` must also have a corresponding
`RequirementProvider` that is registered with the JobManager.
A `Requirement` tells you whether it is present when queried, while a `RequirementProvider`
broadcasts to a listener when a Requirement's status might have changed. `Requirement` is attached
to Job, while `RequirementProvider` is attached to JobManager.
One common `Requirement` a `Job` might depend on is the presence of network connectivity.
A `NetworkRequirement` is bundled with JobManager:
```
public class ApplicationContext extends Application {
private JobManager jobManager;
@Override
public void onCreate() {
initializeJobManager();
}
private void initializeJobManager() {
this.jobManager = JobManager.newBuilder(this)
.withName("SampleJobManager")
.withConsumerThreads(5)
.withJobSerializer(new JavaJobSerializer())
.withRequirementProviders(new NetworkRequirementProvider(this))
.build();
}
...
}
```
The Job declares itself as having a `Requirement` when constructed:
```
public class SampleJob extends Job {
public SampleJob(Context context) {
super(JobParameters.newBuilder()
.withPersistence()
.withRequirement(new NetworkRequirement(context))
.create());
}
...
```
## Dependency Injection
It is possible that Jobs (and Requirements) might require dependency injection. A simple example
is `Context`, which many Jobs might require, but can't be persisted to disk for durable Jobs. Or
maybe Jobs require more complex DI through libraries such as Dagger.
JobManager has an extremely primitive DI mechanism strictly for injecting `Context` objects into
Jobs and Requirements after they're deserialized, and includes support for plugging in more complex
DI systems such as Dagger.
The JobManager `Context` injection works by having your `Job` and/or `Requirement` implement the
`ContextDependent` interface. `Job`s and `Requirement`s implementing that interface will get a
`setContext(Context context)` call immediately after the persistent `Job` or `Requirement` is
deserialized.
To plugin a more complex DI mechanism, simply pass an instance of the `DependencyInjector` interface
to the `JobManager`:
```
public class ApplicationContext extends Application implements DependencyInjector {
private JobManager jobManager;
@Override
public void onCreate() {
initializeJobManager();
}
private void initializeJobManager() {
this.jobManager = JobManager.newBuilder(this)
.withName("SampleJobManager")
.withConsumerThreads(5)
.withJobSerializer(new JavaJobSerializer())
.withRequirementProviders(new NetworkRequirementProvider(this))
.withDependencyInjector(this)
.build();
}
@Override
public void injectDependencies(Object object) {
// And here we do our DI magic.
}
...
}
```
`injectDependencies(Object object)` will be called for a `Job` before the job's `onAdded()` method
is called, or after a persistent job is deserialized.

19
jobqueue/build.gradle Normal file
View File

@@ -0,0 +1,19 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
applicationId "org.whispersystems.jobqueue"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

View File

@@ -0,0 +1,225 @@
package org.whispersystems.jobqueue;
import android.test.AndroidTestCase;
import org.whispersystems.jobqueue.jobs.PersistentTestJob;
import org.whispersystems.jobqueue.jobs.RequirementDeferringTestJob;
import org.whispersystems.jobqueue.jobs.RequirementTestJob;
import org.whispersystems.jobqueue.jobs.TestJob;
import org.whispersystems.jobqueue.persistence.JavaJobSerializer;
import org.whispersystems.jobqueue.requirements.RequirementProvider;
import org.whispersystems.jobqueue.util.MockRequirement;
import org.whispersystems.jobqueue.util.MockRequirementProvider;
import org.whispersystems.jobqueue.util.PersistentMockRequirement;
import org.whispersystems.jobqueue.util.PersistentRequirement;
import org.whispersystems.jobqueue.util.PersistentResult;
import org.whispersystems.jobqueue.util.RunnableThrowable;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class JobManagerTest extends AndroidTestCase {
public void testTransientJobExecution() throws InterruptedException {
TestJob testJob = new TestJob();
JobManager jobManager = JobManager.newBuilder(getContext())
.withName("transient-test")
.withConsumerThreads(1)
.build();
jobManager.add(testJob);
assertTrue(testJob.isAdded());
assertTrue(testJob.isRan());
}
public void testTransientRequirementJobExecution() throws InterruptedException {
MockRequirementProvider provider = new MockRequirementProvider();
MockRequirement requirement = new MockRequirement(false);
TestJob testJob = new RequirementTestJob(requirement);
JobManager jobManager = JobManager.newBuilder(getContext())
.withName("transient-requirement-test")
.withRequirementProviders(provider)
.withConsumerThreads(1)
.build();
jobManager.add(testJob);
assertTrue(testJob.isAdded());
assertTrue(!testJob.isRan());
requirement.setPresent(true);
provider.fireChange();
assertTrue(testJob.isRan());
}
public void testTransientRequirementDeferringJobExecution() throws InterruptedException {
final Object lock = new Object();
RunnableThrowable waitRunnable = new RunnableThrowable() {
public Boolean shouldThrow = false;
@Override
public void run() throws Exception {
try {
synchronized (lock) {
lock.wait();
if (shouldThrow) {
throw new Exception();
}
}
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
@Override
public void shouldThrow(Boolean value) {
shouldThrow = value;
}
};
MockRequirementProvider provider = new MockRequirementProvider();
MockRequirement requirement = new MockRequirement(false);
RequirementDeferringTestJob testJob = new RequirementDeferringTestJob(requirement, 5, waitRunnable);
JobManager jobManager = JobManager.newBuilder(getContext())
.withName("transient-requirement-test")
.withRequirementProviders(provider)
.withConsumerThreads(1)
.build();
jobManager.add(testJob);
waitRunnable.shouldThrow(true);
requirement.setPresent(true);
provider.fireChange();
assertTrue(testJob.isRan());
assertTrue(!testJob.isFinished());
synchronized (lock) { lock.notifyAll(); }
assertTrue(!testJob.isFinished());
requirement.setPresent(false);
provider.fireChange();
assertTrue(!testJob.isFinished());
synchronized (lock) { lock.notifyAll(); }
assertTrue(!testJob.isFinished());
waitRunnable.shouldThrow(false);
requirement.setPresent(true);
provider.fireChange();
assertTrue(!testJob.isFinished());
synchronized (lock) { lock.notifyAll(); }
assertTrue(testJob.isFinished());
}
public void testPersistentJobExecuton() throws InterruptedException {
PersistentMockRequirement requirement = new PersistentMockRequirement();
PersistentTestJob testJob = new PersistentTestJob(requirement);
JobManager jobManager = JobManager.newBuilder(getContext())
.withName("persistent-requirement-test3")
.withJobSerializer(new JavaJobSerializer())
.withConsumerThreads(1)
.build();
PersistentResult.getInstance().reset();
PersistentRequirement.getInstance().setPresent(false);
jobManager.add(testJob);
assertTrue(PersistentResult.getInstance().isAdded());
assertTrue(!PersistentResult.getInstance().isRan());
PersistentRequirement.getInstance().setPresent(true);
jobManager = JobManager.newBuilder(getContext())
.withName("persistent-requirement-test3")
.withJobSerializer(new JavaJobSerializer())
.withConsumerThreads(1)
.build();
assertTrue(PersistentResult.getInstance().isRan());
}
public void testEncryptedJobExecuton() throws InterruptedException {
EncryptionKeys keys = new EncryptionKeys(new byte[30]);
PersistentMockRequirement requirement = new PersistentMockRequirement();
PersistentTestJob testJob = new PersistentTestJob(requirement, keys);
JobManager jobManager = JobManager.newBuilder(getContext())
.withName("persistent-requirement-test4")
.withJobSerializer(new JavaJobSerializer())
.withConsumerThreads(1)
.build();
jobManager.setEncryptionKeys(keys);
PersistentResult.getInstance().reset();
PersistentRequirement.getInstance().setPresent(false);
jobManager.add(testJob);
assertTrue(PersistentResult.getInstance().isAdded());
assertTrue(!PersistentResult.getInstance().isRan());
PersistentRequirement.getInstance().setPresent(true);
jobManager = JobManager.newBuilder(getContext())
.withName("persistent-requirement-test4")
.withJobSerializer(new JavaJobSerializer())
.withConsumerThreads(1)
.build();
assertTrue(!PersistentResult.getInstance().isRan());
jobManager.setEncryptionKeys(keys);
assertTrue(PersistentResult.getInstance().isRan());
}
public void testGroupIdExecution() throws InterruptedException {
final Object lock = new Object();
Runnable waitRunnable = new Runnable() {
@Override
public void run() {
try {
synchronized (lock) {
lock.wait();
}
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
};
TestJob testJobOne = new TestJob(JobParameters.newBuilder().withGroupId("foo").create(), waitRunnable);
TestJob testJobTwo = new TestJob(JobParameters.newBuilder().withGroupId("foo").create());
TestJob testJobThree = new TestJob(JobParameters.newBuilder().withGroupId("bar").create());
JobManager jobManager = JobManager.newBuilder(getContext())
.withName("transient-test")
.withConsumerThreads(3)
.build();
jobManager.add(testJobOne);
jobManager.add(testJobTwo);
jobManager.add(testJobThree);
assertTrue(testJobOne.isAdded());
assertTrue(testJobTwo.isAdded());
assertTrue(testJobThree.isAdded());
assertTrue(testJobOne.isRan());
assertTrue(!testJobTwo.isRan());
assertTrue(testJobThree.isRan());
synchronized (lock) {
lock.notifyAll();
}
assertTrue(testJobTwo.isRan());
}
}

View File

@@ -0,0 +1,39 @@
package org.whispersystems.jobqueue.jobs;
import org.whispersystems.jobqueue.EncryptionKeys;
import org.whispersystems.jobqueue.Job;
import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.Requirement;
import org.whispersystems.jobqueue.util.PersistentResult;
public class PersistentTestJob extends Job {
public PersistentTestJob(Requirement requirement) {
super(JobParameters.newBuilder().withRequirement(requirement).withPersistence().create());
}
public PersistentTestJob(Requirement requirement, EncryptionKeys keys) {
super(JobParameters.newBuilder().withRequirement(requirement).withPersistence().withEncryption(keys).create());
}
@Override
public void onAdded() {
PersistentResult.getInstance().onAdded();
}
@Override
public void onRun() throws Exception {
PersistentResult.getInstance().onRun();
}
@Override
public void onCanceled() {
PersistentResult.getInstance().onCanceled();
}
@Override
public boolean onShouldRetry(Exception exception) {
return false;
}
}

View File

@@ -0,0 +1,51 @@
package org.whispersystems.jobqueue.jobs;
import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.Requirement;
import org.whispersystems.jobqueue.util.RunnableThrowable;
import java.io.IOException;
public class RequirementDeferringTestJob extends TestJob {
private final Object FINISHED_LOCK = new Object();
private boolean finished = false;
private RunnableThrowable runnable;
public RequirementDeferringTestJob(Requirement requirement, int retryCount, RunnableThrowable runnable) {
super(JobParameters.newBuilder().withRequirement(requirement).withRetryCount(retryCount).create());
this.runnable = runnable;
}
@Override
public void onRun() throws Exception {
synchronized (RAN_LOCK) {
this.ran = true;
}
if (runnable != null)
runnable.run();
synchronized (FINISHED_LOCK) {
this.finished = true;
}
}
@Override
public boolean onShouldRetry(Exception exception) {
if (exception instanceof Exception) {
return true;
}
return false;
}
public boolean isFinished() throws InterruptedException {
synchronized (FINISHED_LOCK) {
if (!finished) FINISHED_LOCK.wait(1000);
return finished;
}
}
}

View File

@@ -0,0 +1,12 @@
package org.whispersystems.jobqueue.jobs;
import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.Requirement;
public class RequirementTestJob extends TestJob {
public RequirementTestJob(Requirement requirement) {
super(JobParameters.newBuilder().withRequirement(requirement).create());
}
}

View File

@@ -0,0 +1,81 @@
package org.whispersystems.jobqueue.jobs;
import org.whispersystems.jobqueue.Job;
import org.whispersystems.jobqueue.JobParameters;
public class TestJob extends Job {
private final Object ADDED_LOCK = new Object();
protected final Object RAN_LOCK = new Object();
private final Object CANCELED_LOCK = new Object();
private boolean added = false;
protected boolean ran = false;
private boolean canceled = false;
private Runnable runnable;
public TestJob() {
this(JobParameters.newBuilder().create());
}
public TestJob(JobParameters parameters) {
super(parameters);
}
public TestJob(JobParameters parameters, Runnable runnable) {
super(parameters);
this.runnable = runnable;
}
@Override
public void onAdded() {
synchronized (ADDED_LOCK) {
this.added = true;
this.ADDED_LOCK.notifyAll();
}
}
@Override
public void onRun() throws Exception {
synchronized (RAN_LOCK) {
this.ran = true;
}
if (runnable != null)
runnable.run();
}
@Override
public void onCanceled() {
synchronized (CANCELED_LOCK) {
this.canceled = true;
}
}
@Override
public boolean onShouldRetry(Exception exception) {
return false;
}
public boolean isAdded() throws InterruptedException {
synchronized (ADDED_LOCK) {
if (!added) ADDED_LOCK.wait(1000);
return added;
}
}
public boolean isRan() throws InterruptedException {
synchronized (RAN_LOCK) {
if (!ran) RAN_LOCK.wait(1000);
return ran;
}
}
public boolean isCanceled() throws InterruptedException {
synchronized (CANCELED_LOCK) {
if (!canceled) CANCELED_LOCK.wait(1000);
return canceled;
}
}
}

View File

@@ -0,0 +1,23 @@
package org.whispersystems.jobqueue.util;
import org.whispersystems.jobqueue.requirements.Requirement;
import java.util.concurrent.atomic.AtomicBoolean;
public class MockRequirement implements Requirement {
private AtomicBoolean present;
public MockRequirement(boolean present) {
this.present = new AtomicBoolean(present);
}
public void setPresent(boolean present) {
this.present.set(present);
}
@Override
public boolean isPresent() {
return present.get();
}
}

View File

@@ -0,0 +1,23 @@
package org.whispersystems.jobqueue.util;
import org.whispersystems.jobqueue.requirements.RequirementListener;
import org.whispersystems.jobqueue.requirements.RequirementProvider;
public class MockRequirementProvider implements RequirementProvider {
private RequirementListener listener;
public void fireChange() {
listener.onRequirementStatusChanged();
}
@Override
public void setListener(RequirementListener listener) {
this.listener = listener;
}
@Override
public String getName() {
return "mock-requirement-provider";
}
}

View File

@@ -0,0 +1,10 @@
package org.whispersystems.jobqueue.util;
import org.whispersystems.jobqueue.requirements.Requirement;
public class PersistentMockRequirement implements Requirement {
@Override
public boolean isPresent() {
return PersistentRequirement.getInstance().isPresent();
}
}

View File

@@ -0,0 +1,22 @@
package org.whispersystems.jobqueue.util;
import java.util.concurrent.atomic.AtomicBoolean;
public class PersistentRequirement {
private AtomicBoolean present = new AtomicBoolean(false);
private static final PersistentRequirement instance = new PersistentRequirement();
public static PersistentRequirement getInstance() {
return instance;
}
public void setPresent(boolean present) {
this.present.set(present);
}
public boolean isPresent() {
return present.get();
}
}

View File

@@ -0,0 +1,73 @@
package org.whispersystems.jobqueue.util;
public class PersistentResult {
private final Object ADDED_LOCK = new Object();
private final Object RAN_LOCK = new Object();
private final Object CANCELED_LOCK = new Object();
private boolean added = false;
private boolean ran = false;
private boolean canceled = false;
private static final PersistentResult instance = new PersistentResult();
public static PersistentResult getInstance() {
return instance;
}
public void onAdded() {
synchronized (ADDED_LOCK) {
this.added = true;
this.ADDED_LOCK.notifyAll();
}
}
public void onRun() throws Exception {
synchronized (RAN_LOCK) {
this.ran = true;
}
}
public void onCanceled() {
synchronized (CANCELED_LOCK) {
this.canceled = true;
}
}
public boolean isAdded() throws InterruptedException {
synchronized (ADDED_LOCK) {
if (!added) ADDED_LOCK.wait(1000);
return added;
}
}
public boolean isRan() throws InterruptedException {
synchronized (RAN_LOCK) {
if (!ran) RAN_LOCK.wait(1000);
return ran;
}
}
public boolean isCanceled() throws InterruptedException {
synchronized (CANCELED_LOCK) {
if (!canceled) CANCELED_LOCK.wait(1000);
return canceled;
}
}
public void reset() {
synchronized (ADDED_LOCK) {
this.added = false;
}
synchronized (RAN_LOCK) {
this.ran = false;
}
synchronized (CANCELED_LOCK) {
this.canceled = false;
}
}
}

View File

@@ -0,0 +1,8 @@
package org.whispersystems.jobqueue.util;
public interface RunnableThrowable {
public void run() throws Exception;
public void shouldThrow(Boolean value);
}

View File

@@ -0,0 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.whispersystems.jobqueue">
<application />
</manifest>

View File

@@ -1,6 +1,6 @@
/**
* Copyright (C) 2011 Whisper Systems
*
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -10,27 +10,21 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.crypto;
package org.whispersystems.jobqueue;
public class PublicKeyAndVersion {
public class EncryptionKeys {
public IdentityKey identityKey;
public final PublicKey key;
public final int version;
public final int maxVersion;
public PublicKeyAndVersion(PublicKey key, int version, int maxVersion) {
this.key = key;
this.version = version;
this.maxVersion = maxVersion;
private transient final byte[] encoded;
public EncryptionKeys(byte[] encoded) {
this.encoded = encoded;
}
public PublicKeyAndVersion(PublicKey key, IdentityKey identityKey, int version, int maxVersion) {
this(key, version, maxVersion);
this.identityKey = identityKey;
public byte[] getEncoded() {
return encoded;
}
}

View File

@@ -0,0 +1,116 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue;
import org.whispersystems.jobqueue.requirements.Requirement;
import java.io.Serializable;
import java.util.List;
/**
* An abstract class representing a unit of work that can be scheduled with
* the JobManager. This should be extended to implement tasks.
*/
public abstract class Job implements Serializable {
private final JobParameters parameters;
private transient long persistentId;
private transient int runIteration;
public Job(JobParameters parameters) {
this.parameters = parameters;
}
public List<Requirement> getRequirements() {
return parameters.getRequirements();
}
public boolean isRequirementsMet() {
for (Requirement requirement : parameters.getRequirements()) {
if (!requirement.isPresent()) return false;
}
return true;
}
public String getGroupId() {
return parameters.getGroupId();
}
public boolean isPersistent() {
return parameters.isPersistent();
}
public EncryptionKeys getEncryptionKeys() {
return parameters.getEncryptionKeys();
}
public void setEncryptionKeys(EncryptionKeys keys) {
parameters.setEncryptionKeys(keys);
}
public int getRetryCount() {
return parameters.getRetryCount();
}
public void setPersistentId(long persistentId) {
this.persistentId = persistentId;
}
public long getPersistentId() {
return persistentId;
}
public int getRunIteration() {
return runIteration;
}
public void setRunIteration(int runIteration) {
this.runIteration = runIteration;
}
/**
* Called after a job has been added to the JobManager queue. If it's a persistent job,
* the state has been persisted to disk before this method is called.
*/
public abstract void onAdded();
/**
* Called to actually execute the job.
* @throws Exception
*/
public abstract void onRun() throws Exception;
/**
* If onRun() throws an exception, this method will be called to determine whether the
* job should be retried.
*
* @param exception The exception onRun() threw.
* @return true if onRun() should be called again, false otherwise.
*/
public abstract boolean onShouldRetry(Exception exception);
/**
* Called if a job fails to run (onShouldRetry returned false, or the number of retries exceeded
* the job's configured retry count.
*/
public abstract void onCanceled();
}

View File

@@ -0,0 +1,90 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue;
import android.util.Log;
import org.whispersystems.jobqueue.persistence.PersistentStorage;
class JobConsumer extends Thread {
private static final String TAG = JobConsumer.class.getSimpleName();
enum JobResult {
SUCCESS,
FAILURE,
DEFERRED
}
private final JobQueue jobQueue;
private final PersistentStorage persistentStorage;
public JobConsumer(String name, JobQueue jobQueue, PersistentStorage persistentStorage) {
super(name);
this.jobQueue = jobQueue;
this.persistentStorage = persistentStorage;
}
@Override
public void run() {
while (true) {
Job job = jobQueue.getNext();
JobResult result = runJob(job);
if (result == JobResult.DEFERRED) {
jobQueue.push(job);
} else {
if (result == JobResult.FAILURE) {
job.onCanceled();
}
if (job.isPersistent()) {
persistentStorage.remove(job.getPersistentId());
}
}
if (job.getGroupId() != null) {
jobQueue.setGroupIdAvailable(job.getGroupId());
}
}
}
private JobResult runJob(Job job) {
int retryCount = job.getRetryCount();
int runIteration = job.getRunIteration();
for (;runIteration<retryCount;runIteration++) {
try {
job.onRun();
return JobResult.SUCCESS;
} catch (Exception exception) {
Log.w(TAG, exception);
if (exception instanceof RuntimeException) {
throw (RuntimeException)exception;
} else if (!job.onShouldRetry(exception)) {
return JobResult.FAILURE;
} else if (!job.isRequirementsMet()) {
job.setRunIteration(runIteration+1);
return JobResult.DEFERRED;
}
}
}
return JobResult.FAILURE;
}
}

View File

@@ -0,0 +1,253 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue;
import android.content.Context;
import android.util.Log;
import org.whispersystems.jobqueue.dependencies.DependencyInjector;
import org.whispersystems.jobqueue.persistence.JobSerializer;
import org.whispersystems.jobqueue.persistence.PersistentStorage;
import org.whispersystems.jobqueue.requirements.RequirementListener;
import org.whispersystems.jobqueue.requirements.RequirementProvider;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* A JobManager allows you to enqueue {@link org.whispersystems.jobqueue.Job} tasks
* that are executed once a Job's {@link org.whispersystems.jobqueue.requirements.Requirement}s
* are met.
*/
public class JobManager implements RequirementListener {
private final JobQueue jobQueue = new JobQueue();
private final Executor eventExecutor = Executors.newSingleThreadExecutor();
private final AtomicBoolean hasLoadedEncrypted = new AtomicBoolean(false);
private final PersistentStorage persistentStorage;
private final List<RequirementProvider> requirementProviders;
private final DependencyInjector dependencyInjector;
private JobManager(Context context, String name,
List<RequirementProvider> requirementProviders,
DependencyInjector dependencyInjector,
JobSerializer jobSerializer, int consumers)
{
this.persistentStorage = new PersistentStorage(context, name, jobSerializer, dependencyInjector);
this.requirementProviders = requirementProviders;
this.dependencyInjector = dependencyInjector;
eventExecutor.execute(new LoadTask(null));
if (requirementProviders != null && !requirementProviders.isEmpty()) {
for (RequirementProvider provider : requirementProviders) {
provider.setListener(this);
}
}
for (int i=0;i<consumers;i++) {
new JobConsumer("JobConsumer-" + i, jobQueue, persistentStorage).start();
}
}
/**
* @param context An Android {@link android.content.Context}.
* @return a {@link org.whispersystems.jobqueue.JobManager.Builder} used to construct a JobManager.
*/
public static Builder newBuilder(Context context) {
return new Builder(context);
}
/**
* Returns a {@link org.whispersystems.jobqueue.requirements.RequirementProvider} registered with
* the JobManager by name.
*
* @param name The name of the registered {@link org.whispersystems.jobqueue.requirements.RequirementProvider}
* @return The RequirementProvider, or null if no provider is registered with that name.
*/
public RequirementProvider getRequirementProvider(String name) {
for (RequirementProvider provider : requirementProviders) {
if (provider.getName().equals(name)) {
return provider;
}
}
return null;
}
public void setEncryptionKeys(EncryptionKeys keys) {
if (hasLoadedEncrypted.compareAndSet(false, true)) {
eventExecutor.execute(new LoadTask(keys));
}
}
/**
* Queue a {@link org.whispersystems.jobqueue.Job} to be executed.
*
* @param job The Job to be executed.
*/
public void add(final Job job) {
eventExecutor.execute(new Runnable() {
@Override
public void run() {
try {
if (job.isPersistent()) {
persistentStorage.store(job);
}
if (dependencyInjector != null) {
dependencyInjector.injectDependencies(job);
}
job.onAdded();
jobQueue.add(job);
} catch (IOException e) {
Log.w("JobManager", e);
job.onCanceled();
}
}
});
}
@Override
public void onRequirementStatusChanged() {
eventExecutor.execute(new Runnable() {
@Override
public void run() {
jobQueue.onRequirementStatusChanged();
}
});
}
private class LoadTask implements Runnable {
private final EncryptionKeys keys;
public LoadTask(EncryptionKeys keys) {
this.keys = keys;
}
@Override
public void run() {
List<Job> pendingJobs;
if (keys == null) pendingJobs = persistentStorage.getAllUnencrypted();
else pendingJobs = persistentStorage.getAllEncrypted(keys);
jobQueue.addAll(pendingJobs);
}
}
public static class Builder {
private final Context context;
private String name;
private List<RequirementProvider> requirementProviders;
private DependencyInjector dependencyInjector;
private JobSerializer jobSerializer;
private int consumerThreads;
Builder(Context context) {
this.context = context;
this.consumerThreads = 5;
}
/**
* A name for the {@link org.whispersystems.jobqueue.JobManager}. This is a required parameter,
* and is linked to the durable queue used by persistent jobs.
*
* @param name The name for the JobManager to build.
* @return The builder.
*/
public Builder withName(String name) {
this.name = name;
return this;
}
/**
* The {@link org.whispersystems.jobqueue.requirements.RequirementProvider}s to register with this
* JobManager. Optional. Each {@link org.whispersystems.jobqueue.requirements.Requirement} an
* enqueued Job depends on should have a matching RequirementProvider registered here.
*
* @param requirementProviders The RequirementProviders
* @return The builder.
*/
public Builder withRequirementProviders(RequirementProvider... requirementProviders) {
this.requirementProviders = Arrays.asList(requirementProviders);
return this;
}
/**
* The {@link org.whispersystems.jobqueue.dependencies.DependencyInjector} to use for injecting
* dependencies into {@link Job}s. Optional. Injection occurs just before a Job's onAdded() callback, or
* after deserializing a persistent job.
*
* @param dependencyInjector The injector to use.
* @return The builder.
*/
public Builder withDependencyInjector(DependencyInjector dependencyInjector) {
this.dependencyInjector = dependencyInjector;
return this;
}
/**
* The {@link org.whispersystems.jobqueue.persistence.JobSerializer} to use for persistent Jobs.
* Required if persistent Jobs are used.
*
* @param jobSerializer The serializer to use.
* @return The builder.
*/
public Builder withJobSerializer(JobSerializer jobSerializer) {
this.jobSerializer = jobSerializer;
return this;
}
/**
* Set the number of threads dedicated to consuming Jobs from the queue and executing them.
*
* @param consumerThreads The number of threads.
* @return The builder.
*/
public Builder withConsumerThreads(int consumerThreads) {
this.consumerThreads = consumerThreads;
return this;
}
/**
* @return A constructed JobManager.
*/
public JobManager build() {
if (name == null) {
throw new IllegalArgumentException("You must specify a name!");
}
if (requirementProviders == null) {
requirementProviders = new LinkedList<>();
}
return new JobManager(context, name, requirementProviders,
dependencyInjector, jobSerializer,
consumerThreads);
}
}
}

View File

@@ -0,0 +1,149 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue;
import org.whispersystems.jobqueue.requirements.Requirement;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
/**
* The set of parameters that describe a {@link org.whispersystems.jobqueue.Job}.
*/
public class JobParameters implements Serializable {
private transient EncryptionKeys encryptionKeys;
private final List<Requirement> requirements;
private final boolean isPersistent;
private final int retryCount;
private final String groupId;
private JobParameters(List<Requirement> requirements,
boolean isPersistent, String groupId,
EncryptionKeys encryptionKeys,
int retryCount)
{
this.requirements = requirements;
this.isPersistent = isPersistent;
this.groupId = groupId;
this.encryptionKeys = encryptionKeys;
this.retryCount = retryCount;
}
public List<Requirement> getRequirements() {
return requirements;
}
public boolean isPersistent() {
return isPersistent;
}
public EncryptionKeys getEncryptionKeys() {
return encryptionKeys;
}
public void setEncryptionKeys(EncryptionKeys encryptionKeys) {
this.encryptionKeys = encryptionKeys;
}
public int getRetryCount() {
return retryCount;
}
/**
* @return a builder used to construct JobParameters.
*/
public static Builder newBuilder() {
return new Builder();
}
public String getGroupId() {
return groupId;
}
public static class Builder {
private List<Requirement> requirements = new LinkedList<>();
private boolean isPersistent = false;
private EncryptionKeys encryptionKeys = null;
private int retryCount = 100;
private String groupId = null;
/**
* Specify a {@link org.whispersystems.jobqueue.requirements.Requirement }that must be met
* before the Job is executed. May be called multiple times to register multiple requirements.
* @param requirement The Requirement that must be met.
* @return the builder.
*/
public Builder withRequirement(Requirement requirement) {
this.requirements.add(requirement);
return this;
}
/**
* Specify that the Job should be durably persisted to disk, so that it remains in the queue
* across application restarts.
* @return The builder.
*/
public Builder withPersistence() {
this.isPersistent = true;
return this;
}
/**
* Specify that the job should use encryption when durably persisted to disk.
* @param encryptionKeys The keys to encrypt the serialized job with before persisting.
* @return the builder.
*/
public Builder withEncryption(EncryptionKeys encryptionKeys) {
this.encryptionKeys = encryptionKeys;
return this;
}
/**
* Specify how many times the job should be retried if execution fails but onShouldRetry() returns
* true.
*
* @param retryCount The number of times the job should be retried.
* @return the builder.
*/
public Builder withRetryCount(int retryCount) {
this.retryCount = retryCount;
return this;
}
/**
* Specify a groupId the job should belong to. Jobs with the same groupId are guaranteed to be
* executed serially.
*
* @param groupId The job's groupId.
* @return the builder.
*/
public Builder withGroupId(String groupId) {
this.groupId = groupId;
return this;
}
/**
* @return the JobParameters instance that describes a Job.
*/
public JobParameters create() {
return new JobParameters(requirements, isPersistent, groupId, encryptionKeys, retryCount);
}
}
}

View File

@@ -0,0 +1,95 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
class JobQueue {
private final Set<String> activeGroupIds = new HashSet<>();
private final LinkedList<Job> jobQueue = new LinkedList<>();
synchronized void onRequirementStatusChanged() {
notifyAll();
}
synchronized void add(Job job) {
jobQueue.add(job);
notifyAll();
}
synchronized void addAll(List<Job> jobs) {
jobQueue.addAll(jobs);
notifyAll();
}
synchronized void push(Job job) {
jobQueue.push(job);
}
synchronized Job getNext() {
try {
Job nextAvailableJob;
while ((nextAvailableJob = getNextAvailableJob()) == null) {
wait();
}
return nextAvailableJob;
} catch (InterruptedException e) {
throw new AssertionError(e);
}
}
synchronized void setGroupIdAvailable(String groupId) {
if (groupId != null) {
activeGroupIds.remove(groupId);
notifyAll();
}
}
private Job getNextAvailableJob() {
if (jobQueue.isEmpty()) return null;
ListIterator<Job> iterator = jobQueue.listIterator();
while (iterator.hasNext()) {
Job job = iterator.next();
if (job.isRequirementsMet() && isGroupIdAvailable(job.getGroupId())) {
iterator.remove();
setGroupIdUnavailable(job.getGroupId());
return job;
}
}
return null;
}
private boolean isGroupIdAvailable(String groupId) {
return groupId == null || !activeGroupIds.contains(groupId);
}
private void setGroupIdUnavailable(String groupId) {
if (groupId != null) {
activeGroupIds.add(groupId);
}
}
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.dependencies;
import android.content.Context;
/**
* Any Job or Requirement that depends on {@link android.content.Context} can implement this
* interface to receive a Context after being deserialized.
*/
public interface ContextDependent {
public void setContext(Context context);
}

View File

@@ -0,0 +1,24 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.dependencies;
/**
* Interface responsible for injecting dependencies into Jobs.
*/
public interface DependencyInjector {
public void injectDependencies(Object object);
}

View File

@@ -0,0 +1,58 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.persistence;
import android.util.Base64;
import org.whispersystems.jobqueue.EncryptionKeys;
import org.whispersystems.jobqueue.Job;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* An implementation of {@link org.whispersystems.jobqueue.persistence.JobSerializer} that uses
* Java Serialization.
*/
public class JavaJobSerializer implements JobSerializer {
public JavaJobSerializer() {}
@Override
public String serialize(Job job) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(job);
return Base64.encodeToString(baos.toByteArray(), Base64.NO_WRAP);
}
@Override
public Job deserialize(EncryptionKeys keys, boolean encrypted, String serialized) throws IOException {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(serialized, Base64.NO_WRAP));
ObjectInputStream ois = new ObjectInputStream(bais);
return (Job)ois.readObject();
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
}
}

View File

@@ -0,0 +1,47 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.persistence;
import org.whispersystems.jobqueue.EncryptionKeys;
import org.whispersystems.jobqueue.Job;
import java.io.IOException;
/**
* A JobSerializer is responsible for serializing and deserializing persistent jobs.
*/
public interface JobSerializer {
/**
* Serialize a job object into a string.
* @param job The Job to serialize.
* @return The serialized Job.
* @throws IOException if serialization fails.
*/
public String serialize(Job job) throws IOException;
/**
* Deserialize a String into a Job.
* @param keys Optional encryption keys that could have been used.
* @param encrypted True if the job was encrypted using the encryption keys.
* @param serialized The serialized Job.
* @return The deserialized Job.
* @throws IOException If the Job deserialization fails.
*/
public Job deserialize(EncryptionKeys keys, boolean encrypted, String serialized) throws IOException;
}

View File

@@ -0,0 +1,152 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.persistence;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import org.whispersystems.jobqueue.EncryptionKeys;
import org.whispersystems.jobqueue.Job;
import org.whispersystems.jobqueue.dependencies.ContextDependent;
import org.whispersystems.jobqueue.dependencies.DependencyInjector;
import org.whispersystems.jobqueue.requirements.Requirement;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
public class PersistentStorage {
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "queue";
private static final String ID = "_id";
private static final String ITEM = "item";
private static final String ENCRYPTED = "encrypted";
private static final String DATABASE_CREATE = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s TEXT NOT NULL, %s INTEGER DEFAULT 0);",
TABLE_NAME, ID, ITEM, ENCRYPTED);
private final Context context;
private final DatabaseHelper databaseHelper;
private final JobSerializer jobSerializer;
private final DependencyInjector dependencyInjector;
public PersistentStorage(Context context, String name,
JobSerializer serializer,
DependencyInjector dependencyInjector)
{
this.databaseHelper = new DatabaseHelper(context, "_jobqueue-" + name);
this.context = context;
this.jobSerializer = serializer;
this.dependencyInjector = dependencyInjector;
}
public void store(Job job) throws IOException {
ContentValues contentValues = new ContentValues();
contentValues.put(ITEM, jobSerializer.serialize(job));
contentValues.put(ENCRYPTED, job.getEncryptionKeys() != null);
long id = databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
job.setPersistentId(id);
}
public List<Job> getAllUnencrypted() {
return getJobs(null, ENCRYPTED + " = 0");
}
public List<Job> getAllEncrypted(EncryptionKeys keys) {
return getJobs(keys, ENCRYPTED + " = 1");
}
private List<Job> getJobs(EncryptionKeys keys, String where) {
List<Job> results = new LinkedList<>();
SQLiteDatabase database = databaseHelper.getReadableDatabase();
Cursor cursor = null;
try {
cursor = database.query(TABLE_NAME, null, where, null, null, null, ID + " ASC", null);
while (cursor.moveToNext()) {
long id = cursor.getLong(cursor.getColumnIndexOrThrow(ID));
String item = cursor.getString(cursor.getColumnIndexOrThrow(ITEM));
boolean encrypted = cursor.getInt(cursor.getColumnIndexOrThrow(ENCRYPTED)) == 1;
try{
Job job = jobSerializer.deserialize(keys, encrypted, item);
job.setPersistentId(id);
job.setEncryptionKeys(keys);
injectDependencies(job);
results.add(job);
} catch (IOException e) {
Log.w("PersistentStore", e);
remove(id);
}
}
} finally {
if (cursor != null)
cursor.close();
}
return results;
}
public void remove(long id) {
databaseHelper.getWritableDatabase()
.delete(TABLE_NAME, ID + " = ?", new String[] {String.valueOf(id)});
}
private void injectDependencies(Job job) {
if (job instanceof ContextDependent) {
((ContextDependent)job).setContext(context);
}
for (Requirement requirement : job.getRequirements()) {
if (requirement instanceof ContextDependent) {
((ContextDependent)requirement).setContext(context);
}
}
if (dependencyInjector != null) {
dependencyInjector.injectDependencies(job);
}
}
private static class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper(Context context, String name) {
super(context, name, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.requirements;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import org.whispersystems.jobqueue.dependencies.ContextDependent;
/**
* A requirement that is satisfied when a network connection is present.
*/
public class NetworkRequirement implements Requirement, ContextDependent {
private transient Context context;
public NetworkRequirement(Context context) {
this.context = context;
}
public NetworkRequirement() {}
@Override
public boolean isPresent() {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnectedOrConnecting();
}
@Override
public void setContext(Context context) {
this.context = context;
}
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.requirements;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class NetworkRequirementProvider implements RequirementProvider {
private RequirementListener listener;
private final NetworkRequirement requirement;
public NetworkRequirementProvider(Context context) {
this.requirement = new NetworkRequirement(context);
context.getApplicationContext().registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (listener == null) {
return;
}
if (requirement.isPresent()) {
listener.onRequirementStatusChanged();
}
}
}, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
@Override
public String getName() {
return "network";
}
@Override
public void setListener(RequirementListener listener) {
this.listener = listener;
}
}

View File

@@ -0,0 +1,29 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.requirements;
import java.io.Serializable;
/**
* A Requirement that must be satisfied before a Job can run.
*/
public interface Requirement extends Serializable {
/**
* @return true if the requirement is satisfied, false otherwise.
*/
public boolean isPresent();
}

View File

@@ -0,0 +1,21 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.requirements;
public interface RequirementListener {
public void onRequirementStatusChanged();
}

View File

@@ -0,0 +1,37 @@
/**
* Copyright (C) 2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.whispersystems.jobqueue.requirements;
/**
* Notifies listeners when a {@link org.whispersystems.jobqueue.requirements.Requirement}'s
* state is likely to have changed.
*/
public interface RequirementProvider {
/**
* @return The name of the provider.
*/
public String getName();
/**
* The {@link org.whispersystems.jobqueue.requirements.RequirementListener} to call when
* a {@link org.whispersystems.jobqueue.requirements.Requirement}'s status is likely to
* have changed.
*
* @param listener The listener to call.
*/
public void setListener(RequirementListener listener);
}

View File

@@ -0,0 +1,2 @@
<resources>
</resources>

2
libaxolotl/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/build
/obj

85
libaxolotl/README.md Normal file
View File

@@ -0,0 +1,85 @@
# Overview
This is a ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging
environments. The protocol overview is available [here](https://github.com/trevp/axolotl/wiki),
and the details of the wire format are available [here](https://github.com/WhisperSystems/TextSecure/wiki/ProtocolV2).
## PreKeys
This protocol uses a concept called 'PreKeys'. A PreKey is an ECPublicKey and an associated unique
ID which are stored together by a server. PreKeys can also be signed.
At install time, clients generate a single signed PreKey, as well as a large list of unsigned
PreKeys, and transmit all of them to the server.
## Sessions
The axolotl protocol is session-oriented. Clients establish a "session," which is then used for
all subsequent encrypt/decrypt operations. There is no need to ever tear down a session once one
has been established.
Sessions are established in one of three ways:
1. PreKeyBundles. A client that wishes to send a message to a recipient can establish a session by
retrieving a PreKeyBundle for that recipient from the server.
1. PreKeyWhisperMessages. A client can receive a PreKeyWhisperMessage from a recipient and use it
to establish a session.
1. KeyExchangeMessages. Two clients can exchange KeyExchange messages to establish a session.
## State
An established session encapsulates a lot of state between two clients. That state is maintained
in durable records which need to be kept for the life of the session.
State is kept in the following places:
1. Identity State. Clients will need to maintain the state of their own identity key pair, as well
as identity keys received from other clients.
1. PreKey State. Clients will need to maintain the state of their generated PreKeys.
1. Signed PreKey States. Clients will need to maintain the state of their signed PreKeys.
1. Session State. Clients will need to maintain the state of the sessions they have established.
# Using libaxolotl
## Install time
At install time, a libaxolotl client needs to generate its identity keys, registration id, and
prekeys.
IdentityKeyPair identityKeyPair = KeyHelper.generateIdentityKeyPair();
int registrationId = KeyHelper.generateRegistrationId();
List<PreKeyRecord> preKeys = KeyHelper.generatePreKeys(startId, 100);
PreKeyRecord lastResortKey = KeyHelper.generateLastResortKey();
SignedPreKeyRecord signedPreKey = KeyHelper.generateSignedPreKey(identityKeyPair, 5);
// Store identityKeyPair somewhere durable and safe.
// Store registrationId somewhere durable and safe.
// Store preKeys in PreKeyStore.
// Store signed prekey in SignedPreKeyStore.
## Building a session
A libaxolotl client needs to implement four interfaces: IdentityKeyStore, PreKeyStore,
SignedPreKeyStore, and SessionStore. These will manage loading and storing of identity,
prekeys, signed prekeys, and session state.
Once those are implemented, building a session is fairly straightforward:
SessionStore sessionStore = new MySessionStore();
PreKeyStore preKeyStore = new MyPreKeyStore();
SignedPreKeyStore signedPreKeyStore = new MySignedPreKeyStore();
IdentityKeyStore identityStore = new MyIdentityKeyStore();
// Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityStore, recipientId, deviceId);
// Build a session with a PreKey retrieved from the server.
sessionBuilder.process(retrievedPreKey);
SessionCipher sessionCipher = new SessionCipher(sessionStore, recipientId, deviceId);
CiphertextMessage message = sessionCipher.encrypt("Hello world!".getBytes("UTF-8"));
deliver(message.serialize());

44
libaxolotl/build.gradle Normal file
View File

@@ -0,0 +1,44 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.2'
}
}
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.protobuf:protobuf-java:2.5.0'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
android {
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
}
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}

27
libaxolotl/jni/Android.mk Normal file
View File

@@ -0,0 +1,27 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libcurve25519-donna
LOCAL_SRC_FILES := curve25519-donna.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcurve25519-ref10
LOCAL_SRC_FILES := $(wildcard ed25519/*.c) $(wildcard ed25519/additions/*.c) $(wildcard ed25519/nacl_sha512/*.c)
LOCAL_C_INCLUDES := ed25519/nacl_includes ed25519/additions ed25519/sha512 ed25519
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcurve25519
LOCAL_SRC_FILES := curve25519-jni.c
LOCAL_C_INCLUDES := ed25519/additions
LOCAL_STATIC_LIBRARIES := libcurve25519-donna libcurve25519-ref10
include $(BUILD_SHARED_LIBRARY)

View File

@@ -0,0 +1 @@
APP_ABI := armeabi armeabi-v7a x86 mips

View File

@@ -0,0 +1,870 @@
/* Copyright 2008, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* curve25519-donna: Curve25519 elliptic curve, public key function
*
* http://code.google.com/p/curve25519-donna/
*
* Adam Langley <agl@imperialviolet.org>
*
* Derived from public domain C code by Daniel J. Bernstein <djb@cr.yp.to>
*
* More information about curve25519 can be found here
* http://cr.yp.to/ecdh.html
*
* djb's sample implementation of curve25519 is written in a special assembly
* language called qhasm and uses the floating point registers.
*
* This is, almost, a clean room reimplementation from the curve25519 paper. It
* uses many of the tricks described therein. Only the crecip function is taken
* from the sample implementation. */
#include <string.h>
#include <stdint.h>
#ifdef _MSC_VER
#define inline __inline
#endif
typedef uint8_t u8;
typedef int32_t s32;
typedef int64_t limb;
/* Field element representation:
*
* Field elements are written as an array of signed, 64-bit limbs, least
* significant first. The value of the field element is:
* x[0] + 2^26·x[1] + x^51·x[2] + 2^102·x[3] + ...
*
* i.e. the limbs are 26, 25, 26, 25, ... bits wide. */
/* Sum two numbers: output += in */
static void fsum(limb *output, const limb *in) {
unsigned i;
for (i = 0; i < 10; i += 2) {
output[0+i] = output[0+i] + in[0+i];
output[1+i] = output[1+i] + in[1+i];
}
}
/* Find the difference of two numbers: output = in - output
* (note the order of the arguments!). */
static void fdifference(limb *output, const limb *in) {
unsigned i;
for (i = 0; i < 10; ++i) {
output[i] = in[i] - output[i];
}
}
/* Multiply a number by a scalar: output = in * scalar */
static void fscalar_product(limb *output, const limb *in, const limb scalar) {
unsigned i;
for (i = 0; i < 10; ++i) {
output[i] = in[i] * scalar;
}
}
/* Multiply two numbers: output = in2 * in
*
* output must be distinct to both inputs. The inputs are reduced coefficient
* form, the output is not.
*
* output[x] <= 14 * the largest product of the input limbs. */
static void fproduct(limb *output, const limb *in2, const limb *in) {
output[0] = ((limb) ((s32) in2[0])) * ((s32) in[0]);
output[1] = ((limb) ((s32) in2[0])) * ((s32) in[1]) +
((limb) ((s32) in2[1])) * ((s32) in[0]);
output[2] = 2 * ((limb) ((s32) in2[1])) * ((s32) in[1]) +
((limb) ((s32) in2[0])) * ((s32) in[2]) +
((limb) ((s32) in2[2])) * ((s32) in[0]);
output[3] = ((limb) ((s32) in2[1])) * ((s32) in[2]) +
((limb) ((s32) in2[2])) * ((s32) in[1]) +
((limb) ((s32) in2[0])) * ((s32) in[3]) +
((limb) ((s32) in2[3])) * ((s32) in[0]);
output[4] = ((limb) ((s32) in2[2])) * ((s32) in[2]) +
2 * (((limb) ((s32) in2[1])) * ((s32) in[3]) +
((limb) ((s32) in2[3])) * ((s32) in[1])) +
((limb) ((s32) in2[0])) * ((s32) in[4]) +
((limb) ((s32) in2[4])) * ((s32) in[0]);
output[5] = ((limb) ((s32) in2[2])) * ((s32) in[3]) +
((limb) ((s32) in2[3])) * ((s32) in[2]) +
((limb) ((s32) in2[1])) * ((s32) in[4]) +
((limb) ((s32) in2[4])) * ((s32) in[1]) +
((limb) ((s32) in2[0])) * ((s32) in[5]) +
((limb) ((s32) in2[5])) * ((s32) in[0]);
output[6] = 2 * (((limb) ((s32) in2[3])) * ((s32) in[3]) +
((limb) ((s32) in2[1])) * ((s32) in[5]) +
((limb) ((s32) in2[5])) * ((s32) in[1])) +
((limb) ((s32) in2[2])) * ((s32) in[4]) +
((limb) ((s32) in2[4])) * ((s32) in[2]) +
((limb) ((s32) in2[0])) * ((s32) in[6]) +
((limb) ((s32) in2[6])) * ((s32) in[0]);
output[7] = ((limb) ((s32) in2[3])) * ((s32) in[4]) +
((limb) ((s32) in2[4])) * ((s32) in[3]) +
((limb) ((s32) in2[2])) * ((s32) in[5]) +
((limb) ((s32) in2[5])) * ((s32) in[2]) +
((limb) ((s32) in2[1])) * ((s32) in[6]) +
((limb) ((s32) in2[6])) * ((s32) in[1]) +
((limb) ((s32) in2[0])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[0]);
output[8] = ((limb) ((s32) in2[4])) * ((s32) in[4]) +
2 * (((limb) ((s32) in2[3])) * ((s32) in[5]) +
((limb) ((s32) in2[5])) * ((s32) in[3]) +
((limb) ((s32) in2[1])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[1])) +
((limb) ((s32) in2[2])) * ((s32) in[6]) +
((limb) ((s32) in2[6])) * ((s32) in[2]) +
((limb) ((s32) in2[0])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[0]);
output[9] = ((limb) ((s32) in2[4])) * ((s32) in[5]) +
((limb) ((s32) in2[5])) * ((s32) in[4]) +
((limb) ((s32) in2[3])) * ((s32) in[6]) +
((limb) ((s32) in2[6])) * ((s32) in[3]) +
((limb) ((s32) in2[2])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[2]) +
((limb) ((s32) in2[1])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[1]) +
((limb) ((s32) in2[0])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[0]);
output[10] = 2 * (((limb) ((s32) in2[5])) * ((s32) in[5]) +
((limb) ((s32) in2[3])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[3]) +
((limb) ((s32) in2[1])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[1])) +
((limb) ((s32) in2[4])) * ((s32) in[6]) +
((limb) ((s32) in2[6])) * ((s32) in[4]) +
((limb) ((s32) in2[2])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[2]);
output[11] = ((limb) ((s32) in2[5])) * ((s32) in[6]) +
((limb) ((s32) in2[6])) * ((s32) in[5]) +
((limb) ((s32) in2[4])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[4]) +
((limb) ((s32) in2[3])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[3]) +
((limb) ((s32) in2[2])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[2]);
output[12] = ((limb) ((s32) in2[6])) * ((s32) in[6]) +
2 * (((limb) ((s32) in2[5])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[5]) +
((limb) ((s32) in2[3])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[3])) +
((limb) ((s32) in2[4])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[4]);
output[13] = ((limb) ((s32) in2[6])) * ((s32) in[7]) +
((limb) ((s32) in2[7])) * ((s32) in[6]) +
((limb) ((s32) in2[5])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[5]) +
((limb) ((s32) in2[4])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[4]);
output[14] = 2 * (((limb) ((s32) in2[7])) * ((s32) in[7]) +
((limb) ((s32) in2[5])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[5])) +
((limb) ((s32) in2[6])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[6]);
output[15] = ((limb) ((s32) in2[7])) * ((s32) in[8]) +
((limb) ((s32) in2[8])) * ((s32) in[7]) +
((limb) ((s32) in2[6])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[6]);
output[16] = ((limb) ((s32) in2[8])) * ((s32) in[8]) +
2 * (((limb) ((s32) in2[7])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[7]));
output[17] = ((limb) ((s32) in2[8])) * ((s32) in[9]) +
((limb) ((s32) in2[9])) * ((s32) in[8]);
output[18] = 2 * ((limb) ((s32) in2[9])) * ((s32) in[9]);
}
/* Reduce a long form to a short form by taking the input mod 2^255 - 19.
*
* On entry: |output[i]| < 14*2^54
* On exit: |output[0..8]| < 280*2^54 */
static void freduce_degree(limb *output) {
/* Each of these shifts and adds ends up multiplying the value by 19.
*
* For output[0..8], the absolute entry value is < 14*2^54 and we add, at
* most, 19*14*2^54 thus, on exit, |output[0..8]| < 280*2^54. */
output[8] += output[18] << 4;
output[8] += output[18] << 1;
output[8] += output[18];
output[7] += output[17] << 4;
output[7] += output[17] << 1;
output[7] += output[17];
output[6] += output[16] << 4;
output[6] += output[16] << 1;
output[6] += output[16];
output[5] += output[15] << 4;
output[5] += output[15] << 1;
output[5] += output[15];
output[4] += output[14] << 4;
output[4] += output[14] << 1;
output[4] += output[14];
output[3] += output[13] << 4;
output[3] += output[13] << 1;
output[3] += output[13];
output[2] += output[12] << 4;
output[2] += output[12] << 1;
output[2] += output[12];
output[1] += output[11] << 4;
output[1] += output[11] << 1;
output[1] += output[11];
output[0] += output[10] << 4;
output[0] += output[10] << 1;
output[0] += output[10];
}
#if (-1 & 3) != 3
#error "This code only works on a two's complement system"
#endif
/* return v / 2^26, using only shifts and adds.
*
* On entry: v can take any value. */
static inline limb
div_by_2_26(const limb v)
{
/* High word of v; no shift needed. */
const uint32_t highword = (uint32_t) (((uint64_t) v) >> 32);
/* Set to all 1s if v was negative; else set to 0s. */
const int32_t sign = ((int32_t) highword) >> 31;
/* Set to 0x3ffffff if v was negative; else set to 0. */
const int32_t roundoff = ((uint32_t) sign) >> 6;
/* Should return v / (1<<26) */
return (v + roundoff) >> 26;
}
/* return v / (2^25), using only shifts and adds.
*
* On entry: v can take any value. */
static inline limb
div_by_2_25(const limb v)
{
/* High word of v; no shift needed*/
const uint32_t highword = (uint32_t) (((uint64_t) v) >> 32);
/* Set to all 1s if v was negative; else set to 0s. */
const int32_t sign = ((int32_t) highword) >> 31;
/* Set to 0x1ffffff if v was negative; else set to 0. */
const int32_t roundoff = ((uint32_t) sign) >> 7;
/* Should return v / (1<<25) */
return (v + roundoff) >> 25;
}
/* return v / (2^25), using only shifts and adds.
*
* On entry: v can take any value. */
static inline s32
div_s32_by_2_25(const s32 v)
{
const s32 roundoff = ((uint32_t)(v >> 31)) >> 7;
return (v + roundoff) >> 25;
}
/* Reduce all coefficients of the short form input so that |x| < 2^26.
*
* On entry: |output[i]| < 280*2^54 */
static void freduce_coefficients(limb *output) {
unsigned i;
output[10] = 0;
for (i = 0; i < 10; i += 2) {
limb over = div_by_2_26(output[i]);
/* The entry condition (that |output[i]| < 280*2^54) means that over is, at
* most, 280*2^28 in the first iteration of this loop. This is added to the
* next limb and we can approximate the resulting bound of that limb by
* 281*2^54. */
output[i] -= over << 26;
output[i+1] += over;
/* For the first iteration, |output[i+1]| < 281*2^54, thus |over| <
* 281*2^29. When this is added to the next limb, the resulting bound can
* be approximated as 281*2^54.
*
* For subsequent iterations of the loop, 281*2^54 remains a conservative
* bound and no overflow occurs. */
over = div_by_2_25(output[i+1]);
output[i+1] -= over << 25;
output[i+2] += over;
}
/* Now |output[10]| < 281*2^29 and all other coefficients are reduced. */
output[0] += output[10] << 4;
output[0] += output[10] << 1;
output[0] += output[10];
output[10] = 0;
/* Now output[1..9] are reduced, and |output[0]| < 2^26 + 19*281*2^29
* So |over| will be no more than 2^16. */
{
limb over = div_by_2_26(output[0]);
output[0] -= over << 26;
output[1] += over;
}
/* Now output[0,2..9] are reduced, and |output[1]| < 2^25 + 2^16 < 2^26. The
* bound on |output[1]| is sufficient to meet our needs. */
}
/* A helpful wrapper around fproduct: output = in * in2.
*
* On entry: |in[i]| < 2^27 and |in2[i]| < 2^27.
*
* output must be distinct to both inputs. The output is reduced degree
* (indeed, one need only provide storage for 10 limbs) and |output[i]| < 2^26. */
static void
fmul(limb *output, const limb *in, const limb *in2) {
limb t[19];
fproduct(t, in, in2);
/* |t[i]| < 14*2^54 */
freduce_degree(t);
freduce_coefficients(t);
/* |t[i]| < 2^26 */
memcpy(output, t, sizeof(limb) * 10);
}
/* Square a number: output = in**2
*
* output must be distinct from the input. The inputs are reduced coefficient
* form, the output is not.
*
* output[x] <= 14 * the largest product of the input limbs. */
static void fsquare_inner(limb *output, const limb *in) {
output[0] = ((limb) ((s32) in[0])) * ((s32) in[0]);
output[1] = 2 * ((limb) ((s32) in[0])) * ((s32) in[1]);
output[2] = 2 * (((limb) ((s32) in[1])) * ((s32) in[1]) +
((limb) ((s32) in[0])) * ((s32) in[2]));
output[3] = 2 * (((limb) ((s32) in[1])) * ((s32) in[2]) +
((limb) ((s32) in[0])) * ((s32) in[3]));
output[4] = ((limb) ((s32) in[2])) * ((s32) in[2]) +
4 * ((limb) ((s32) in[1])) * ((s32) in[3]) +
2 * ((limb) ((s32) in[0])) * ((s32) in[4]);
output[5] = 2 * (((limb) ((s32) in[2])) * ((s32) in[3]) +
((limb) ((s32) in[1])) * ((s32) in[4]) +
((limb) ((s32) in[0])) * ((s32) in[5]));
output[6] = 2 * (((limb) ((s32) in[3])) * ((s32) in[3]) +
((limb) ((s32) in[2])) * ((s32) in[4]) +
((limb) ((s32) in[0])) * ((s32) in[6]) +
2 * ((limb) ((s32) in[1])) * ((s32) in[5]));
output[7] = 2 * (((limb) ((s32) in[3])) * ((s32) in[4]) +
((limb) ((s32) in[2])) * ((s32) in[5]) +
((limb) ((s32) in[1])) * ((s32) in[6]) +
((limb) ((s32) in[0])) * ((s32) in[7]));
output[8] = ((limb) ((s32) in[4])) * ((s32) in[4]) +
2 * (((limb) ((s32) in[2])) * ((s32) in[6]) +
((limb) ((s32) in[0])) * ((s32) in[8]) +
2 * (((limb) ((s32) in[1])) * ((s32) in[7]) +
((limb) ((s32) in[3])) * ((s32) in[5])));
output[9] = 2 * (((limb) ((s32) in[4])) * ((s32) in[5]) +
((limb) ((s32) in[3])) * ((s32) in[6]) +
((limb) ((s32) in[2])) * ((s32) in[7]) +
((limb) ((s32) in[1])) * ((s32) in[8]) +
((limb) ((s32) in[0])) * ((s32) in[9]));
output[10] = 2 * (((limb) ((s32) in[5])) * ((s32) in[5]) +
((limb) ((s32) in[4])) * ((s32) in[6]) +
((limb) ((s32) in[2])) * ((s32) in[8]) +
2 * (((limb) ((s32) in[3])) * ((s32) in[7]) +
((limb) ((s32) in[1])) * ((s32) in[9])));
output[11] = 2 * (((limb) ((s32) in[5])) * ((s32) in[6]) +
((limb) ((s32) in[4])) * ((s32) in[7]) +
((limb) ((s32) in[3])) * ((s32) in[8]) +
((limb) ((s32) in[2])) * ((s32) in[9]));
output[12] = ((limb) ((s32) in[6])) * ((s32) in[6]) +
2 * (((limb) ((s32) in[4])) * ((s32) in[8]) +
2 * (((limb) ((s32) in[5])) * ((s32) in[7]) +
((limb) ((s32) in[3])) * ((s32) in[9])));
output[13] = 2 * (((limb) ((s32) in[6])) * ((s32) in[7]) +
((limb) ((s32) in[5])) * ((s32) in[8]) +
((limb) ((s32) in[4])) * ((s32) in[9]));
output[14] = 2 * (((limb) ((s32) in[7])) * ((s32) in[7]) +
((limb) ((s32) in[6])) * ((s32) in[8]) +
2 * ((limb) ((s32) in[5])) * ((s32) in[9]));
output[15] = 2 * (((limb) ((s32) in[7])) * ((s32) in[8]) +
((limb) ((s32) in[6])) * ((s32) in[9]));
output[16] = ((limb) ((s32) in[8])) * ((s32) in[8]) +
4 * ((limb) ((s32) in[7])) * ((s32) in[9]);
output[17] = 2 * ((limb) ((s32) in[8])) * ((s32) in[9]);
output[18] = 2 * ((limb) ((s32) in[9])) * ((s32) in[9]);
}
/* fsquare sets output = in^2.
*
* On entry: The |in| argument is in reduced coefficients form and |in[i]| <
* 2^27.
*
* On exit: The |output| argument is in reduced coefficients form (indeed, one
* need only provide storage for 10 limbs) and |out[i]| < 2^26. */
static void
fsquare(limb *output, const limb *in) {
limb t[19];
fsquare_inner(t, in);
/* |t[i]| < 14*2^54 because the largest product of two limbs will be <
* 2^(27+27) and fsquare_inner adds together, at most, 14 of those
* products. */
freduce_degree(t);
freduce_coefficients(t);
/* |t[i]| < 2^26 */
memcpy(output, t, sizeof(limb) * 10);
}
/* Take a little-endian, 32-byte number and expand it into polynomial form */
static void
fexpand(limb *output, const u8 *input) {
#define F(n,start,shift,mask) \
output[n] = ((((limb) input[start + 0]) | \
((limb) input[start + 1]) << 8 | \
((limb) input[start + 2]) << 16 | \
((limb) input[start + 3]) << 24) >> shift) & mask;
F(0, 0, 0, 0x3ffffff);
F(1, 3, 2, 0x1ffffff);
F(2, 6, 3, 0x3ffffff);
F(3, 9, 5, 0x1ffffff);
F(4, 12, 6, 0x3ffffff);
F(5, 16, 0, 0x1ffffff);
F(6, 19, 1, 0x3ffffff);
F(7, 22, 3, 0x1ffffff);
F(8, 25, 4, 0x3ffffff);
F(9, 28, 6, 0x1ffffff);
#undef F
}
#if (-32 >> 1) != -16
#error "This code only works when >> does sign-extension on negative numbers"
#endif
/* s32_eq returns 0xffffffff iff a == b and zero otherwise. */
static s32 s32_eq(s32 a, s32 b) {
a = ~(a ^ b);
a &= a << 16;
a &= a << 8;
a &= a << 4;
a &= a << 2;
a &= a << 1;
return a >> 31;
}
/* s32_gte returns 0xffffffff if a >= b and zero otherwise, where a and b are
* both non-negative. */
static s32 s32_gte(s32 a, s32 b) {
a -= b;
/* a >= 0 iff a >= b. */
return ~(a >> 31);
}
/* Take a fully reduced polynomial form number and contract it into a
* little-endian, 32-byte array.
*
* On entry: |input_limbs[i]| < 2^26 */
static void
fcontract(u8 *output, limb *input_limbs) {
int i;
int j;
s32 input[10];
s32 mask;
/* |input_limbs[i]| < 2^26, so it's valid to convert to an s32. */
for (i = 0; i < 10; i++) {
input[i] = input_limbs[i];
}
for (j = 0; j < 2; ++j) {
for (i = 0; i < 9; ++i) {
if ((i & 1) == 1) {
/* This calculation is a time-invariant way to make input[i]
* non-negative by borrowing from the next-larger limb. */
const s32 mask = input[i] >> 31;
const s32 carry = -((input[i] & mask) >> 25);
input[i] = input[i] + (carry << 25);
input[i+1] = input[i+1] - carry;
} else {
const s32 mask = input[i] >> 31;
const s32 carry = -((input[i] & mask) >> 26);
input[i] = input[i] + (carry << 26);
input[i+1] = input[i+1] - carry;
}
}
/* There's no greater limb for input[9] to borrow from, but we can multiply
* by 19 and borrow from input[0], which is valid mod 2^255-19. */
{
const s32 mask = input[9] >> 31;
const s32 carry = -((input[9] & mask) >> 25);
input[9] = input[9] + (carry << 25);
input[0] = input[0] - (carry * 19);
}
/* After the first iteration, input[1..9] are non-negative and fit within
* 25 or 26 bits, depending on position. However, input[0] may be
* negative. */
}
/* The first borrow-propagation pass above ended with every limb
except (possibly) input[0] non-negative.
If input[0] was negative after the first pass, then it was because of a
carry from input[9]. On entry, input[9] < 2^26 so the carry was, at most,
one, since (2**26-1) >> 25 = 1. Thus input[0] >= -19.
In the second pass, each limb is decreased by at most one. Thus the second
borrow-propagation pass could only have wrapped around to decrease
input[0] again if the first pass left input[0] negative *and* input[1]
through input[9] were all zero. In that case, input[1] is now 2^25 - 1,
and this last borrow-propagation step will leave input[1] non-negative. */
{
const s32 mask = input[0] >> 31;
const s32 carry = -((input[0] & mask) >> 26);
input[0] = input[0] + (carry << 26);
input[1] = input[1] - carry;
}
/* All input[i] are now non-negative. However, there might be values between
* 2^25 and 2^26 in a limb which is, nominally, 25 bits wide. */
for (j = 0; j < 2; j++) {
for (i = 0; i < 9; i++) {
if ((i & 1) == 1) {
const s32 carry = input[i] >> 25;
input[i] &= 0x1ffffff;
input[i+1] += carry;
} else {
const s32 carry = input[i] >> 26;
input[i] &= 0x3ffffff;
input[i+1] += carry;
}
}
{
const s32 carry = input[9] >> 25;
input[9] &= 0x1ffffff;
input[0] += 19*carry;
}
}
/* If the first carry-chain pass, just above, ended up with a carry from
* input[9], and that caused input[0] to be out-of-bounds, then input[0] was
* < 2^26 + 2*19, because the carry was, at most, two.
*
* If the second pass carried from input[9] again then input[0] is < 2*19 and
* the input[9] -> input[0] carry didn't push input[0] out of bounds. */
/* It still remains the case that input might be between 2^255-19 and 2^255.
* In this case, input[1..9] must take their maximum value and input[0] must
* be >= (2^255-19) & 0x3ffffff, which is 0x3ffffed. */
mask = s32_gte(input[0], 0x3ffffed);
for (i = 1; i < 10; i++) {
if ((i & 1) == 1) {
mask &= s32_eq(input[i], 0x1ffffff);
} else {
mask &= s32_eq(input[i], 0x3ffffff);
}
}
/* mask is either 0xffffffff (if input >= 2^255-19) and zero otherwise. Thus
* this conditionally subtracts 2^255-19. */
input[0] -= mask & 0x3ffffed;
for (i = 1; i < 10; i++) {
if ((i & 1) == 1) {
input[i] -= mask & 0x1ffffff;
} else {
input[i] -= mask & 0x3ffffff;
}
}
input[1] <<= 2;
input[2] <<= 3;
input[3] <<= 5;
input[4] <<= 6;
input[6] <<= 1;
input[7] <<= 3;
input[8] <<= 4;
input[9] <<= 6;
#define F(i, s) \
output[s+0] |= input[i] & 0xff; \
output[s+1] = (input[i] >> 8) & 0xff; \
output[s+2] = (input[i] >> 16) & 0xff; \
output[s+3] = (input[i] >> 24) & 0xff;
output[0] = 0;
output[16] = 0;
F(0,0);
F(1,3);
F(2,6);
F(3,9);
F(4,12);
F(5,16);
F(6,19);
F(7,22);
F(8,25);
F(9,28);
#undef F
}
/* Input: Q, Q', Q-Q'
* Output: 2Q, Q+Q'
*
* x2 z3: long form
* x3 z3: long form
* x z: short form, destroyed
* xprime zprime: short form, destroyed
* qmqp: short form, preserved
*
* On entry and exit, the absolute value of the limbs of all inputs and outputs
* are < 2^26. */
static void fmonty(limb *x2, limb *z2, /* output 2Q */
limb *x3, limb *z3, /* output Q + Q' */
limb *x, limb *z, /* input Q */
limb *xprime, limb *zprime, /* input Q' */
const limb *qmqp /* input Q - Q' */) {
limb origx[10], origxprime[10], zzz[19], xx[19], zz[19], xxprime[19],
zzprime[19], zzzprime[19], xxxprime[19];
memcpy(origx, x, 10 * sizeof(limb));
fsum(x, z);
/* |x[i]| < 2^27 */
fdifference(z, origx); /* does x - z */
/* |z[i]| < 2^27 */
memcpy(origxprime, xprime, sizeof(limb) * 10);
fsum(xprime, zprime);
/* |xprime[i]| < 2^27 */
fdifference(zprime, origxprime);
/* |zprime[i]| < 2^27 */
fproduct(xxprime, xprime, z);
/* |xxprime[i]| < 14*2^54: the largest product of two limbs will be <
* 2^(27+27) and fproduct adds together, at most, 14 of those products.
* (Approximating that to 2^58 doesn't work out.) */
fproduct(zzprime, x, zprime);
/* |zzprime[i]| < 14*2^54 */
freduce_degree(xxprime);
freduce_coefficients(xxprime);
/* |xxprime[i]| < 2^26 */
freduce_degree(zzprime);
freduce_coefficients(zzprime);
/* |zzprime[i]| < 2^26 */
memcpy(origxprime, xxprime, sizeof(limb) * 10);
fsum(xxprime, zzprime);
/* |xxprime[i]| < 2^27 */
fdifference(zzprime, origxprime);
/* |zzprime[i]| < 2^27 */
fsquare(xxxprime, xxprime);
/* |xxxprime[i]| < 2^26 */
fsquare(zzzprime, zzprime);
/* |zzzprime[i]| < 2^26 */
fproduct(zzprime, zzzprime, qmqp);
/* |zzprime[i]| < 14*2^52 */
freduce_degree(zzprime);
freduce_coefficients(zzprime);
/* |zzprime[i]| < 2^26 */
memcpy(x3, xxxprime, sizeof(limb) * 10);
memcpy(z3, zzprime, sizeof(limb) * 10);
fsquare(xx, x);
/* |xx[i]| < 2^26 */
fsquare(zz, z);
/* |zz[i]| < 2^26 */
fproduct(x2, xx, zz);
/* |x2[i]| < 14*2^52 */
freduce_degree(x2);
freduce_coefficients(x2);
/* |x2[i]| < 2^26 */
fdifference(zz, xx); // does zz = xx - zz
/* |zz[i]| < 2^27 */
memset(zzz + 10, 0, sizeof(limb) * 9);
fscalar_product(zzz, zz, 121665);
/* |zzz[i]| < 2^(27+17) */
/* No need to call freduce_degree here:
fscalar_product doesn't increase the degree of its input. */
freduce_coefficients(zzz);
/* |zzz[i]| < 2^26 */
fsum(zzz, xx);
/* |zzz[i]| < 2^27 */
fproduct(z2, zz, zzz);
/* |z2[i]| < 14*2^(26+27) */
freduce_degree(z2);
freduce_coefficients(z2);
/* |z2|i| < 2^26 */
}
/* Conditionally swap two reduced-form limb arrays if 'iswap' is 1, but leave
* them unchanged if 'iswap' is 0. Runs in data-invariant time to avoid
* side-channel attacks.
*
* NOTE that this function requires that 'iswap' be 1 or 0; other values give
* wrong results. Also, the two limb arrays must be in reduced-coefficient,
* reduced-degree form: the values in a[10..19] or b[10..19] aren't swapped,
* and all all values in a[0..9],b[0..9] must have magnitude less than
* INT32_MAX. */
static void
swap_conditional(limb a[19], limb b[19], limb iswap) {
unsigned i;
const s32 swap = (s32) -iswap;
for (i = 0; i < 10; ++i) {
const s32 x = swap & ( ((s32)a[i]) ^ ((s32)b[i]) );
a[i] = ((s32)a[i]) ^ x;
b[i] = ((s32)b[i]) ^ x;
}
}
/* Calculates nQ where Q is the x-coordinate of a point on the curve
*
* resultx/resultz: the x coordinate of the resulting curve point (short form)
* n: a little endian, 32-byte number
* q: a point of the curve (short form) */
static void
cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) {
limb a[19] = {0}, b[19] = {1}, c[19] = {1}, d[19] = {0};
limb *nqpqx = a, *nqpqz = b, *nqx = c, *nqz = d, *t;
limb e[19] = {0}, f[19] = {1}, g[19] = {0}, h[19] = {1};
limb *nqpqx2 = e, *nqpqz2 = f, *nqx2 = g, *nqz2 = h;
unsigned i, j;
memcpy(nqpqx, q, sizeof(limb) * 10);
for (i = 0; i < 32; ++i) {
u8 byte = n[31 - i];
for (j = 0; j < 8; ++j) {
const limb bit = byte >> 7;
swap_conditional(nqx, nqpqx, bit);
swap_conditional(nqz, nqpqz, bit);
fmonty(nqx2, nqz2,
nqpqx2, nqpqz2,
nqx, nqz,
nqpqx, nqpqz,
q);
swap_conditional(nqx2, nqpqx2, bit);
swap_conditional(nqz2, nqpqz2, bit);
t = nqx;
nqx = nqx2;
nqx2 = t;
t = nqz;
nqz = nqz2;
nqz2 = t;
t = nqpqx;
nqpqx = nqpqx2;
nqpqx2 = t;
t = nqpqz;
nqpqz = nqpqz2;
nqpqz2 = t;
byte <<= 1;
}
}
memcpy(resultx, nqx, sizeof(limb) * 10);
memcpy(resultz, nqz, sizeof(limb) * 10);
}
// -----------------------------------------------------------------------------
// Shamelessly copied from djb's code
// -----------------------------------------------------------------------------
static void
crecip(limb *out, const limb *z) {
limb z2[10];
limb z9[10];
limb z11[10];
limb z2_5_0[10];
limb z2_10_0[10];
limb z2_20_0[10];
limb z2_50_0[10];
limb z2_100_0[10];
limb t0[10];
limb t1[10];
int i;
/* 2 */ fsquare(z2,z);
/* 4 */ fsquare(t1,z2);
/* 8 */ fsquare(t0,t1);
/* 9 */ fmul(z9,t0,z);
/* 11 */ fmul(z11,z9,z2);
/* 22 */ fsquare(t0,z11);
/* 2^5 - 2^0 = 31 */ fmul(z2_5_0,t0,z9);
/* 2^6 - 2^1 */ fsquare(t0,z2_5_0);
/* 2^7 - 2^2 */ fsquare(t1,t0);
/* 2^8 - 2^3 */ fsquare(t0,t1);
/* 2^9 - 2^4 */ fsquare(t1,t0);
/* 2^10 - 2^5 */ fsquare(t0,t1);
/* 2^10 - 2^0 */ fmul(z2_10_0,t0,z2_5_0);
/* 2^11 - 2^1 */ fsquare(t0,z2_10_0);
/* 2^12 - 2^2 */ fsquare(t1,t0);
/* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
/* 2^20 - 2^0 */ fmul(z2_20_0,t1,z2_10_0);
/* 2^21 - 2^1 */ fsquare(t0,z2_20_0);
/* 2^22 - 2^2 */ fsquare(t1,t0);
/* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
/* 2^40 - 2^0 */ fmul(t0,t1,z2_20_0);
/* 2^41 - 2^1 */ fsquare(t1,t0);
/* 2^42 - 2^2 */ fsquare(t0,t1);
/* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fsquare(t1,t0); fsquare(t0,t1); }
/* 2^50 - 2^0 */ fmul(z2_50_0,t0,z2_10_0);
/* 2^51 - 2^1 */ fsquare(t0,z2_50_0);
/* 2^52 - 2^2 */ fsquare(t1,t0);
/* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
/* 2^100 - 2^0 */ fmul(z2_100_0,t1,z2_50_0);
/* 2^101 - 2^1 */ fsquare(t1,z2_100_0);
/* 2^102 - 2^2 */ fsquare(t0,t1);
/* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fsquare(t1,t0); fsquare(t0,t1); }
/* 2^200 - 2^0 */ fmul(t1,t0,z2_100_0);
/* 2^201 - 2^1 */ fsquare(t0,t1);
/* 2^202 - 2^2 */ fsquare(t1,t0);
/* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fsquare(t0,t1); fsquare(t1,t0); }
/* 2^250 - 2^0 */ fmul(t0,t1,z2_50_0);
/* 2^251 - 2^1 */ fsquare(t1,t0);
/* 2^252 - 2^2 */ fsquare(t0,t1);
/* 2^253 - 2^3 */ fsquare(t1,t0);
/* 2^254 - 2^4 */ fsquare(t0,t1);
/* 2^255 - 2^5 */ fsquare(t1,t0);
/* 2^255 - 21 */ fmul(out,t1,z11);
}
int
curve25519_donna(u8 *mypublic, const u8 *secret, const u8 *basepoint) {
limb bp[10], x[10], z[11], zmone[10];
uint8_t e[32];
int i;
for (i = 0; i < 32; ++i) e[i] = secret[i];
// e[0] &= 248;
// e[31] &= 127;
// e[31] |= 64;
fexpand(bp, basepoint);
cmult(x, z, e, bp);
crecip(zmone, z);
fmul(z, x, zmone);
fcontract(mypublic, z);
return 0;
}

View File

@@ -0,0 +1,6 @@
#ifndef CURVE25519_DONNA_H
#define CURVE25519_DONNA_H
extern int curve25519_donna(uint8_t *, const uint8_t *, const uint8_t *);
#endif

View File

@@ -0,0 +1,109 @@
/**
* Copyright (C) 2013-2014 Open Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdint.h>
#include <jni.h>
#include "curve25519-donna.h"
#include "curve_sigs.h"
JNIEXPORT jbyteArray JNICALL Java_org_whispersystems_libaxolotl_ecc_Curve25519_generatePrivateKey
(JNIEnv *env, jclass clazz, jbyteArray random)
{
uint8_t* privateKey = (uint8_t*)(*env)->GetByteArrayElements(env, random, 0);
privateKey[0] &= 248;
privateKey[31] &= 127;
privateKey[31] |= 64;
(*env)->ReleaseByteArrayElements(env, random, privateKey, 0);
return random;
}
JNIEXPORT jbyteArray JNICALL Java_org_whispersystems_libaxolotl_ecc_Curve25519_generatePublicKey
(JNIEnv *env, jclass clazz, jbyteArray privateKey)
{
static const uint8_t basepoint[32] = {9};
jbyteArray publicKey = (*env)->NewByteArray(env, 32);
uint8_t* publicKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, publicKey, 0);
uint8_t* privateKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, privateKey, 0);
curve25519_donna(publicKeyBytes, privateKeyBytes, basepoint);
(*env)->ReleaseByteArrayElements(env, publicKey, publicKeyBytes, 0);
(*env)->ReleaseByteArrayElements(env, privateKey, privateKeyBytes, 0);
return publicKey;
}
JNIEXPORT jbyteArray JNICALL Java_org_whispersystems_libaxolotl_ecc_Curve25519_calculateAgreement
(JNIEnv *env, jclass clazz, jbyteArray privateKey, jbyteArray publicKey)
{
jbyteArray sharedKey = (*env)->NewByteArray(env, 32);
uint8_t* sharedKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, sharedKey, 0);
uint8_t* privateKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, privateKey, 0);
uint8_t* publicKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, publicKey, 0);
curve25519_donna(sharedKeyBytes, privateKeyBytes, publicKeyBytes);
(*env)->ReleaseByteArrayElements(env, sharedKey, sharedKeyBytes, 0);
(*env)->ReleaseByteArrayElements(env, publicKey, publicKeyBytes, 0);
(*env)->ReleaseByteArrayElements(env, privateKey, privateKeyBytes, 0);
return sharedKey;
}
JNIEXPORT jbyteArray JNICALL Java_org_whispersystems_libaxolotl_ecc_Curve25519_calculateSignature
(JNIEnv *env, jclass clazz, jbyteArray random, jbyteArray privateKey, jbyteArray message)
{
jbyteArray signature = (*env)->NewByteArray(env, 64);
uint8_t* signatureBytes = (uint8_t*)(*env)->GetByteArrayElements(env, signature, 0);
uint8_t* randomBytes = (uint8_t*)(*env)->GetByteArrayElements(env, random, 0);
uint8_t* privateKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, privateKey, 0);
uint8_t* messageBytes = (uint8_t*)(*env)->GetByteArrayElements(env, message, 0);
jsize messageLength = (*env)->GetArrayLength(env, message);
int result = curve25519_sign(signatureBytes, privateKeyBytes, messageBytes, messageLength, randomBytes);
(*env)->ReleaseByteArrayElements(env, signature, signatureBytes, 0);
(*env)->ReleaseByteArrayElements(env, random, randomBytes, 0);
(*env)->ReleaseByteArrayElements(env, privateKey, privateKeyBytes, 0);
(*env)->ReleaseByteArrayElements(env, message, messageBytes, 0);
if (result == 0) return signature;
else (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/AssertionError"), "Signature failed!");
}
JNIEXPORT jboolean JNICALL Java_org_whispersystems_libaxolotl_ecc_Curve25519_verifySignature
(JNIEnv *env, jclass clazz, jbyteArray publicKey, jbyteArray message, jbyteArray signature)
{
uint8_t* signatureBytes = (uint8_t*)(*env)->GetByteArrayElements(env, signature, 0);
uint8_t* publicKeyBytes = (uint8_t*)(*env)->GetByteArrayElements(env, publicKey, 0);
uint8_t* messageBytes = (uint8_t*)(*env)->GetByteArrayElements(env, message, 0);
jsize messageLength = (*env)->GetArrayLength(env, message);
jboolean result = (curve25519_verify(signatureBytes, publicKeyBytes, messageBytes, messageLength) == 0);
(*env)->ReleaseByteArrayElements(env, signature, signatureBytes, 0);
(*env)->ReleaseByteArrayElements(env, publicKey, publicKeyBytes, 0);
(*env)->ReleaseByteArrayElements(env, message, messageBytes, 0);
return result;
}

View File

@@ -0,0 +1,44 @@
#include <string.h>
#include "compare.h"
/* Const-time comparison from SUPERCOP, but here it's only used for
signature verification, so doesn't need to be const-time. But
copied the nacl version anyways. */
int crypto_verify_32_ref(const unsigned char *x, const unsigned char *y)
{
unsigned int differentbits = 0;
#define F(i) differentbits |= x[i] ^ y[i];
F(0)
F(1)
F(2)
F(3)
F(4)
F(5)
F(6)
F(7)
F(8)
F(9)
F(10)
F(11)
F(12)
F(13)
F(14)
F(15)
F(16)
F(17)
F(18)
F(19)
F(20)
F(21)
F(22)
F(23)
F(24)
F(25)
F(26)
F(27)
F(28)
F(29)
F(30)
F(31)
return (1 & ((differentbits - 1) >> 8)) - 1;
}

View File

@@ -0,0 +1,6 @@
#ifndef __COMPARE_H__
#define __COMPARE_H__
int crypto_verify_32_ref(const unsigned char *b1, const unsigned char *b2);
#endif

View File

@@ -0,0 +1,6 @@
#ifndef crypto_hash_sha512_H
#define crypto_hash_sha512_H
extern int crypto_hash_sha512(unsigned char *,const unsigned char *,unsigned long long);
#endif

View File

@@ -0,0 +1,116 @@
#include <string.h>
#include "ge.h"
#include "curve_sigs.h"
#include "crypto_sign.h"
void curve25519_keygen(unsigned char* curve25519_pubkey_out,
const unsigned char* curve25519_privkey_in)
{
ge_p3 ed; /* Ed25519 pubkey point */
fe ed_y, ed_y_plus_one, one_minus_ed_y, inv_one_minus_ed_y;
fe mont_x;
/* Perform a fixed-base multiplication of the Edwards base point,
(which is efficient due to precalculated tables), then convert
to the Curve25519 montgomery-format public key. In particular,
convert Curve25519's "montgomery" x-coordinate into an Ed25519
"edwards" y-coordinate:
mont_x = (ed_y + 1) / (1 - ed_y)
with projective coordinates:
mont_x = (ed_y + ed_z) / (ed_z - ed_y)
NOTE: ed_y=1 is converted to mont_x=0 since fe_invert is mod-exp
*/
ge_scalarmult_base(&ed, curve25519_privkey_in);
fe_add(ed_y_plus_one, ed.Y, ed.Z);
fe_sub(one_minus_ed_y, ed.Z, ed.Y);
fe_invert(inv_one_minus_ed_y, one_minus_ed_y);
fe_mul(mont_x, ed_y_plus_one, inv_one_minus_ed_y);
fe_tobytes(curve25519_pubkey_out, mont_x);
}
int curve25519_sign(unsigned char* signature_out,
const unsigned char* curve25519_privkey,
const unsigned char* msg, const unsigned long msg_len,
const unsigned char* random)
{
ge_p3 ed_pubkey_point; /* Ed25519 pubkey point */
unsigned char ed_pubkey[32]; /* Ed25519 encoded pubkey */
unsigned char sigbuf[MAX_MSG_LEN + 128]; /* working buffer */
unsigned char sign_bit = 0;
if (msg_len > MAX_MSG_LEN) {
memset(signature_out, 0, 64);
return -1;
}
/* Convert the Curve25519 privkey to an Ed25519 public key */
ge_scalarmult_base(&ed_pubkey_point, curve25519_privkey);
ge_p3_tobytes(ed_pubkey, &ed_pubkey_point);
sign_bit = ed_pubkey[31] & 0x80;
/* Perform an Ed25519 signature with explicit private key */
crypto_sign_modified(sigbuf, msg, msg_len, curve25519_privkey,
ed_pubkey, random);
memmove(signature_out, sigbuf, 64);
/* Encode the sign bit into signature (in unused high bit of S) */
signature_out[63] &= 0x7F; /* bit should be zero already, but just in case */
signature_out[63] |= sign_bit;
return 0;
}
int curve25519_verify(const unsigned char* signature,
const unsigned char* curve25519_pubkey,
const unsigned char* msg, const unsigned long msg_len)
{
fe mont_x, mont_x_minus_one, mont_x_plus_one, inv_mont_x_plus_one;
fe one;
fe ed_y;
unsigned char ed_pubkey[32];
unsigned long long some_retval;
unsigned char verifybuf[MAX_MSG_LEN + 64]; /* working buffer */
unsigned char verifybuf2[MAX_MSG_LEN + 64]; /* working buffer #2 */
if (msg_len > MAX_MSG_LEN) {
return -1;
}
/* Convert the Curve25519 public key into an Ed25519 public key. In
particular, convert Curve25519's "montgomery" x-coordinate into an
Ed25519 "edwards" y-coordinate:
ed_y = (mont_x - 1) / (mont_x + 1)
NOTE: mont_x=-1 is converted to ed_y=0 since fe_invert is mod-exp
Then move the sign bit into the pubkey from the signature.
*/
fe_frombytes(mont_x, curve25519_pubkey);
fe_1(one);
fe_sub(mont_x_minus_one, mont_x, one);
fe_add(mont_x_plus_one, mont_x, one);
fe_invert(inv_mont_x_plus_one, mont_x_plus_one);
fe_mul(ed_y, mont_x_minus_one, inv_mont_x_plus_one);
fe_tobytes(ed_pubkey, ed_y);
/* Copy the sign bit, and remove it from signature */
ed_pubkey[31] &= 0x7F; /* bit should be zero already, but just in case */
ed_pubkey[31] |= (signature[63] & 0x80);
memmove(verifybuf, signature, 64);
verifybuf[63] &= 0x7F;
memmove(verifybuf+64, msg, msg_len);
/* Then perform a normal Ed25519 verification, return 0 on success */
/* The below call has a strange API: */
/* verifybuf = R || S || message */
/* verifybuf2 = internal to next call gets a copy of verifybuf, S gets
replaced with pubkey for hashing, then the whole thing gets zeroized
(if bad sig), or contains a copy of msg (good sig) */
return crypto_sign_open(verifybuf2, &some_retval, verifybuf, 64 + msg_len, ed_pubkey);
}

View File

@@ -0,0 +1,50 @@
#ifndef __CURVE_SIGS_H__
#define __CURVE_SIGS_H__
#define MAX_MSG_LEN 256
void curve25519_keygen(unsigned char* curve25519_pubkey_out, /* 32 bytes */
const unsigned char* curve25519_privkey_in); /* 32 bytes */
/* returns 0 on success */
int curve25519_sign(unsigned char* signature_out, /* 64 bytes */
const unsigned char* curve25519_privkey, /* 32 bytes */
const unsigned char* msg, const unsigned long msg_len,
const unsigned char* random); /* 64 bytes */
/* returns 0 on success */
int curve25519_verify(const unsigned char* signature, /* 64 bytes */
const unsigned char* curve25519_pubkey, /* 32 bytes */
const unsigned char* msg, const unsigned long msg_len);
/* helper function - modified version of crypto_sign() to use
explicit private key. In particular:
sk : private key
pk : public key
msg : message
prefix : 0xFE || [0xFF]*31
random : 64 bytes random
q : main subgroup order
The prefix is chosen to distinguish the two SHA512 uses below, since
prefix is an invalid encoding for R (it would encode a "field element"
of 2^255 - 2). 0xFF*32 is set aside for use in ECDH protocols, which
is why the first byte here ix 0xFE.
sig_nonce = SHA512(prefix || sk || msg || random) % q
R = g^sig_nonce
M = SHA512(R || pk || m)
S = sig_nonce + (m * sk)
signature = (R || S)
*/
int crypto_sign_modified(
unsigned char *sm,
const unsigned char *m,unsigned long long mlen,
const unsigned char *sk, /* Curve/Ed25519 private key */
const unsigned char *pk, /* Ed25519 public key */
const unsigned char *random /* 64 bytes random to hash into nonce */
);
#endif

View File

@@ -0,0 +1,47 @@
#include <string.h>
#include "crypto_sign.h"
#include "crypto_hash_sha512.h"
#include "ge.h"
#include "sc.h"
#include "zeroize.h"
/* NEW: Compare to pristine crypto_sign()
Uses explicit private key for nonce derivation and as scalar,
instead of deriving both from a master key.
*/
int crypto_sign_modified(
unsigned char *sm,
const unsigned char *m,unsigned long long mlen,
const unsigned char *sk, const unsigned char* pk,
const unsigned char* random
)
{
unsigned char nonce[64];
unsigned char hram[64];
ge_p3 R;
int count=0;
memmove(sm + 64,m,mlen);
memmove(sm + 32,sk,32); /* NEW: Use privkey directly for nonce derivation */
/* NEW : add prefix to separate hash uses - see .h */
sm[0] = 0xFE;
for (count = 1; count < 32; count++)
sm[count] = 0xFF;
/* NEW: add suffix of random data */
memmove(sm + mlen + 64, random, 64);
crypto_hash_sha512(nonce,sm,mlen + 128);
memmove(sm + 32,pk,32);
sc_reduce(nonce);
ge_scalarmult_base(&R,nonce);
ge_p3_tobytes(sm,&R);
crypto_hash_sha512(hram,sm,mlen + 64);
sc_reduce(hram);
sc_muladd(sm + 32,hram,sk,nonce); /* NEW: Use privkey directly */
return 0;
}

View File

@@ -0,0 +1,17 @@
#include "zeroize.h"
void zeroize(unsigned char* b, size_t len)
{
size_t count = 0;
unsigned long retval = 0;
volatile unsigned char *p = b;
for (count = 0; count < len; count++)
p[count] = 0;
}
void zeroize_stack()
{
unsigned char m[ZEROIZE_STACK_SIZE];
zeroize(m, sizeof m);
}

View File

@@ -0,0 +1,12 @@
#ifndef __ZEROIZE_H__
#define __ZEROIZE_H__
#include <stdlib.h>
#define ZEROIZE_STACK_SIZE 2048
void zeroize(unsigned char* b, size_t len);
void zeroize_stack();
#endif

View File

@@ -0,0 +1,4 @@
#define CRYPTO_SECRETKEYBYTES 64
#define CRYPTO_PUBLICKEYBYTES 32
#define CRYPTO_BYTES 64
#define CRYPTO_DETERMINISTIC 1

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
{
{ 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 },
{ -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 },
{ -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 },
},
{
{ 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 },
{ 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 },
{ 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 },
},
{
{ 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 },
{ 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 },
{ 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 },
},
{
{ 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 },
{ -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 },
{ 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 },
},
{
{ -22518993,-6692182,14201702,-8745502,-23510406,8844726,18474211,-1361450,-13062696,13821877 },
{ -6455177,-7839871,3374702,-4740862,-27098617,-10571707,31655028,-7212327,18853322,-14220951 },
{ 4566830,-12963868,-28974889,-12240689,-7602672,-2830569,-8514358,-10431137,2207753,-3209784 },
},
{
{ -25154831,-4185821,29681144,7868801,-6854661,-9423865,-12437364,-663000,-31111463,-16132436 },
{ 25576264,-2703214,7349804,-11814844,16472782,9300885,3844789,15725684,171356,6466918 },
{ 23103977,13316479,9739013,-16149481,817875,-15038942,8965339,-14088058,-30714912,16193877 },
},
{
{ -33521811,3180713,-2394130,14003687,-16903474,-16270840,17238398,4729455,-18074513,9256800 },
{ -25182317,-4174131,32336398,5036987,-21236817,11360617,22616405,9761698,-19827198,630305 },
{ -13720693,2639453,-24237460,-7406481,9494427,-5774029,-6554551,-15960994,-2449256,-14291300 },
},
{
{ -3151181,-5046075,9282714,6866145,-31907062,-863023,-18940575,15033784,25105118,-7894876 },
{ -24326370,15950226,-31801215,-14592823,-11662737,-5090925,1573892,-2625887,2198790,-15804619 },
{ -3099351,10324967,-2241613,7453183,-5446979,-2735503,-13812022,-16236442,-32461234,-12290683 },
},

View File

@@ -0,0 +1 @@
-10913610,13857413,-15372611,6949391,114729,-8787816,-6275908,-3247719,-18696448,-12055116

View File

@@ -0,0 +1 @@
-21827239,-5839606,-30745221,13898782,229458,15978800,-12551817,-6495438,29715968,9444199

View File

@@ -0,0 +1,56 @@
#ifndef FE_H
#define FE_H
#include "crypto_int32.h"
typedef crypto_int32 fe[10];
/*
fe means field element.
Here the field is \Z/(2^255-19).
An element t, entries t[0]...t[9], represents the integer
t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
Bounds on each t[i] vary depending on context.
*/
#define fe_frombytes crypto_sign_ed25519_ref10_fe_frombytes
#define fe_tobytes crypto_sign_ed25519_ref10_fe_tobytes
#define fe_copy crypto_sign_ed25519_ref10_fe_copy
#define fe_isnonzero crypto_sign_ed25519_ref10_fe_isnonzero
#define fe_isnegative crypto_sign_ed25519_ref10_fe_isnegative
#define fe_0 crypto_sign_ed25519_ref10_fe_0
#define fe_1 crypto_sign_ed25519_ref10_fe_1
#define fe_cswap crypto_sign_ed25519_ref10_fe_cswap
#define fe_cmov crypto_sign_ed25519_ref10_fe_cmov
#define fe_add crypto_sign_ed25519_ref10_fe_add
#define fe_sub crypto_sign_ed25519_ref10_fe_sub
#define fe_neg crypto_sign_ed25519_ref10_fe_neg
#define fe_mul crypto_sign_ed25519_ref10_fe_mul
#define fe_sq crypto_sign_ed25519_ref10_fe_sq
#define fe_sq2 crypto_sign_ed25519_ref10_fe_sq2
#define fe_mul121666 crypto_sign_ed25519_ref10_fe_mul121666
#define fe_invert crypto_sign_ed25519_ref10_fe_invert
#define fe_pow22523 crypto_sign_ed25519_ref10_fe_pow22523
extern void fe_frombytes(fe,const unsigned char *);
extern void fe_tobytes(unsigned char *,const fe);
extern void fe_copy(fe,const fe);
extern int fe_isnonzero(const fe);
extern int fe_isnegative(const fe);
extern void fe_0(fe);
extern void fe_1(fe);
extern void fe_cswap(fe,fe,unsigned int);
extern void fe_cmov(fe,const fe,unsigned int);
extern void fe_add(fe,const fe,const fe);
extern void fe_sub(fe,const fe,const fe);
extern void fe_neg(fe,const fe);
extern void fe_mul(fe,const fe,const fe);
extern void fe_sq(fe,const fe);
extern void fe_sq2(fe,const fe);
extern void fe_mul121666(fe,const fe);
extern void fe_invert(fe,const fe);
extern void fe_pow22523(fe,const fe);
#endif

View File

@@ -0,0 +1,19 @@
#include "fe.h"
/*
h = 0
*/
void fe_0(fe h)
{
h[0] = 0;
h[1] = 0;
h[2] = 0;
h[3] = 0;
h[4] = 0;
h[5] = 0;
h[6] = 0;
h[7] = 0;
h[8] = 0;
h[9] = 0;
}

View File

@@ -0,0 +1,19 @@
#include "fe.h"
/*
h = 1
*/
void fe_1(fe h)
{
h[0] = 1;
h[1] = 0;
h[2] = 0;
h[3] = 0;
h[4] = 0;
h[5] = 0;
h[6] = 0;
h[7] = 0;
h[8] = 0;
h[9] = 0;
}

View File

@@ -0,0 +1,57 @@
#include "fe.h"
/*
h = f + g
Can overlap h with f or g.
Preconditions:
|f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
|g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
Postconditions:
|h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
*/
void fe_add(fe h,const fe f,const fe g)
{
crypto_int32 f0 = f[0];
crypto_int32 f1 = f[1];
crypto_int32 f2 = f[2];
crypto_int32 f3 = f[3];
crypto_int32 f4 = f[4];
crypto_int32 f5 = f[5];
crypto_int32 f6 = f[6];
crypto_int32 f7 = f[7];
crypto_int32 f8 = f[8];
crypto_int32 f9 = f[9];
crypto_int32 g0 = g[0];
crypto_int32 g1 = g[1];
crypto_int32 g2 = g[2];
crypto_int32 g3 = g[3];
crypto_int32 g4 = g[4];
crypto_int32 g5 = g[5];
crypto_int32 g6 = g[6];
crypto_int32 g7 = g[7];
crypto_int32 g8 = g[8];
crypto_int32 g9 = g[9];
crypto_int32 h0 = f0 + g0;
crypto_int32 h1 = f1 + g1;
crypto_int32 h2 = f2 + g2;
crypto_int32 h3 = f3 + g3;
crypto_int32 h4 = f4 + g4;
crypto_int32 h5 = f5 + g5;
crypto_int32 h6 = f6 + g6;
crypto_int32 h7 = f7 + g7;
crypto_int32 h8 = f8 + g8;
crypto_int32 h9 = f9 + g9;
h[0] = h0;
h[1] = h1;
h[2] = h2;
h[3] = h3;
h[4] = h4;
h[5] = h5;
h[6] = h6;
h[7] = h7;
h[8] = h8;
h[9] = h9;
}

Some files were not shown because too many files have changed in this diff Show More