Search in sources :

Example 1 with KeyStoreHandler

use of com.toshi.crypto.keyStore.KeyStoreHandler in project toshi-android-client by toshiapp.

the class HDWallet method readMasterSeedFromStorage.

private String readMasterSeedFromStorage() {
    try {
        final KeyStoreHandler keyStoreHandler = new KeyStoreHandler(BaseApplication.get(), ALIAS);
        final String encryptedMasterSeed = this.prefs.getString(MASTER_SEED, null);
        if (encryptedMasterSeed == null)
            return null;
        return keyStoreHandler.decrypt(encryptedMasterSeed, this::saveMasterSeed);
    } catch (KeyStoreException e) {
        LogUtil.exception("Error while reading master seed from storage", e);
        throw new IllegalStateException(e);
    }
}
Also used : KeyStoreHandler(com.toshi.crypto.keyStore.KeyStoreHandler) KeyStoreException(com.toshi.exception.KeyStoreException)

Example 2 with KeyStoreHandler

use of com.toshi.crypto.keyStore.KeyStoreHandler in project toshi-android-client by toshiapp.

the class HDWallet method saveMasterSeedToStorage.

private void saveMasterSeedToStorage(final String masterSeed) {
    try {
        final KeyStoreHandler keyStoreHandler = new KeyStoreHandler(BaseApplication.get(), ALIAS);
        final String encryptedMasterSeed = keyStoreHandler.encrypt(masterSeed);
        saveMasterSeed(encryptedMasterSeed);
        this.masterSeed = masterSeed;
    } catch (KeyStoreException e) {
        LogUtil.exception("Error while saving master seed from storage", e);
        throw new IllegalStateException(e);
    }
}
Also used : KeyStoreHandler(com.toshi.crypto.keyStore.KeyStoreHandler) KeyStoreException(com.toshi.exception.KeyStoreException)

Aggregations

KeyStoreHandler (com.toshi.crypto.keyStore.KeyStoreHandler)2 KeyStoreException (com.toshi.exception.KeyStoreException)2