GithubHelp home page GithubHelp logo

Comments (11)

tholenst avatar tholenst commented on July 20, 2024 1

I see, thank you.

I will have to contact this team then. Did you already file an issue for androidx.security? If so, I will reuse that.

Also, did you try different versions of androidx.security? If so, what was the result?

from tink.

tholenst avatar tholenst commented on July 20, 2024 1

You may be able to test it if you tell gradle explicitly that you need at least Tink 1.9. I don't know Gradle at all, so I cannot help you with how to do that.

But basically, if you can say explicitly that you need com.google.crypto.tink:tink-android:1.9.0 the issue should go away.

I filed an issue in the Google internal bug tracker, I hope that they can soon upgrade androidx.security:security-crypto:1.1.0-alpha06. I didn't find a public component for this.

Please wait a week and then Ping this issue if there is no new release.

from tink.

GuilhE avatar GuilhE commented on July 20, 2024 1

I filed an issue in the Google internal bug tracker, I hope that they can soon upgrade androidx.security:security-crypto:1.1.0-alpha06. I didn't find a public component for this.

Thanks, I was indeed trying to find on Google Issue Tracker but I couldn't also, only for generic AndroidX.

You may be able to test it if you tell gradle explicitly that you need at least Tink 1.9. I don't know Gradle at all, so I cannot help you with how to do that.

But basically, if you can say explicitly that you need com.google.crypto.tink:tink-android:1.9.0 the issue should go away.

This makes a lot of sense, and the way to do that is by doing the following:

implementation("androidx.security:security-crypto:1.1.0-alpha06") {
     exclude(group = "com.google.crypto.tink", module = "tink-android")
}
implementation("com.google.crypto.tink:tink-android:1.9.0")

And it works 🥳

But now I end up again with the runtime error which made me think it was a false positive. A bit of research and I found that either way I need to add the following rules:

# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation

This leaves me with 2 solutions:

  • With the new rules, add the following and leave the dependency as is:
-dontwarn com.google.api.client.http.**
-dontwarn org.joda.time.**
  • With the new rules, exclude the dependency on 1.8.0 and force 1.9.0

Which do you think is the cleanest/safest? I prefer the second because as soon as the security-crypto uses officially the 1.9.0 I just need to remove the gradle configuration. Having the 2 new rules added sounds like code smell 😅

from tink.

tholenst avatar tholenst commented on July 20, 2024 1

Can you expand on the runtime error? A stacktrace would be helpful.

Please do try to use 1.9.0 -- in the end, we do fix a problem with 1.9.0 over 1.8.0, and if there is another problem we need to debug that one too. We will upgrade to 1.9.0 anyhow, and if it doesn't work then you cannot avoid it in the medium term.

from tink.

tholenst avatar tholenst commented on July 20, 2024

Hey, thanks for the report.

What version of Tink do you use?

In general, the dependencies referenced (http-client and joda-time) are needed for the class com.google.crypto.tink.util.KeysDownloader -- and we didn't list them in early versions of Tink. We later added them, but they really shouldn't be there: unless you use exactly KeysDownloader directly, Tink doesn't need them.

Are you using tink-android? They shouldn't be there.

from tink.

GuilhE avatar GuilhE commented on July 20, 2024

I'm not using Tink directly, only via androidx.security:security-crypto:1.1.0-alpha06

from tink.

morambro avatar morambro commented on July 20, 2024

androidx.security:security-crypto:1.1.0-alpha06 depends on com.google.crypto.tink:tink-android:1.8.0 (source) which doesn't explicitly depend on http-client (source). I am not very familiar with R8, but if IIUC adding -dontwarn com.google.api.client.http.* and -dontwarn org.joda.time.* to theproguard-rules.pro file (https://developer.android.com/build/shrink-code#configuration-files) should solve the issue.

from tink.

tholenst avatar tholenst commented on July 20, 2024

Oh I see. And somehow in 1.8 we included the keys downloader by mistake :(

https://github.com/tink-crypto/tink-java/blob/1.8/BUILD.bazel#L696-L699

This should be fixed with 1.9 though: https://github.com/tink-crypto/tink-java/blob/1.9/BUILD.bazel#L780-L782

So what remains to do is for someone to try to see if androidx.security:security-crypto can update to 1.9

from tink.

GuilhE avatar GuilhE commented on July 20, 2024

androidx.security:security-crypto:1.1.0-alpha06 depends on com.google.crypto.tink:tink-android:1.8.0 (source) which doesn't explicitly depend on http-client (source). I am not very familiar with R8, but if IIUC adding -dontwarn com.google.api.client.http.* and -dontwarn org.joda.time.* to theproguard-rules.pro file (https://developer.android.com/build/shrink-code#configuration-files) should solve the issue.

This doesn't work, by adding:

-dontwarn com.google.api.client.http.**
-dontwarn org.joda.time.**

The build will succeed (because it mutes the warnings/errors) but then it will fail in runtime:

java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:46) at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:39)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202)
at retrofit2.Retrofit$1.invoke(Retrofit.java:160)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy3.login(Unknown Source)
...

I'm using EncryptedSharedPreferences to store some credentials.

Oh I see. And somehow in 1.8 we included the keys downloader by mistake :(

https://github.com/tink-crypto/tink-java/blob/1.8/BUILD.bazel#L696-L699

This should be fixed with 1.9 though: https://github.com/tink-crypto/tink-java/blob/1.9/BUILD.bazel#L780-L782

So what remains to do is for someone to try to see if androidx.security:security-crypto can update to 1.9

Is it something I can test on my end?

I will have to contact this team then. Did you already file an issue for androidx.security? If so, I will reuse that.

I have not, I'll so you can reuse 😉

from tink.

GuilhE avatar GuilhE commented on July 20, 2024

The runtime error was a false positive towards Tink, the stacktrace was relative to coroutines and retrofit, thus the 3 proguard rules that also saved the day 🙏🏼

from tink.

tholenst avatar tholenst commented on July 20, 2024

I will mark this as finished as you said it was a false positive. I will also do another release as in Java Tink 1.9.0 still has some problems with regard to this class. However, if anyone has still issues with this, please comment here or open a new issue in https://github.com/tink-crypto/tink-java

from tink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.