Problems with Android SecretKeyFactory. No implementation found?

I am trying to create an Android application that uses encryption to store user information, and I cannot understand what I am doing wrong. I am trying to create an instance of SecretKeyFactory using the "PBKDF2WithHmacSHA1" algorithm, but the application continues to throw exceptions at this point in the program (it does not matter whether it is in the emulator or on real hardware).

the code:

SecretKeyFactory secretFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 

An exception:

java.security.NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found ...

Here's the strange thing ... if I take this code and compile it as a regular Java application, it works ... no exceptions arise, and I can create encrypted files (and decrypt them) without errors.

I also tried to introduce other algorithms (e.g. AES, PBEWithHmacSHA1AndDESede, PBEWithMD5AndDES, etc.), and they all produce the same error / exception on this line in the code (when compiling for Android).

I have the latest version of Java (JDK 1.6.0.18) installed, all updates applied to Eclipse and plugins, and the latest version of the Android SDK. I also use the 64-bit version of Windows 7.

Please help, I did not find an answer to this after two days of searching the Internet. Thanks.

+6
java android encryption
source share
3 answers

It may just be an unsupported algorithm or its purpose on Android.

Have you looked at the javax.crypto classes? https://developer.android.com/reference/javax/crypto/EncryptedPrivateKeyInfo.html

Here is an example of using a different algorithm if this helps. http://www.anddev.org/viewtopic.php?p=11737

btw, add the "from-irc" tag to this post to get a Google response. http://android-developers.blogspot.com/2010/01/irc-offce-hours-update.html

+4
source share

This means that the Android SDK does not have an implementation for this algorithm. You have two options:

  • switch to another supported algorithm (I cannot find the link, so try them manually)
  • provide implementation of its own algorithm
+4
source share

Is there any 3-part implementation that can be used on Android? For example, Firefox Sync uses PBKDF2WithHmacSHA1, so there is no option for me to switch to another algorithm, as this is what I am trying to decrypt.

+1
source share

All Articles