Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/security/AttestedKeyPair#pubctors) \| [Methods](https://developer.android.com/reference/android/security/AttestedKeyPair#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/security/AttestedKeyPair#inhmethods)

# AttestedKeyPair

*** ** * ** ***


`
public

final

class
AttestedKeyPair
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.security.AttestedKeyPair |

<br />

*** ** * ** ***

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
`https://developer.android.com/reference/android/app/admin/DevicePolicyManager#generateKeyPair(android.content.ComponentName,%20java.lang.String,%20android.security.keystore.KeyGenParameterSpec,%20int)`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/security/AttestedKeyPair#AttestedKeyPair(java.security.KeyPair,%20java.util.List<java.security.cert.Certificate>)(https://developer.android.com/reference/java/security/KeyPair keyPair, https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/security/cert/Certificate> attestationRecord) ` Public constructor for creating a new instance (useful for testing). |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/security/cert/Certificate>` | ` https://developer.android.com/reference/android/security/AttestedKeyPair#getAttestationRecord()() ` Returns the attestation record for the key pair in this instance. |
| ` https://developer.android.com/reference/java/security/KeyPair` | ` https://developer.android.com/reference/android/security/AttestedKeyPair#getKeyPair()() ` Returns the generated key pair associated with the attestation record in this instance. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### AttestedKeyPair

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AttestedKeyPair (KeyPair keyPair, 
                List<Certificate> attestationRecord)
```

Public constructor for creating a new instance (useful for testing).

<br />

| Parameters ||
|---|---|
| `keyPair` | `KeyPair`: the key pair associated with the attestation record. This value may be `null`. <br /> |
| `attestationRecord` | `List`: attestation record for the provided key pair. This value cannot be `null`. <br /> |

## Public methods

### getAttestationRecord

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<Certificate> getAttestationRecord ()
```

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 `https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setAttestationChallenge(byte[])`
and [Key Attestation](https://developer.android.com/training/articles/security-key-attestation.html) for the format of the attestation record inside the certificate.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/security/cert/Certificate>` | This value cannot be `null`. <br /> |

### getKeyPair

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public KeyPair getKeyPair ()
```

Returns the generated key pair associated with the attestation record
in this instance.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/KeyPair` | This value may be `null`. <br /> |