Merge "Add attestation API to Android KeyStore." into nyc-dev

This commit is contained in:
Shawn Willden
2016-02-09 22:57:23 +00:00
committed by Android (Google) Code Review
12 changed files with 392 additions and 81 deletions

View File

@@ -19,6 +19,7 @@ package android.security;
import android.security.keymaster.ExportResult;
import android.security.keymaster.KeyCharacteristics;
import android.security.keymaster.KeymasterArguments;
import android.security.keymaster.KeymasterCertificateChain;
import android.security.keymaster.KeymasterBlob;
import android.security.keymaster.OperationResult;
import android.security.KeystoreArguments;
@@ -74,4 +75,5 @@ interface IKeystoreService {
int addAuthToken(in byte[] authToken);
int onUserAdded(int userId, int parentId);
int onUserRemoved(int userId);
int attestKey(String alias, in KeymasterArguments params, out KeymasterCertificateChain chain);
}

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.security.keymaster;
/* @hide */
parcelable KeymasterCertificateChain;

View File

@@ -0,0 +1,85 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.security.keymaster;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
/**
* Utility class for the Java side of keystore-generated certificate chains.
*
* Serialization code for this must be kept in sync with system/security/keystore
* @hide
*/
public class KeymasterCertificateChain implements Parcelable {
private List<byte[]> mCertificates;
public static final Parcelable.Creator<KeymasterCertificateChain> CREATOR = new
Parcelable.Creator<KeymasterCertificateChain>() {
public KeymasterCertificateChain createFromParcel(Parcel in) {
return new KeymasterCertificateChain(in);
}
public KeymasterCertificateChain[] newArray(int size) {
return new KeymasterCertificateChain[size];
}
};
public KeymasterCertificateChain() {
mCertificates = null;
}
public KeymasterCertificateChain(List<byte[]> mCertificates) {
this.mCertificates = mCertificates;
}
private KeymasterCertificateChain(Parcel in) {
readFromParcel(in);
}
public List<byte[]> getCertificates() {
return mCertificates;
}
@Override
public void writeToParcel(Parcel out, int flags) {
if (mCertificates == null) {
out.writeInt(0);
} else {
out.writeInt(mCertificates.size());
for (byte[] arg : mCertificates) {
out.writeByteArray(arg);
}
}
}
public void readFromParcel(Parcel in) {
int length = in.readInt();
mCertificates = new ArrayList<byte[]>(length);
for (int i = 0; i < length; i++) {
mCertificates.add(in.createByteArray());
}
}
@Override
public int describeContents() {
return 0;
}
}

View File

@@ -58,6 +58,8 @@ public final class KeymasterDefs {
public static final int KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 705;
public static final int KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200;
public static final int KM_TAG_INCLUDE_UNIQUE_ID = KM_BOOL | 202;
public static final int KM_TAG_ACTIVE_DATETIME = KM_DATE | 400;
public static final int KM_TAG_ORIGINATION_EXPIRE_DATETIME = KM_DATE | 401;
public static final int KM_TAG_USAGE_EXPIRE_DATETIME = KM_DATE | 402;
@@ -74,11 +76,12 @@ public final class KeymasterDefs {
public static final int KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600;
public static final int KM_TAG_APPLICATION_ID = KM_BYTES | 601;
public static final int KM_TAG_APPLICATION_DATA = KM_BYTES | 700;
public static final int KM_TAG_CREATION_DATETIME = KM_DATE | 701;
public static final int KM_TAG_ORIGIN = KM_ENUM | 702;
public static final int KM_TAG_ROLLBACK_RESISTANT = KM_BOOL | 703;
public static final int KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704;
public static final int KM_TAG_UNIQUE_ID = KM_BYTES | 707;
public static final int KM_TAG_ATTESTATION_CHALLENGE = KM_BYTES | 708;
public static final int KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000;
public static final int KM_TAG_NONCE = KM_BYTES | 1001;