session-android/src/org/thoughtcrime/securesms/PassphraseCreateActivity.java

87 lines
2.7 KiB
Java
Raw Normal View History

/**
2011-12-20 18:20:44 +00:00
* Copyright (C) 2011 Whisper Systems
*
2011-12-20 18:20:44 +00: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.
*
2011-12-20 18:20:44 +00: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;
import android.os.AsyncTask;
2011-12-20 18:20:44 +00:00
import android.os.Bundle;
2014-06-29 03:40:57 +00:00
import android.support.v7.app.ActionBar;
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.VersionTracker;
2011-12-20 18:20:44 +00:00
/**
* Activity for creating a user's local encryption passphrase.
*
2011-12-20 18:20:44 +00:00
* @author Moxie Marlinspike
*/
2012-10-01 02:56:29 +00:00
2011-12-20 18:20:44 +00:00
public class PassphraseCreateActivity extends PassphraseActivity {
2012-10-01 02:56:29 +00:00
public PassphraseCreateActivity() { }
2011-12-20 18:20:44 +00:00
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
2011-12-20 18:20:44 +00:00
setContentView(R.layout.create_passphrase_activity);
2011-12-20 18:20:44 +00:00
initializeResources();
}
2011-12-20 18:20:44 +00:00
private void initializeResources() {
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.light_centered_app_title);
new SecretGenerator().execute(MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
}
private class SecretGenerator extends AsyncTask<String, Void, Void> {
private MasterSecret masterSecret;
@Override
protected void onPreExecute() {
2011-12-20 18:20:44 +00:00
}
2011-12-20 18:20:44 +00:00
@Override
protected Void doInBackground(String... params) {
String passphrase = params[0];
masterSecret = MasterSecretUtil.generateMasterSecret(PassphraseCreateActivity.this,
passphrase);
MasterSecretUtil.generateAsymmetricMasterSecret(PassphraseCreateActivity.this, masterSecret);
IdentityKeyUtil.generateIdentityKeys(PassphraseCreateActivity.this, masterSecret);
VersionTracker.updateLastSeenVersion(PassphraseCreateActivity.this);
TextSecurePreferences.setPasswordDisabled(PassphraseCreateActivity.this, true);
return null;
2011-12-20 18:20:44 +00:00
}
@Override
protected void onPostExecute(Void param) {
setMasterSecret(masterSecret);
2011-12-20 18:20:44 +00:00
}
}
@Override
protected void cleanup() {
System.gc();
}
}