Problems to decrypt and encrypted key using chilkat sshkey.
I'm setting up an SFTP transfer between an Android terminal and a linux server via SFTP. I did create a key using openssh (ssh-keygen) and tested the key via another linux box. It works nicely. I'm trying now to do the same from the Android. I loaded the private key on the device
CkSshKey key = new CkSshKey(); String privKey = key.loadText();
I set up the passphrase used to generate the key key.put_Password(mPrefs.getSftpSapPass()); / <- is a string
and I'm sure is loaded because I did check with getPassword :
CkString checkPwd = new CkString();
key.get_Password(checkPwd);
if (checkPwd == null) {
Log.d(TAG, "Password not assigned");
key.get_LastMethodSuccess();
Log.i(TAG, "Put Password : " + key.lastErrorText());
} else {
Log.d(TAG, "Assigned password : " + checkPwd.getString());
Log.i(TAG, "Info : " + key.lastErrorText());
}
Then I try to load the key : key.FromOpenSshPrivateKey(privKey);
and it fails !
FromOpenSshPrivateKey:
DllDate: Jul 26 2019
ChilkatVersion: 9.5.0.79
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Android Java
VerboseLogging: 0
fromOpenSshPrivateKey:
loadPem2:
loadPem:
itemType: RSA PRIVATE KEY
addPemItem:
decryptPem:
sbMime: Content-Transfer-Encoding: base64
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,FFC30E1594858F31B5D56E104A01A401
NGtNvFQ+lk3kZMIBX1oTHhY4xDWdaS3OMGQFE8h/r8k4gPMpTSAdKUMWj2qr4x3Z ...................................... kOf7SEY02vMyiYj9A8iSw91qYR7esn1rMOpScdYwp5K65KHgUukrtDR4zRaLHjAT
encryptionAlg: AES-128-CBC
ivNumBytes: 16
encNumBytes: 2352
decNumBytes: 2352
--decryptPem
Failed to load private key...
--addPemItem
Failed to add PEM item.
--loadPem
Failed to load PEM
--loadPem2
Check the password, it may be
The passphrase is correct. What can be ? The passphrase I used contains spaces, could be that the problem ? Any hint can helps !!!
Thanks
Ok, did find the problem, maybe can be useful to somebody else. Apparently the chilkat library doesn't use "passphrase". Instead of a passphrase with spaces and/or special characters, I had to set up a password with no spaces/special characters.
For example, originally I used: "This is a passphrase you're using"
Not working.
But also "This_is_a_passphrase_you're_using" did not work. Then I did try : "This_is_a_passphrase_youre_using" .. the same, i.e. not working.
In the end to have the authentication working I used : "ThisIsAPassphraseYoureUsing"
Steve