Android: Stop using jsch

Instead use the c-lib for the ssh keygeneration. This should reduce our
APK size a little bit, but most importantly we'll be using the exact
same code for osx and android.
This commit is contained in:
Vishesh Handa
2019-05-29 14:57:55 +02:00
parent 2bcd609776
commit ce316d6811
3 changed files with 6 additions and 20 deletions

View File

@ -102,8 +102,6 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.jcraft:jsch:0.1.54'
// For reading a file to string
implementation 'commons-io:commons-io:2.5'
}

View File

@ -42,6 +42,7 @@ add_library(native-lib
SHARED
${CMAKE_SOURCE_DIR}/../../../../../gj_common/gitjournal.c
${CMAKE_SOURCE_DIR}/../../../../../gj_common/keygen.c
${CMAKE_SOURCE_DIR}/../../../../../gj_common/common.c
git.c
)

View File

@ -3,14 +3,12 @@ package io.gitjournal.gitjournal;
import android.os.AsyncTask;
import android.util.Log;
import com.jcraft.jsch.*;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.commons.io.FileUtils;
import io.flutter.plugin.common.MethodChannel.Result;
public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
@ -41,21 +39,10 @@ public class GenerateSSHKeysTask extends AsyncTask<String, Void, Void> {
return null;
}
// Generate key pair
try {
JSch jsch = new JSch();
KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, 1024 * 4);
kpair.writePrivateKey(privateKeyPath);
kpair.writePublicKey(publicKeyPath, comment);
kpair.dispose();
} catch (JSchException ex) {
Log.d(TAG, ex.toString());
result.error("FAILED", ex.getMessage(), null);
return null;
} catch (IOException ex) {
Log.d(TAG, ex.toString());
result.error("FAILED", ex.getMessage(), null);
io.gitjournal.gitjournal.Git git = new io.gitjournal.gitjournal.Git();
String errorStr = git.generateKeys(privateKeyPath, publicKeyPath, comment);
if (!errorStr.isEmpty()) {
result.error("FAILED", errorStr, null);
return null;
}