forked from hardcoresushi/DroidFS
XChaCha20-Ploy1305 support
This commit is contained in:
parent
a377b61240
commit
e47d9f4548
@ -1 +1 @@
|
|||||||
Subproject commit f0e45c7b7e428f13667edd3b8d73501e15322a04
|
Subproject commit bd5d53f50eb274ed084e9f363ccfbe30d9061039
|
@ -4,7 +4,8 @@ import android.content.Intent
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.view.View
|
||||||
|
import android.widget.*
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import sushi.hardcore.droidfs.databinding.ActivityCreateBinding
|
import sushi.hardcore.droidfs.databinding.ActivityCreateBinding
|
||||||
import sushi.hardcore.droidfs.explorers.ExplorerActivity
|
import sushi.hardcore.droidfs.explorers.ExplorerActivity
|
||||||
@ -29,6 +30,25 @@ class CreateActivity : VolumeActionActivity() {
|
|||||||
createVolume()
|
createVolume()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
binding.spinnerXchacha.adapter = ArrayAdapter(
|
||||||
|
this@CreateActivity,
|
||||||
|
android.R.layout.simple_spinner_item,
|
||||||
|
resources.getStringArray(R.array.encryption_cipher)
|
||||||
|
).apply {
|
||||||
|
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
}
|
||||||
|
binding.spinnerXchacha.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
|
if (position == 1) {
|
||||||
|
ColoredAlertDialogBuilder(this@CreateActivity)
|
||||||
|
.setTitle(R.string.warning)
|
||||||
|
.setMessage(R.string.xchacha_warning)
|
||||||
|
.setPositiveButton(R.string.ok, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||||
|
}
|
||||||
binding.buttonCreate.setOnClickListener {
|
binding.buttonCreate.setOnClickListener {
|
||||||
createVolume()
|
createVolume()
|
||||||
}
|
}
|
||||||
@ -112,7 +132,12 @@ class CreateActivity : VolumeActionActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (goodDirectory) {
|
if (goodDirectory) {
|
||||||
if (GocryptfsVolume.createVolume(currentVolumePath, password, false, GocryptfsVolume.ScryptDefaultLogN, ConstValues.creator)) {
|
val xchacha = when (binding.spinnerXchacha.selectedItemPosition) {
|
||||||
|
0 -> 0
|
||||||
|
1 -> 1
|
||||||
|
else -> -1
|
||||||
|
}
|
||||||
|
if (GocryptfsVolume.createVolume(currentVolumePath, password, false, xchacha, GocryptfsVolume.ScryptDefaultLogN, ConstValues.creator)) {
|
||||||
var returnedHash: ByteArray? = null
|
var returnedHash: ByteArray? = null
|
||||||
if (checkboxSavePassword.isChecked){
|
if (checkboxSavePassword.isChecked){
|
||||||
returnedHash = ByteArray(GocryptfsVolume.KeyLen)
|
returnedHash = ByteArray(GocryptfsVolume.KeyLen)
|
||||||
|
@ -30,7 +30,7 @@ class GocryptfsVolume(var sessionID: Int) {
|
|||||||
const val KeyLen = 32
|
const val KeyLen = 32
|
||||||
const val ScryptDefaultLogN = 16
|
const val ScryptDefaultLogN = 16
|
||||||
const val DefaultBS = 4096
|
const val DefaultBS = 4096
|
||||||
external fun createVolume(root_cipher_dir: String, password: CharArray, plainTextNames: Boolean, logN: Int, creator: String): Boolean
|
external fun createVolume(root_cipher_dir: String, password: CharArray, plainTextNames: Boolean, xchacha: Int, logN: Int, creator: String): Boolean
|
||||||
external fun init(root_cipher_dir: String, password: CharArray?, givenHash: ByteArray?, returnedHash: ByteArray?): Int
|
external fun init(root_cipher_dir: String, password: CharArray?, givenHash: ByteArray?, returnedHash: ByteArray?): Int
|
||||||
external fun changePassword(root_cipher_dir: String, old_password: CharArray?, givenHash: ByteArray?, new_password: CharArray, returnedHash: ByteArray?): Boolean
|
external fun changePassword(root_cipher_dir: String, old_password: CharArray?, givenHash: ByteArray?, new_password: CharArray, returnedHash: ByteArray?): Boolean
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ JNIEXPORT jboolean JNICALL
|
|||||||
Java_sushi_hardcore_droidfs_GocryptfsVolume_00024Companion_createVolume(JNIEnv *env, jclass clazz,
|
Java_sushi_hardcore_droidfs_GocryptfsVolume_00024Companion_createVolume(JNIEnv *env, jclass clazz,
|
||||||
jstring jroot_cipher_dir, jcharArray jpassword,
|
jstring jroot_cipher_dir, jcharArray jpassword,
|
||||||
jboolean plainTextNames,
|
jboolean plainTextNames,
|
||||||
|
jint xchacha,
|
||||||
jint logN,
|
jint logN,
|
||||||
jstring jcreator) {
|
jstring jcreator) {
|
||||||
const char* root_cipher_dir = (*env)->GetStringUTFChars(env, jroot_cipher_dir, NULL);
|
const char* root_cipher_dir = (*env)->GetStringUTFChars(env, jroot_cipher_dir, NULL);
|
||||||
@ -45,7 +46,7 @@ Java_sushi_hardcore_droidfs_GocryptfsVolume_00024Companion_createVolume(JNIEnv *
|
|||||||
jcharArray_to_charArray(jchar_password, password, password_len);
|
jcharArray_to_charArray(jchar_password, password, password_len);
|
||||||
GoSlice go_password = {password, password_len, password_len};
|
GoSlice go_password = {password, password_len, password_len};
|
||||||
|
|
||||||
GoUint8 result = gcf_create_volume(gofilename, go_password, plainTextNames, logN, gocreator);
|
GoUint8 result = gcf_create_volume(gofilename, go_password, plainTextNames, xchacha, logN, gocreator);
|
||||||
|
|
||||||
(*env)->ReleaseStringUTFChars(env, jroot_cipher_dir, root_cipher_dir);
|
(*env)->ReleaseStringUTFChars(env, jroot_cipher_dir, root_cipher_dir);
|
||||||
(*env)->ReleaseStringUTFChars(env, jcreator, creator);
|
(*env)->ReleaseStringUTFChars(env, jcreator, creator);
|
||||||
|
@ -59,6 +59,24 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="15dp"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/encryption_cipher_label"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinner_xchacha"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<include layout="@layout/checkboxes_section"/>
|
<include layout="@layout/checkboxes_section"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
<string-array name="encryption_cipher">
|
||||||
|
<item>AES-GCM</item>
|
||||||
|
<item>XChaCha20-Poly1305</item>
|
||||||
|
<item>@string/auto</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="sort_orders_entries">
|
<string-array name="sort_orders_entries">
|
||||||
<item>Name</item>
|
<item>Name</item>
|
||||||
<item>Size</item>
|
<item>Size</item>
|
||||||
|
@ -206,4 +206,7 @@
|
|||||||
<string name="camera_optimization">Camera optimization</string>
|
<string name="camera_optimization">Camera optimization</string>
|
||||||
<string name="maximize_quality">Maximize quality</string>
|
<string name="maximize_quality">Maximize quality</string>
|
||||||
<string name="minimize_latency">Minimize latency</string>
|
<string name="minimize_latency">Minimize latency</string>
|
||||||
|
<string name="auto">Auto</string>
|
||||||
|
<string name="xchacha_warning">XChaCha20-Poly1305 is only supported since gocryptfs v2.2.0. Older versions won\'t be able to open a volume based on this cipher.</string>
|
||||||
|
<string name="encryption_cipher_label">Encryption cipher:</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user