tink-crypto / tink

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
https://developers.google.com/tink
Apache License 2.0
13.5k stars 1.18k forks source link

Request: remove warning log of EncryptedSharedPreferences :"keyset not found, will generate a new one" #534

Closed AndroidDeveloperLB closed 1 year ago

AndroidDeveloperLB commented 3 years ago

I was told to create a request about this here: https://issuetracker.google.com/issues/185219606

nikunjparadva commented 2 years ago

Yes I also facing the same issue

You can check logs here.

2022-08-02 10:52:12.016 25975-25975/com.akaita.encryptedsharedpreferences I/AndroidKeysetManager: keyset not found, will generate a new one
    java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_value_keyset__ does not exist
        at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.readPref(SharedPrefKeysetReader.java:71)
        at com.google.crypto.tink.integration.android.SharedPrefKeysetReader.readEncrypted(SharedPrefKeysetReader.java:89)
        at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:116)
        at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.read(AndroidKeysetManager.java:311)
        at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readOrGenerateNewKeyset(AndroidKeysetManager.java:287)
        at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:238)
        at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:160)
        at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:120)
juergw commented 1 year ago

I think this issue was addressed in https://github.com/google/tink/commit/3c5b2a887c8d13529c33ca28c196a7fc55825032, where the stack trace was replaced with a simple log message.

I'll leave it as it is for now, at least until https://github.com/google/tink/issues/535 is resolved.

AndroidDeveloperLB commented 1 year ago

Yes it was removed recently. Sadly not sure about the rare exceptions , though

juergw commented 1 year ago

I changed my mind. I think this log message is more confusing than helpful. Let's remove it completely.

AndroidDeveloperLB commented 1 year ago

@juergw Wasn't it removed? Please check.

juergw commented 1 year ago

I think it will still log by default, according to what https://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String,%20int) says. So I will change it to "verbose", so the logging is turned off by default, and the user can still turn it on if they want to.

AndroidDeveloperLB commented 1 year ago

@juergw Please check on latest version.

juergw commented 1 year ago

Yes, the lastest version of jetpack (https://developer.android.com/jetpack/androidx/releases/security#1.1.0-alpha04) says that the log message was removed, and references b/185219606. Which is marked as fixed. But I don't see what was changed.

juergw commented 1 year ago

I've now changed the logging to only log in verbose mode, https://github.com/google/tink/commit/cb67a3a9e3acce588cb00f7b2da384be1d48290a.