2016-11-19 7 views
-1

午前アプリ用の指紋認証を使用しています。以下のAPI 23もサポートしたい。そのためにはFingerprintManagerCompatを使用しています。コード午前以下は主なAndroid API 23の下でキーとチッパーの開始を生成する方法は?

protected void generateKey() { 
    try { 
     keyStore = KeyStore.getInstance("AndroidKeyStore"); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    try { 
     keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore"); 
    } catch (NoSuchAlgorithmException | 
      NoSuchProviderException e) { 
     throw new RuntimeException("Failed to get KeyGenerator instance", e); 
    } 

    try { 
     keyStore.load(null); 
     keyGenerator.init(new 
       KeyGenParameterSpec.Builder(KEY_NAME, 
       KeyProperties.PURPOSE_ENCRYPT | 
         KeyProperties.PURPOSE_DECRYPT) 
       .setBlockModes(KeyProperties.BLOCK_MODE_CBC) 
       .setUserAuthenticationRequired(true) 
       .setEncryptionPaddings(
         KeyProperties.ENCRYPTION_PADDING_PKCS7) 
       .build()); 
     keyGenerator.generateKey(); 
    } catch (NoSuchAlgorithmException | 
      InvalidAlgorithmParameterException 
      | CertificateException | IOException e) { 
     throw new RuntimeException(e); 
    } 
} 

を生成します - 私は、API 23に使用しています前のAndroid APIにコードの下に23

をキーChiper開始を生成する方法がわかりませんAPI 23に使用される - Chiper開始

public boolean cipherInit() { 
    try { 
     cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); 
    } catch (NoSuchAlgorithmException | 
      NoSuchPaddingException e) { 
     throw new RuntimeException("Failed to get Cipher", e); 
    } 

    try { 
     keyStore.load(null); 
     SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null); 
     cipher.init(Cipher.ENCRYPT_MODE, key); 
     return true; 
    } catch (KeyStoreException | CertificateException 
      | UnrecoverableKeyException | IOException 
      | NoSuchAlgorithmException | InvalidKeyException e) { 
     throw new RuntimeException("Failed to init Cipher", e); 
    } 
} 

私はこれら二つのことを開始する方法がわかりませんPre API 23でFingerprintManagerCompatにアクセスするには、この問題の解決に手伝ってください。

答えて

0

FingerprintManagerは、マッシュマロ前のデバイスでは使用できません。彼らは指定されたMarshamallowにこのAPIを追加しましたhere

+0

指紋センサーをこのlink .Sampleプロジェクトを見ることができます。 – Yugesh

0

いいえAPI 23(Marshmallow 6.0)の下でキーと暗号を生成できません。

一部のAndroidデバイスは、API 21以下の指紋センサーを持っていますが、アンドロイドは、APIのみ23サポートとabove.Youは指紋authentication.SamsungがPass SDKすなわち、指紋認証のために独自のSDKを提供するために彼らのSDKを使用する必要があります。

あなたは指紋認証のためのAPI 21と一部の携帯電話で利用可能なhere

関連する問題