login about faq

Hi,

I'am using Android NDK on Android Studio with Experimental Plugin(gradle). I built my library successfully with chilkat but I meeting some issue. When I send a invalid input string to chilkat decrypt method (decryptStringENC), my C++ code throw a exception that have this signal: SIGSEGV and I can't use try/catch to catch it (I included cppFlags.add("-fexceptions") in gradle). I try to use a thirdparty library: https://github.com/xroche/coffeecatch but after run code block in COFFEE_CATCH, the app was still crash with exception SIGSEGV. So do you have any solution for this? Thank you.

asked Apr 06 at 02:42

Vinh%20Le's gravatar image

Vinh Le
153

edited Apr 06 at 07:41


I suspect the crash is in your code:

    rsa.put_EncodingMode("hex");
    rsa.ImportPrivateKey("hello");
    string decryptedStr = rsa.decryptStringENC(
            "hello",
            true);
    return env->NewStringUTF(decryptedStr.c_str());
The call to rsa.decryptStringENC will return 0 if it failed. You're probably trying to dereference a null pointer in your C++ code..

link

answered Apr 07 at 13:10

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Yes! My issue was solved! Thank you very much.

link

answered Apr 07 at 22:29

Vinh%20Le's gravatar image

Vinh Le
153

I don't know of how to catch the SIGSEGV, but the real solution is to fix the crash. Did this happen with the latest version of Chilkat? If not, then update to the latest version and test again.

If the crash was in the latest version, please post the string passed to decryptStringENC, along with the settings for EncodingMode, and other encryption property settings (CryptAlgorithm, CipherMode, KeyLength, etc.) If I can reproduce the problem, it is easily fixable.

link

answered Apr 06 at 08:45

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

I have downloaded lastest version. THis is my code:

string RSA::rsaDecrypt(string inputString, string privateKey) {
    string decryptedStr;
    CkRsa *rsa = Utils::getCkRsa();
    rsa->put_EncodingMode("hex");
    rsa->ImportPrivateKey(privateKey.c_str());
    decryptedStr = rsa->decryptStringENC(
            inputString.c_str(),
            true);
    return decryptedStr;

}

Anytime, if I give a invalid string to inputString (ex: "E00D"), decryptStringENC throw a error signal (SIGSEGV), then application crash. I tried to put call native method in a AsyncTask, sometime it doesn't crash but still happen many time.

For example, with these code, app will be crashed:

CkRsa rsa;
    bool success = rsa.UnlockComponent("UNLOCK KEY");
    if (success != true) {
        std::cout << rsa.lastErrorText() << "\r\n";
        return "";
    }
    rsa.put_EncodingMode("hex");
    rsa.ImportPrivateKey("hello");
    decryptedStr = rsa.decryptStringENC(
            "hello",
            true);
link

answered Apr 07 at 02:58

Vinh%20Le's gravatar image

Vinh Le
153

edited Apr 07 at 06:33

Thanks! I'll give it a try an will report back..

link

answered Apr 07 at 07:57

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

I'm not able to reproduce a crash...

link

answered Apr 07 at 10:48

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Thanks, I downloaded it and deleted your link. :-)

link

answered Apr 07 at 12:31

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Thank you. This source is built on Android Studio 1.5.1 with NDK r11 :D

(Apr 07 at 13:06) Vinh Le
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×65
×45
×10

Asked: Apr 06 at 02:42

Seen: 442 times

Last updated: Apr 07 at 22:29

powered by OSQA