summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/AttestedKeyPair.java
diff options
context:
space:
mode:
authorEran Messeri <eranm@google.com>2019-08-23 13:37:43 +0100
committerEran Messeri <eranm@google.com>2019-08-23 15:33:16 +0100
commite7a65b65e55253d74dd3a9899b62f285d014b74e (patch)
treec19a1a6f8737d8a0edab5c758fe7fe4ee7d36f50 /keystore/java/android/security/AttestedKeyPair.java
parente1025e8228591197ba691c4d4f98dee9224c082b (diff)
AttestedKeyPair: Address API review comments
Make AttestedKeyPair c'tor accept a List<Certificate> rather than Certificate[] to match the getter method on this class. To make it easier to use this class from other framework code I've re-instantiated the c'tor with a certificate array which will convert the array to a list. Bug: 139092002 Test: cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement Change-Id: Ie80dcb28f112efa89d3cc6fdceb1b9e5e26c58b1
Diffstat (limited to 'keystore/java/android/security/AttestedKeyPair.java')
-rw-r--r--keystore/java/android/security/AttestedKeyPair.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/keystore/java/android/security/AttestedKeyPair.java b/keystore/java/android/security/AttestedKeyPair.java
index 2debfee83923..19fbdac16576 100644
--- a/keystore/java/android/security/AttestedKeyPair.java
+++ b/keystore/java/android/security/AttestedKeyPair.java
@@ -23,6 +23,7 @@ import java.security.KeyPair;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -36,7 +37,7 @@ import java.util.List;
public final class AttestedKeyPair {
private final KeyPair mKeyPair;
- private final Certificate[] mAttestationRecord;
+ private final List<Certificate> mAttestationRecord;
/**
* Public constructor for creating a new instance (useful for testing).
@@ -44,12 +45,25 @@ public final class AttestedKeyPair {
* @param keyPair the key pair associated with the attestation record.
* @param attestationRecord attestation record for the provided key pair.
*/
- public AttestedKeyPair(@Nullable KeyPair keyPair, @Nullable Certificate[] attestationRecord) {
+ public AttestedKeyPair(
+ @Nullable KeyPair keyPair, @NonNull List<Certificate> attestationRecord) {
mKeyPair = keyPair;
mAttestationRecord = attestationRecord;
}
/**
+ * @hide used by platform.
+ */
+ public AttestedKeyPair(@Nullable KeyPair keyPair, @Nullable Certificate[] attestationRecord) {
+ mKeyPair = keyPair;
+ if (attestationRecord == null) {
+ mAttestationRecord = new ArrayList();
+ } else {
+ mAttestationRecord = Arrays.asList(attestationRecord);
+ }
+ }
+
+ /**
* Returns the generated key pair associated with the attestation record
* in this instance.
*/
@@ -73,9 +87,6 @@ public final class AttestedKeyPair {
* Key Attestation</a> for the format of the attestation record inside the certificate.
*/
public @NonNull List<Certificate> getAttestationRecord() {
- if (mAttestationRecord == null) {
- return new ArrayList();
- }
- return Arrays.asList(mAttestationRecord);
+ return Collections.unmodifiableList(mAttestationRecord);
}
}