Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found #31

Closed
savekirk opened this issue Mar 6, 2015 · 23 comments
Closed

SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found #31

savekirk opened this issue Mar 6, 2015 · 23 comments
Assignees
Labels

Comments

@savekirk
Copy link

savekirk commented Mar 6, 2015

Thanks for creating this.

I am trying to use Hawk in one of my projects but getting the bellow error on some Samsung devices:

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

Any workaround for that?.
Thanks.

@orhanobut orhanobut added the bug label Mar 6, 2015
@orhanobut
Copy link
Owner

Let us check for this issue. Which samsung device exactly are you using and android version?

@savekirk
Copy link
Author

savekirk commented Mar 6, 2015

samsung GT-S5282 - 4.1.2
samsung GT-I8190 - 4.1.2
samsung GT-S5300 - 2.3.6

@csechuan
Copy link

csechuan commented Apr 8, 2015

And samsung GT-I9100G - 4.1.2
Not always happen though but enough to kill my app :(

@Christophe668
Copy link

Same problem in my app:
Here is the stacktrace.

java.lang.RuntimeException: Unable to create application MeteoApp: java.lang.RuntimeException: java.security.NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4233)
       at android.app.ActivityThread.access$1300(ActivityThread.java:137)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4827)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.RuntimeException: java.security.NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found
       at com.orhanobut.hawk.AesEncryption.generateSecretKey(AesEncryption.java:84)
       at com.orhanobut.hawk.AesEncryption.<init>(AesEncryption.java:25)
       at com.orhanobut.hawk.Hawk.init(Hawk.java:68)
       at com.orhanobut.hawk.Hawk.init(Hawk.java:54)
       at MeteoApp.onCreate(MeteoApp.java:57)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4230)
       at android.app.ActivityThread.access$1300(ActivityThread.java:137)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4827)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.security.NoSuchAlgorithmException: SecretKeyFactory PBKDF2WithHmacSHA1 implementation not found
       at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
       at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
       at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:108)
       at com.orhanobut.hawk.AesCbcWithIntegrity.generateKeyFromPassword(AesCbcWithIntegrity.java:159)
       at com.orhanobut.hawk.AesCbcWithIntegrity.generateKeyFromPassword(AesCbcWithIntegrity.java:185)
       at com.orhanobut.hawk.AesEncryption.generateSecretKey(AesEncryption.java:82)
       at com.orhanobut.hawk.AesEncryption.<init>(AesEncryption.java:25)
       at com.orhanobut.hawk.Hawk.init(Hawk.java:68)
       at com.orhanobut.hawk.Hawk.init(Hawk.java:54)
       at MeteoApp.onCreate(MeteoApp.java:57)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4230)
       at android.app.ActivityThread.access$1300(ActivityThread.java:137)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1271)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4827)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
       at dalvik.system.NativeStart.main(NativeStart.java)

It happens on these devices :

screen shot 2015-05-07 at 09 56 56

screen shot 2015-05-07 at 09 57 32

This is a great library but it cannot be used on a production app used by a lot of people. The crash rate increase really quickly with that crash.

@orhanobut
Copy link
Owner

I started working on this issue, apparently some devices don't have this algorithm. I think today I'll create a new version with the fix

@Christophe668
Copy link

Thanks a lot ! If you need more info, I will be glad to help you

@aligurelli
Copy link

i have same problem too, thanks a lot. We are waiting for new build :)

@orhanobut
Copy link
Owner

Soon, there will be a new release, I'll update this post for the snapshot version, if it works we can release it. Thanks for the feedback really.

@orhanobut
Copy link
Owner

@aligurelli @Christophe668 @csechuan @sakirk I uploaded a new snapshot version with a fallback fix, could you try with this please? I don't have these devices and cannot test properly unfortunately, I just did some mockup.

snapshot version is

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
    compile 'com.orhanobut:hawk:1.7-SNAPSHOT'
}

If everything works properly, I'll put a new release.

@csechuan
Copy link

csechuan commented May 9, 2015

Thx. Will test it out. You replace encryption with conceal?

@orhanobut
Copy link
Owner

@csechuan no, I didn't use conceal, I just added a fallback to another key generation. I also updated the snapshot version with a new quick fix. Please try below.

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
    compile 'com.orhanobut:hawk:1.9-SNAPSHOT'
}

@Christophe668
Copy link

Thx @orhanobut. Unfortunately I don't have a device affected by this issue so if I release this update it would be launched on a large set of user. Do you think it is stable enough to be released on a production app with a large set of user?

@orhanobut
Copy link
Owner

Best would be to wait for the release version. I also dont have these devices but gonna check this at work. This should fix this issue permanently but still need a good test.

I will keep to update this post. It would be great if someone check this version as well :(

@csechuan
Copy link

So far so good.

@orhanobut
Copy link
Owner

@csechuan Do you have this problem anymore so far? That would be great feedback if you have tried and test it in a device that was affected this issue, Thanks

@csechuan
Copy link

Has a little problem.

Caused by java.lang.NullPointerException
com.orhanobut.hawk.Hawk.encode (Hawk.java:167)
com.orhanobut.hawk.Hawk.put (Hawk.java:131)

@orhanobut
Copy link
Owner

I think the secretkeyfactory problem is solved, today I'll release a new build including this NPE.

@csechuan
Copy link

Wait. Not yet.
When I release my app, it cant start hawk at all.

E/AndroidRuntime﹕ FATAL EXCEPTION: pool-2-thread-1
java.lang.NullPointerException
at io.abc.app.g.d.a(ELog.java:12)
at io.abc.app.g.d.a(ELog.java:20)
at io.abc.app.Hello$1.a(Hello.java:45)
at com.e.a.m$1.run(Hawk.java:110)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

@orhanobut
Copy link
Owner

Can you try without proguard? and can you also tell me which android version? you may need to add some config in the proguard. I tested in a few devices, had no problem at all. Can you also tell me how do you init hawk?

@orhanobut
Copy link
Owner

@csechuan I think this issue is related to something, can we move this issue to another thread please? While creating issue, could you also show me the exception without proguard if possible and also the value might be null?

@csechuan
Copy link

Ok. I found out the problem is with Gson itself. Gson cant serialize / deserialize enums after pro-guarded, so have to make exceptions on those enum thingy.
I am using ver 1.8, so far no problem with NPE. Thanks for solving this. I think we can close this.

@orhanobut
Copy link
Owner

That's great news. I'll close this issue. @csechuan thanks for testing.

@Christophe668
Copy link

Thank you @orhanobut for this fix and @csechuan for testing !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants