Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:08:23+00:00 2026-05-31T08:08:23+00:00

I have an Android crypto app that’s built with Bouncy Castle (actually using Spongy

  • 0

I have an Android crypto app that’s built with Bouncy Castle (actually using Spongy Castle but essentially the same thing). For some reason key generation is EXTREMELY slow (on the order of several minutes).

Here is a test method I’m using:

@Test
public void testHMAC()
{
    System.out.println(getTestAnnouncement("testHMAC"));

    long start = System.currentTimeMillis();

    final PBEParametersGenerator generator = new PKCS5S2ParametersGenerator();
    generator.init(PBEParametersGenerator.PKCS5PasswordToBytes(("mypassword").toCharArray()), new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 8192);
    byte[] key = ((KeyParameter)generator.generateDerivedParameters(256)).getKey();

    long time = System.currentTimeMillis() - start;
    Assert.assertTrue("Generated " + key.length + "-byte key, took " + time + "ms", true);
}

When I run this on my 2.4 GHz Intel Core 2 Duo machine, it takes around 0.05 seconds (50 ms). When I run that same method on Android, it takes several hundred thousand milliseconds (i.e. ~3-5 minutes).

I’m running it on an HTC Thunderbolt running Android 2.2.1. The application targets 2.1, if that makes any difference (I remember reading something about < 2.2 not having JIT but I assume the app target would make no difference, as long as the actual OS on the phone is >= 2.2). This is a pretty powerful phone which has a 1 GHz Snapdragon processor, and it seems strange that generating a key would take that many orders of magnitude longer than on a PC. What are possible causes of this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:08:25+00:00Added an answer on May 31, 2026 at 8:08 am

    Jake, although the tracing JIT should work well with Crypto library, can you try doing this with the NDK? From what I’ve heard, even after the JIT, the performance improvement on the NDK is significant. (Of the order of 10-50x)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have an Android project that branched into three different applications, app-1 , app-2
I have Android application which is Sales Rep application.When he using the app first
I have learned that when using android:entries with a ListView , it uses android.R.layout.simple_list_item_1
I have android application that I need to debug using eclipse. When I right
I have android app that talks to server and syncs some data int SQLite
I have an Android app that looks absolutely horrible if the user sets their
I have an Android app that I would like to convert to an Android
I have built OpenSSL for Android(using ndk-build) and have linked it to my program.
I'm using SpongyCastle (full implementation of BouncyCastle's crypto functions for Android) and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.