2012-07-31 17:02:50 -07:00
|
|
|
/**
|
2011-12-20 10:20:44 -08:00
|
|
|
* Copyright (C) 2011 Whisper Systems
|
2012-07-31 17:02:50 -07:00
|
|
|
*
|
2011-12-20 10:20:44 -08:00
|
|
|
* 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.
|
2012-07-31 17:02:50 -07:00
|
|
|
*
|
2011-12-20 10:20:44 -08:00
|
|
|
* 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;
|
|
|
|
|
2012-12-01 15:57:44 -08:00
|
|
|
import android.os.AsyncTask;
|
2011-12-20 10:20:44 -08:00
|
|
|
import android.os.Bundle;
|
2014-07-21 23:44:01 -10:00
|
|
|
|
2012-07-31 17:02:50 -07:00
|
|
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2012-07-31 17:02:50 -07:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2015-10-01 15:21:21 -07:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2013-05-07 16:31:11 -07:00
|
|
|
import org.thoughtcrime.securesms.util.VersionTracker;
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
/**
|
|
|
|
* Activity for creating a user's local encryption passphrase.
|
2012-07-31 17:02:50 -07:00
|
|
|
*
|
2011-12-20 10:20:44 -08:00
|
|
|
* @author Moxie Marlinspike
|
|
|
|
*/
|
2012-09-30 19:56:29 -07:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
public class PassphraseCreateActivity extends PassphraseActivity {
|
|
|
|
|
2012-09-30 19:56:29 -07:00
|
|
|
public PassphraseCreateActivity() { }
|
2011-12-20 10:20:44 -08:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
setContentView(R.layout.create_passphrase_activity);
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
initializeResources();
|
|
|
|
}
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
private void initializeResources() {
|
2017-10-23 13:03:32 -07:00
|
|
|
new SecretGenerator().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
2014-01-07 16:27:00 -08:00
|
|
|
}
|
|
|
|
|
2012-12-01 15:57:44 -08:00
|
|
|
private class SecretGenerator extends AsyncTask<String, Void, Void> {
|
|
|
|
private MasterSecret masterSecret;
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2012-12-01 15:57:44 -08:00
|
|
|
@Override
|
|
|
|
protected void onPreExecute() {
|
2011-12-20 10:20:44 -08:00
|
|
|
}
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
@Override
|
2012-12-01 15:57:44 -08:00
|
|
|
protected Void doInBackground(String... params) {
|
|
|
|
String passphrase = params[0];
|
|
|
|
masterSecret = MasterSecretUtil.generateMasterSecret(PassphraseCreateActivity.this,
|
|
|
|
passphrase);
|
|
|
|
|
|
|
|
MasterSecretUtil.generateAsymmetricMasterSecret(PassphraseCreateActivity.this, masterSecret);
|
2019-08-19 15:34:21 +10:00
|
|
|
IdentityKeyUtil.generateIdentityKeyPair(PassphraseCreateActivity.this);
|
2013-05-07 16:31:11 -07:00
|
|
|
VersionTracker.updateLastSeenVersion(PassphraseCreateActivity.this);
|
2018-01-24 19:17:44 -08:00
|
|
|
|
2019-05-28 19:57:06 -03:00
|
|
|
TextSecurePreferences.setLastExperienceVersionCode(PassphraseCreateActivity.this, Util.getCanonicalVersionCode());
|
2015-03-05 13:09:18 -08:00
|
|
|
TextSecurePreferences.setPasswordDisabled(PassphraseCreateActivity.this, true);
|
2017-09-15 22:38:53 -07:00
|
|
|
TextSecurePreferences.setReadReceiptsEnabled(PassphraseCreateActivity.this, true);
|
2018-10-29 15:14:31 -07:00
|
|
|
TextSecurePreferences.setTypingIndicatorsEnabled(PassphraseCreateActivity.this, true);
|
2019-02-13 11:52:55 -08:00
|
|
|
TextSecurePreferences.setHasSeenWelcomeScreen(PassphraseCreateActivity.this, false);
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2012-12-01 15:57:44 -08:00
|
|
|
return null;
|
2011-12-20 10:20:44 -08:00
|
|
|
}
|
2012-07-31 17:02:50 -07:00
|
|
|
|
2012-12-01 15:57:44 -08:00
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Void param) {
|
|
|
|
setMasterSecret(masterSecret);
|
2011-12-20 10:20:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void cleanup() {
|
|
|
|
System.gc();
|
|
|
|
}
|
|
|
|
}
|