android.security.KeyStoreException occuring while trying to login with Line - sdk-version:5.10.1
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 149
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
## What did you do?
> Try to authenticate users with Line.
## What did you expect?
> User's getting authenticated with Line.
## What happened actually?
Some users were experiencing crashes while trying to login with Line as we updated SDK to v5.10.1. It is occurring due to KeyStoreException. Currently this is only occurring in one particular phone model: Oppo Reno5 A.
Stack trace
```
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
at java.util.concurrent.FutureTask.run(FutureTask.java:269)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by com.linecorp.linesdk.internal.security.encryption.EncryptionException: Failed to encrypt
at com.linecorp.linesdk.internal.security.encryption.StringAesCipher.encrypt(StringAesCipher.kt:63)
at com.linecorp.linesdk.internal.AccessTokenCache.encryptString(AccessTokenCache.java:99)
at com.linecorp.linesdk.internal.AccessTokenCache.saveAccessToken(AccessTokenCache.java:60)
at com.linecorp.linesdk.auth.internal.LineAuthenticationController$AccessTokenRequestTask.doInBackground(LineAuthenticationController.java:242)
at com.linecorp.linesdk.auth.internal.LineAuthenticationController$AccessTokenRequestTask.doInBackground(LineAuthenticationController.java:203)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by java.security.ProviderException: Keystore operation failed
at android.security.keystore2.AndroidKeyStoreHmacSpi.engineDoFinal(AndroidKeyStoreHmacSpi.java:241)
at javax.crypto.Mac.doFinal(Mac.java:667)
at javax.crypto.Mac.doFinal(Mac.java:742)
at com.linecorp.linesdk.internal.security.encryption.StringAesCipher.calculateHmacValue(StringAesCipher.kt:154)
at com.linecorp.linesdk.internal.security.encryption.StringAesCipher.encrypt(StringAesCipher.kt:60)
at com.linecorp.linesdk.internal.AccessTokenCache.encryptString(AccessTokenCache.java:99)
at com.linecorp.linesdk.internal.AccessTokenCache.saveAccessToken(AccessTokenCache.java:60)
at com.linecorp.linesdk.auth.internal.LineAuthenticationController$AccessTokenRequestTask.doInBackground(LineAuthenticationController.java:242)
at com.linecorp.linesdk.auth.internal.LineAuthenticationController$AccessTokenRequestTask.doInBackground(LineAuthenticationController.java:203)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by android.security.KeyStoreException: Invalid operation handle
at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:356)
at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
at android.security.KeyStoreOperation.finish(KeyStoreOperation.java:127)
```
## Your environment?
> LINE SDK version 5.10.1
Andorid version -12
Phone Model - Oppo Reno5 A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing LINE login on Android 12 with SDK 5.10.1 on the Oppo Reno5 A, then trace the failure through LineAuthenticationController, AccessTokenCache.java, and StringAesCipher.kt. Investigate the reported KeyStoreException during token encryption; done means login completes without the crash and the access token is saved successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100