ContriHUB / Just-Share

Android app that enables quick transfer of photos, videos, documents, and audio files using WiFiDirect and Bluetooth.
MIT License
0 stars 7 forks source link

feat: Implement Encryption with Hash Digest #10

Open anushkaVerma1007 opened 1 month ago

anushkaVerma1007 commented 1 month ago

🚀 ### Feature: Implement Chunk-Based Data Encryption and Integrity Verification for Secure Data Transfer

Description

This pull request implements a mechanism for encrypting data in chunks before transfer and decrypting it after transfer completion as described in issue #3. The changes include the generation of a hash digest for each chunk to ensure data integrity during transmission. The changes involves:

Related Issue

Fixes #3

Type of change

Motivation and Context

This change is required to enhance data security during transfers, addressing vulnerabilities associated with unencrypted data. Implementing encryption and integrity checks mitigates risks related to interception and tampering.

How Has This Been Tested?

Screenshots (if appropriate):

Checklist:

Test Configuration:

anushkaVerma1007 commented 1 month ago

sir, Please review my pull request.

SaiDheerajPeketi commented 1 month ago

@anushkaVerma1007, since you are using AES, the key used on encryption side and decryption side should be the same. How is the key getting transferred between devices?

Where are the functions generateHash and verifyHash getting called on Data Block?

anushkaVerma1007 commented 1 month ago

@SaiDheerajPeketi , apologies for the oversight. I have implemented the generateHash and verifyHash, but not integrated. The should be generated before sending the data, and on the recievers side, it should be verfied after decryption. Is this correct approach?

SaiDheerajPeketi commented 1 month ago

If you are generating hash on sender's side after encryption then you have to verify before decryption on receiver's side. This would be the better approach compared to calculating hash before encryption.

anushkaVerma1007 commented 1 month ago

@SaiDheerajPeketi yes sir this is correct approach to do the task..

Pra-San commented 1 month ago

@anushkaVerma1007 Any updates?

anushkaVerma1007 commented 1 month ago

@Pra-San sir can I correct my implementation and submit another pull request ?

Pra-San commented 1 month ago

@anushkaVerma1007 you can update this PR once you are done with your implementation.

SaiDheerajPeketi commented 1 month ago

@anushkaVerma1007 Any updates?

Pra-San commented 1 month ago

@anushkaVerma1007 Transfer process is crashing with the error: FATAL EXCEPTION: main Process: com.invincible.jedishare, PID: 31591 java.lang.IllegalStateException: AES key not initialized! at com.invincible.jedishare.data.chat.BluetoothDataTransferService$sendMessage$2.invokeSuspend(BluetoothDataTransferService.kt:146) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@dc3cdaf, Dispatchers.Main.immediate]