Home | History | Annotate | Download | only in keystore
      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 <vector>
     22 
     23 #include <binder/Parcelable.h>
     24 
     25 #include "Signature.h"
     26 #include "utils.h"
     27 
     28 namespace android {
     29 namespace security {
     30 namespace keymaster {
     31 
     32 class KeyAttestationPackageInfo : public Parcelable {
     33   public:
     34     typedef SharedNullableIterator<const content::pm::Signature, std::vector>
     35         ConstSignatureIterator;
     36     typedef std::vector<std::unique_ptr<content::pm::Signature>>
     37         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 
     47     const std::unique_ptr<String16>& package_name() const { return packageName_; }
     48     int64_t version_code() const { return versionCode_; }
     49 
     50     ConstSignatureIterator sigs_begin() const { return ConstSignatureIterator(signatures_); }
     51     ConstSignatureIterator sigs_end() const { return ConstSignatureIterator(); }
     52 
     53   private:
     54     std::unique_ptr<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