Add remnant local changes

This commit is contained in:
Alexander Bakker 2017-08-02 21:29:27 +02:00
parent a5c6c329ab
commit c79c9f84dc
5 changed files with 30 additions and 27 deletions

View file

@ -5,12 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.widget.Toast;
import agency.tango.materialintroscreen.MaterialIntroActivity; import agency.tango.materialintroscreen.MaterialIntroActivity;
import agency.tango.materialintroscreen.MessageButtonBehaviour; import agency.tango.materialintroscreen.MessageButtonBehaviour;
@ -23,21 +18,21 @@ public class IntroActivity extends MaterialIntroActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
addSlide(new SlideFragmentBuilder() addSlide(new SlideFragmentBuilder()
.backgroundColor(R.color.colorPrimary) .backgroundColor(R.color.colorPrimary)
.buttonsColor(R.color.colorAccent) .buttonsColor(R.color.colorAccent)
.image(R.drawable.intro_shield) .image(R.drawable.intro_shield)
.title("Welcome") .title("Welcome")
.description("Aegis is a brand new open source(!) authenticator app which generates tokens for your accounts.") .description("Aegis is a brand new open source(!) authenticator app which generates tokens for your accounts.")
.build()); .build());
addSlide(new SlideFragmentBuilder() addSlide(new SlideFragmentBuilder()
.backgroundColor(R.color.colorAccent) .backgroundColor(R.color.colorAccent)
.buttonsColor(R.color.colorPrimary) .buttonsColor(R.color.colorPrimary)
.neededPermissions(new String[]{Manifest.permission.CAMERA}) .neededPermissions(new String[]{Manifest.permission.CAMERA})
.image(R.drawable.intro_scanner) .image(R.drawable.intro_scanner)
.title("Permissions") .title("Permissions")
.description("Aegis needs permission to your camera in order to function properly. This is needed to scan QR codes.") .description("Aegis needs permission to your camera in order to function properly. This is needed to scan QR codes.")
.build(), .build(),
new MessageButtonBehaviour(new View.OnClickListener() { new MessageButtonBehaviour(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -52,5 +47,4 @@ public class IntroActivity extends MaterialIntroActivity {
SharedPreferences prefs = this.getSharedPreferences("me.impy.aegis", Context.MODE_PRIVATE); SharedPreferences prefs = this.getSharedPreferences("me.impy.aegis", Context.MODE_PRIVATE);
prefs.edit().putBoolean("passedIntro", true).apply(); prefs.edit().putBoolean("passedIntro", true).apply();
} }
} }

View file

@ -369,7 +369,7 @@ public class MainActivity extends AppCompatActivity {
databaseFile = new DatabaseFile(); databaseFile = new DatabaseFile();
try { try {
masterKey = new MasterKey(null); masterKey = MasterKey.generate();
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
// TODO: tell the user to stop using a weird platform // TODO: tell the user to stop using a weird platform
throw new UndeclaredThrowableException(e); throw new UndeclaredThrowableException(e);

View file

@ -25,6 +25,7 @@ public class CryptoUtils {
public static final byte CRYPTO_KEY_SIZE = 32; public static final byte CRYPTO_KEY_SIZE = 32;
public static final byte CRYPTO_NONCE_SIZE = 12; public static final byte CRYPTO_NONCE_SIZE = 12;
public static final byte CRYPTO_SALT_SIZE = 32; public static final byte CRYPTO_SALT_SIZE = 32;
// TODO: decide on a 'secure-enough' iteration count
public static final short CRYPTO_ITERATION_COUNT = 10000; public static final short CRYPTO_ITERATION_COUNT = 10000;
public static final String CRYPTO_CIPHER_RAW = "AES/ECB/NoPadding"; public static final String CRYPTO_CIPHER_RAW = "AES/ECB/NoPadding";
public static final String CRYPTO_CIPHER_AEAD = "AES/GCM/NoPadding"; public static final String CRYPTO_CIPHER_AEAD = "AES/GCM/NoPadding";

View file

@ -16,13 +16,22 @@ import me.impy.aegis.crypto.slots.Slot;
public class MasterKey { public class MasterKey {
private SecretKey _key; private SecretKey _key;
public MasterKey(SecretKey key) throws NoSuchAlgorithmException { public MasterKey(SecretKey key) {
if (key == null) { if (key == null) {
key = CryptoUtils.generateKey(); throw new NullPointerException();
} }
_key = key; _key = key;
} }
public static MasterKey generate() throws NoSuchAlgorithmException {
return new MasterKey(CryptoUtils.generateKey());
}
public void encryptSlot(Slot slot, Cipher cipher)
throws BadPaddingException, IllegalBlockSizeException {
slot.setKey(_key, cipher);
}
public static MasterKey decryptSlot(Slot slot, Cipher cipher) public static MasterKey decryptSlot(Slot slot, Cipher cipher)
throws BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException { throws BadPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException {
return new MasterKey(slot.getKey(cipher)); return new MasterKey(slot.getKey(cipher));
@ -41,8 +50,4 @@ public class MasterKey {
Cipher cipher = CryptoUtils.createCipher(_key, Cipher.DECRYPT_MODE, params.Nonce); Cipher cipher = CryptoUtils.createCipher(_key, Cipher.DECRYPT_MODE, params.Nonce);
return CryptoUtils.decrypt(bytes, cipher, params); return CryptoUtils.decrypt(bytes, cipher, params);
} }
public void encryptSlot(Slot slot, Cipher cipher) throws BadPaddingException, IllegalBlockSizeException {
slot.setKey(_key, cipher);
}
} }

View file

@ -1,5 +1,8 @@
package me.impy.aegis.crypto.slots; package me.impy.aegis.crypto.slots;
public class FingerprintSlot extends RawSlot { public class FingerprintSlot extends RawSlot {
@Override
public byte getType() {
return TYPE_FINGERPRINT;
}
} }