line / line/line-sdk-android

LineLoginApi.getLoginIntent throws javax.crypto.KeyGenerator.generateKey exception

Open
#167 0 comments 2 reactions 0 assignees View on GitHub

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?

Tried to create login intent:

```
val authParams = LineAuthenticationParams.Builder()
.scopes(listOf(Scope.PROFILE, Scope.OPENID_CONNECT, Scope.OC_EMAIL))
.build()

val intent = LineLoginApi.getLoginIntent(context, "mychannelId", authParams)

```

The issue happens only to some users, in most cases it works fine. Happens on different devices and Android version, we couldn't find any relation between them.

## What did you expect?

Intent created properly

## What happened actually?
Exception is thrown

```
android.security.keystore2.AndroidKeyStoreKeyGeneratorSpi.engineGenerateKey (AndroidKeyStoreKeyGeneratorSpi.java:413)
javax.crypto.KeyGenerator.generateKey (KeyGenerator.java:612)
com.linecorp.android.security.encryption.StringAesCipher.createAesKey (StringAesCipher.kt:132)
com.linecorp.android.security.encryption.StringAesCipher.getAesSecretKey (StringAesCipher.kt:98)
com.linecorp.android.security.encryption.StringAesCipher.initialize (StringAesCipher.kt:36)
com.linecorp.linesdk.internal.EncryptorHolder$EncryptorInitializationTask.run (EncryptorHolder.java:48)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
java.lang.Thread.run (Thread.java:1012)
```

## Your environment?

Line SDK version: 5.10.0
Android Studio version: Android Studio Iguana | 2023.2.1
Happens on different devices and android versions. Highest Android version of reported crash is Android 13.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing LineLoginApi.getLoginIntent through EncryptorHolder.java and StringAesCipher.kt, especially getAesSecretKey and createAesKey around line 132. Reproduce the reported flow on the affected Android versions or devices and investigate the Android Keystore exception. Done means the login intent is created without the KeyGenerator.generateKey failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, kotlin
Domain
authentication, mobile, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.