Example usage for android.security KeyChain isBoundKeyAlgorithm

List of usage examples for android.security KeyChain isBoundKeyAlgorithm

Introduction

In this page you can find the example usage for android.security KeyChain isBoundKeyAlgorithm.

Prototype

@Deprecated
public static boolean isBoundKeyAlgorithm(@NonNull @KeyProperties.KeyAlgorithmEnum String algorithm) 

Source Link

Document

Returns true if the current device's KeyChain binds any PrivateKey of the given algorithm to the device once imported or generated.

Usage

From source file:com.example.android.vault.VaultProvider.java

@Override
public boolean onCreate() {
    mHardwareBacked = KeyChain.isBoundKeyAlgorithm("RSA");

    mKeyFile = new File(getContext().getFilesDir(), "vault.key");
    mDocumentsDir = new File(getContext().getFilesDir(), "documents");
    mDocumentsDir.mkdirs();/* w w w  .j  a v  a  2s . c o  m*/

    try {
        // Load secret key and ensure our root document is ready.
        loadOrGenerateKeys(getContext(), mKeyFile);
        initDocument(Long.parseLong(DEFAULT_DOCUMENT_ID), Document.MIME_TYPE_DIR, null);

    } catch (IOException e) {
        throw new IllegalStateException(e);
    } catch (GeneralSecurityException e) {
        throw new IllegalStateException(e);
    }

    return true;
}