Stay organized with collections
Save and categorize content based on your preferences.
AttestedKeyPair
class AttestedKeyPair
The AttestedKeyPair
class contains a KeyPair
instance of keys generated by Keystore and owned by KeyChain, as well as an attestation record for the key.
Such keys can be obtained by calling android.app.admin.DevicePolicyManager#generateKeyPair
.
Summary
Public constructors |
Public constructor for creating a new instance (useful for testing).
|
Public methods |
MutableList<Certificate!> |
Returns the attestation record for the key pair in this instance.
|
KeyPair? |
Returns the generated key pair associated with the attestation record in this instance.
|
Public constructors
AttestedKeyPair
AttestedKeyPair(
keyPair: KeyPair?,
attestationRecord: MutableList<Certificate!>)
Public constructor for creating a new instance (useful for testing).
Parameters |
keyPair |
KeyPair?: the key pair associated with the attestation record. This value may be null . |
attestationRecord |
MutableList<Certificate!>: attestation record for the provided key pair. This value cannot be null . |
Public methods
getAttestationRecord
fun getAttestationRecord(): MutableList<Certificate!>
Returns the attestation record for the key pair in this instance. The attestation record is a chain of certificates. The leaf certificate links to the public key of this key pair and other properties of the key or the device. If the key is in secure hardware, and if the secure hardware supports attestation, the leaf certificate will be signed by a chain of certificates rooted at a trustworthy CA key. Otherwise the chain will be rooted at an untrusted certificate. The attestation record could be for properties of the key, or include device identifiers. See android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge
and Key Attestation for the format of the attestation record inside the certificate.
getKeyPair
fun getKeyPair(): KeyPair?
Returns the generated key pair associated with the attestation record in this instance.
Return |
KeyPair? |
This value may be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AttestedKeyPair\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAttestedKeyPair\n===============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/security/AttestedKeyPair \"View this page in Java\") \n\n```\nclass AttestedKeyPair\n```\n\n|---|---------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.security.AttestedKeyPair](#) |\n\nThe `AttestedKeyPair` class contains a `KeyPair` instance of keys generated by Keystore and owned by KeyChain, as well as an attestation record for the key.\n\nSuch keys can be obtained by calling [android.app.admin.DevicePolicyManager#generateKeyPair](../app/admin/DevicePolicyManager.html#generateKeyPair(android.content.ComponentName,%20kotlin.String,%20android.security.keystore.KeyGenParameterSpec,%20kotlin.Int)).\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [AttestedKeyPair](#AttestedKeyPair(java.security.KeyPair,%20kotlin.collections.MutableList))`(`keyPair:` `[KeyPair](../../java/security/KeyPair.html#)?`, `attestationRecord:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\u003c[Certificate](../../java/security/cert/Certificate.html#)!\u003e`)` Public constructor for creating a new instance (useful for testing). |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|\n| [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\\\u003c[Certificate](../../java/security/cert/Certificate.html#)!\\\u003e | [getAttestationRecord](#getAttestationRecord())`()` Returns the attestation record for the key pair in this instance. |\n| [KeyPair](../../java/security/KeyPair.html#)? | [getKeyPair](#getKeyPair())`()` Returns the generated key pair associated with the attestation record in this instance. |\n\nPublic constructors\n-------------------\n\n### AttestedKeyPair\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nAttestedKeyPair(\n keyPair: KeyPair?, \n attestationRecord: MutableList\u003cCertificate!\u003e)\n```\n\nPublic constructor for creating a new instance (useful for testing).\n\n| Parameters ||\n|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `keyPair` | [KeyPair](../../java/security/KeyPair.html#)?: the key pair associated with the attestation record. This value may be `null`. |\n| `attestationRecord` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\\\u003c[Certificate](../../java/security/cert/Certificate.html#)!\\\u003e: attestation record for the provided key pair. This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### getAttestationRecord\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getAttestationRecord(): MutableList\u003cCertificate!\u003e\n```\n\nReturns the attestation record for the key pair in this instance. The attestation record is a chain of certificates. The leaf certificate links to the public key of this key pair and other properties of the key or the device. If the key is in secure hardware, and if the secure hardware supports attestation, the leaf certificate will be signed by a chain of certificates rooted at a trustworthy CA key. Otherwise the chain will be rooted at an untrusted certificate. The attestation record could be for properties of the key, or include device identifiers. See [android.security.keystore.KeyGenParameterSpec.Builder#setAttestationChallenge](/reference/kotlin/android/security/keystore/KeyGenParameterSpec.Builder#setAttestationChallenge(kotlin.ByteArray)) and [Key Attestation](https://developer.android.com/training/articles/security-key-attestation.html) for the format of the attestation record inside the certificate.\n\n| Return ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|\n| [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\u003c[Certificate](../../java/security/cert/Certificate.html#)!\u003e | This value cannot be `null`. |\n\n### getKeyPair\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getKeyPair(): KeyPair?\n```\n\nReturns the generated key pair associated with the attestation record in this instance.\n\n| Return ||\n|-----------------------------------------------|---------------------------|\n| [KeyPair](../../java/security/KeyPair.html#)? | This value may be `null`. |"]]