blob: a93d1e113eec473ca14453a4cf39dd18a0050bf6 [file] [log] [blame]
Janis Danisevskis8ff1e192016-06-03 11:31:55 -07001/*
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
17package android.security.keymaster;
18
19import android.content.pm.Signature;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
24 * @hide
25 * This class constitutes and excerpt from the PackageManager's PackageInfo for the purpose of
26 * key attestation. It is part of the KeyAttestationApplicationId, which is used by
27 * keystore to identify the caller of the keystore API towards a remote party.
28 */
29public class KeyAttestationPackageInfo implements Parcelable {
30 private final String mPackageName;
Dianne Hackborn3accca02013-09-20 09:32:11 -070031 private final long mPackageVersionCode;
Janis Danisevskis8ff1e192016-06-03 11:31:55 -070032 private final Signature[] mPackageSignatures;
33
34 /**
35 * @param mPackageName
36 * @param mPackageVersionCode
37 * @param mPackageSignatures
38 */
39 public KeyAttestationPackageInfo(
Dianne Hackborn3accca02013-09-20 09:32:11 -070040 String mPackageName, long mPackageVersionCode, Signature[] mPackageSignatures) {
Janis Danisevskis8ff1e192016-06-03 11:31:55 -070041 super();
42 this.mPackageName = mPackageName;
43 this.mPackageVersionCode = mPackageVersionCode;
44 this.mPackageSignatures = mPackageSignatures;
45 }
46 /**
47 * @return the mPackageName
48 */
49 public String getPackageName() {
50 return mPackageName;
51 }
52 /**
53 * @return the mPackageVersionCode
54 */
Dianne Hackborn3accca02013-09-20 09:32:11 -070055 public long getPackageVersionCode() {
Janis Danisevskis8ff1e192016-06-03 11:31:55 -070056 return mPackageVersionCode;
57 }
58 /**
59 * @return the mPackageSignatures
60 */
61 public Signature[] getPackageSignatures() {
62 return mPackageSignatures;
63 }
64
65 @Override
66 public int describeContents() {
67 return 0;
68 }
69
70 @Override
71 public void writeToParcel(Parcel dest, int flags) {
72 dest.writeString(mPackageName);
Dianne Hackborn3accca02013-09-20 09:32:11 -070073 dest.writeLong(mPackageVersionCode);
Janis Danisevskis8ff1e192016-06-03 11:31:55 -070074 dest.writeTypedArray(mPackageSignatures, flags);
75 }
76
77 public static final Parcelable.Creator<KeyAttestationPackageInfo> CREATOR
78 = new Parcelable.Creator<KeyAttestationPackageInfo>() {
79 @Override
80 public KeyAttestationPackageInfo createFromParcel(Parcel source) {
81 return new KeyAttestationPackageInfo(source);
82 }
83
84 @Override
85 public KeyAttestationPackageInfo[] newArray(int size) {
86 return new KeyAttestationPackageInfo[size];
87 }
88 };
89
90 private KeyAttestationPackageInfo(Parcel source) {
91 mPackageName = source.readString();
Dianne Hackborn3accca02013-09-20 09:32:11 -070092 mPackageVersionCode = source.readLong();
Janis Danisevskis8ff1e192016-06-03 11:31:55 -070093 mPackageSignatures = source.createTypedArray(Signature.CREATOR);
94 }
95}