That fuck shit the fascists are using
1/**
2 * Copyright (C) 2011 Whisper Systems
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17package org.tm.archive;
18
19import android.os.AsyncTask;
20import android.os.Bundle;
21
22import org.tm.archive.crypto.MasterSecret;
23import org.tm.archive.crypto.MasterSecretUtil;
24import org.tm.archive.keyvalue.SignalStore;
25import org.tm.archive.util.VersionTracker;
26
27/**
28 * Activity for creating a user's local encryption passphrase.
29 *
30 * @author Moxie Marlinspike
31 */
32
33public class PassphraseCreateActivity extends PassphraseActivity {
34
35 public PassphraseCreateActivity() { }
36
37 @Override
38 public void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState);
40
41 setContentView(R.layout.create_passphrase_activity);
42
43 initializeResources();
44 }
45
46 private void initializeResources() {
47 new SecretGenerator().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
48 }
49
50 private class SecretGenerator extends AsyncTask<String, Void, Void> {
51 private MasterSecret masterSecret;
52
53 @Override
54 protected void onPreExecute() {
55 }
56
57 @Override
58 protected Void doInBackground(String... params) {
59 String passphrase = params[0];
60 masterSecret = MasterSecretUtil.generateMasterSecret(PassphraseCreateActivity.this,
61 passphrase);
62
63 MasterSecretUtil.generateAsymmetricMasterSecret(PassphraseCreateActivity.this, masterSecret);
64 SignalStore.account().generateAciIdentityKeyIfNecessary();
65 SignalStore.account().generatePniIdentityKeyIfNecessary();
66 VersionTracker.updateLastSeenVersion(PassphraseCreateActivity.this);
67
68 return null;
69 }
70
71 @Override
72 protected void onPostExecute(Void param) {
73 setMasterSecret(masterSecret);
74 }
75 }
76
77 @Override
78 protected void cleanup() {
79 System.gc();
80 }
81}