Merge pull request #4 from cybertier/hotfix-encrypt-sync-infos

fix sync information encryption
pull/5/head
Felix PK 2019-07-15 17:47:41 +02:00 committed by GitHub
commit 7df3bf491c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -68,7 +68,6 @@ public class ExchangeActivity extends AppCompatActivity {
uploadInformation = new UploadInformation(); uploadInformation = new UploadInformation();
publicKeyQr = generatePublicKeyBitmap(); publicKeyQr = generatePublicKeyBitmap();
dataQr = generateLocalSyncInfoBitmap();
setSyncState(SyncState.KEY_EXCHANGE); setSyncState(SyncState.KEY_EXCHANGE);
} }
@ -112,7 +111,7 @@ public class ExchangeActivity extends AppCompatActivity {
private Bitmap generateLocalSyncInfoBitmap() { private Bitmap generateLocalSyncInfoBitmap() {
uploadInformation.setLocal(generateLocalSyncInfo()); uploadInformation.setLocal(generateLocalSyncInfo());
return qrCodeGenerator.generateQrCode(new Gson().toJson(uploadInformation.getLocal())); return qrCodeGenerator.generateQrCode(diffieHellman.encrypt(new Gson().toJson(uploadInformation.getLocal())));
} }
private SyncInformation generateLocalSyncInfo() { private SyncInformation generateLocalSyncInfo() {
@ -273,6 +272,7 @@ public class ExchangeActivity extends AppCompatActivity {
try { try {
diffieHellman.setForeignPublicKey(DiffieHellman.publicKeyFromString(qrData)); diffieHellman.setForeignPublicKey(DiffieHellman.publicKeyFromString(qrData));
setSyncState(SyncState.KEY_EXCHANGE_DONE); setSyncState(SyncState.KEY_EXCHANGE_DONE);
dataQr = generateLocalSyncInfoBitmap();
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) { } catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
if (currentReadQrStatus == ReadQrStatus.PENDING) { if (currentReadQrStatus == ReadQrStatus.PENDING) {
setReadQrStatus(ReadQrStatus.FAILURE); setReadQrStatus(ReadQrStatus.FAILURE);