1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.security.keymaster;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * @hide
24  * The information aggregated by this class is used by keystore to identify a caller of the
25  * keystore API toward a remote party. It aggregates multiple PackageInfos because keystore
26  * can only determine a caller by uid granularity, and a uid can be shared by multiple packages.
27  * The remote party must decide if it trusts all of the packages enough to consider the
28  * confidentiality of the key material in question intact.
29  */
30 public class KeyAttestationApplicationId implements Parcelable {
31     private final KeyAttestationPackageInfo[] mAttestationPackageInfos;
32 
33     /**
34      * @param mAttestationPackageInfos
35      */
KeyAttestationApplicationId(KeyAttestationPackageInfo[] mAttestationPackageInfos)36     public KeyAttestationApplicationId(KeyAttestationPackageInfo[] mAttestationPackageInfos) {
37         super();
38         this.mAttestationPackageInfos = mAttestationPackageInfos;
39     }
40 
41     /**
42      * @return the mAttestationPackageInfos
43      */
getAttestationPackageInfos()44     public KeyAttestationPackageInfo[] getAttestationPackageInfos() {
45         return mAttestationPackageInfos;
46     }
47 
48     @Override
describeContents()49     public int describeContents() {
50         return 0;
51     }
52 
53     @Override
writeToParcel(Parcel dest, int flags)54     public void writeToParcel(Parcel dest, int flags) {
55         dest.writeTypedArray(mAttestationPackageInfos, flags);
56     }
57 
58     public static final @android.annotation.NonNull Parcelable.Creator<KeyAttestationApplicationId> CREATOR
59             = new Parcelable.Creator<KeyAttestationApplicationId>() {
60         @Override
61         public KeyAttestationApplicationId createFromParcel(Parcel source) {
62             return new KeyAttestationApplicationId(source);
63         }
64 
65         @Override
66         public KeyAttestationApplicationId[] newArray(int size) {
67             return new KeyAttestationApplicationId[size];
68         }
69     };
70 
KeyAttestationApplicationId(Parcel source)71     KeyAttestationApplicationId(Parcel source) {
72         mAttestationPackageInfos = source.createTypedArray(KeyAttestationPackageInfo.CREATOR);
73     }
74 }
75