• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef KEYSTORE_INCLUDE_KEYSTORE_KEYATTESTATIONPACKAGEINFO_H_
16 #define KEYSTORE_INCLUDE_KEYSTORE_KEYATTESTATIONPACKAGEINFO_H_
17 
18 #include <stdint.h>
19 
20 #include <memory>
21 #include <optional>
22 #include <vector>
23 
24 #include <binder/Parcelable.h>
25 
26 #include "Signature.h"
27 #include "utils.h"
28 
29 namespace android {
30 namespace security {
31 namespace keymaster {
32 
33 class KeyAttestationPackageInfo : public Parcelable {
34   public:
35     typedef SharedNullableIterator<const content::pm::Signature, std::vector>
36         ConstSignatureIterator;
37     typedef std::vector<std::optional<content::pm::Signature>> SignaturesVector;
38     typedef std::shared_ptr<SignaturesVector> SharedSignaturesVector;
39 
40     KeyAttestationPackageInfo(const String16& packageName, int64_t versionCode,
41                               SharedSignaturesVector signatures);
42     KeyAttestationPackageInfo();
43 
44     status_t writeToParcel(Parcel*) const override;
45     status_t readFromParcel(const Parcel* parcel) override;
46 
package_name()47     const std::optional<String16>& package_name() const { return packageName_; }
version_code()48     int64_t version_code() const { return versionCode_; }
49 
sigs_begin()50     ConstSignatureIterator sigs_begin() const { return ConstSignatureIterator(signatures_); }
sigs_end()51     ConstSignatureIterator sigs_end() const { return ConstSignatureIterator(); }
52 
53   private:
54     std::optional<String16> packageName_;
55     int64_t versionCode_;
56     SharedSignaturesVector signatures_;
57 };
58 
59 }  // namespace keymaster
60 }  // namespace security
61 }  // namespace android
62 
63 #endif  // KEYSTORE_INCLUDE_KEYSTORE_KEYATTESTATIONPACKAGEINFO_H_
64