Home | History | Annotate | Download | only in common
      1 //
      2 // Copyright (C) 2015 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 #ifndef ATTESTATION_COMMON_ATTESTATION_INTERFACE_H_
     18 #define ATTESTATION_COMMON_ATTESTATION_INTERFACE_H_
     19 
     20 #include <string>
     21 
     22 #include <base/callback_forward.h>
     23 
     24 #include "attestation/common/interface.pb.h"
     25 
     26 namespace attestation {
     27 
     28 // The main attestation interface implemented by proxies and services. The
     29 // anticipated flow looks like this:
     30 //   [APP] -> AttestationInterface -> [IPC] -> AttestationInterface
     31 class AttestationInterface {
     32  public:
     33   virtual ~AttestationInterface() = default;
     34 
     35   // Performs initialization tasks that may take a long time. This method must
     36   // be successfully called before calling any other method. Returns true on
     37   // success.
     38   virtual bool Initialize() = 0;
     39 
     40   // Processes a CreateGoogleAttestedKeyRequest and responds with a
     41   // CreateGoogleAttestedKeyReply.
     42   using CreateGoogleAttestedKeyCallback =
     43       base::Callback<void(const CreateGoogleAttestedKeyReply&)>;
     44   virtual void CreateGoogleAttestedKey(
     45       const CreateGoogleAttestedKeyRequest& request,
     46       const CreateGoogleAttestedKeyCallback& callback) = 0;
     47 
     48   // Processes a GetKeyInfoRequest and responds with a GetKeyInfoReply.
     49   using GetKeyInfoCallback = base::Callback<void(const GetKeyInfoReply&)>;
     50   virtual void GetKeyInfo(const GetKeyInfoRequest& request,
     51                           const GetKeyInfoCallback& callback) = 0;
     52 
     53   // Processes a GetEndorsementInfoRequest and responds with a
     54   // GetEndorsementInfoReply.
     55   using GetEndorsementInfoCallback =
     56       base::Callback<void(const GetEndorsementInfoReply&)>;
     57   virtual void GetEndorsementInfo(
     58       const GetEndorsementInfoRequest& request,
     59       const GetEndorsementInfoCallback& callback) = 0;
     60 
     61   // Processes a GetAttestationKeyInfoRequest and responds with a
     62   // GetAttestationKeyInfoReply.
     63   using GetAttestationKeyInfoCallback =
     64       base::Callback<void(const GetAttestationKeyInfoReply&)>;
     65   virtual void GetAttestationKeyInfo(
     66       const GetAttestationKeyInfoRequest& request,
     67       const GetAttestationKeyInfoCallback& callback) = 0;
     68 
     69   // Processes a ActivateAttestationKeyRequest and responds with a
     70   // ActivateAttestationKeyReply.
     71   using ActivateAttestationKeyCallback =
     72       base::Callback<void(const ActivateAttestationKeyReply&)>;
     73   virtual void ActivateAttestationKey(
     74       const ActivateAttestationKeyRequest& request,
     75       const ActivateAttestationKeyCallback& callback) = 0;
     76 
     77   // Processes a CreateCertifiableKeyRequest and responds with a
     78   // CreateCertifiableKeyReply.
     79   using CreateCertifiableKeyCallback =
     80       base::Callback<void(const CreateCertifiableKeyReply&)>;
     81   virtual void CreateCertifiableKey(
     82       const CreateCertifiableKeyRequest& request,
     83       const CreateCertifiableKeyCallback& callback) = 0;
     84 
     85   // Processes a DecryptRequest and responds with a DecryptReply.
     86   using DecryptCallback = base::Callback<void(const DecryptReply&)>;
     87   virtual void Decrypt(const DecryptRequest& request,
     88                        const DecryptCallback& callback) = 0;
     89 
     90   // Processes a SignRequest and responds with a SignReply.
     91   using SignCallback = base::Callback<void(const SignReply&)>;
     92   virtual void Sign(const SignRequest& request,
     93                     const SignCallback& callback) = 0;
     94 
     95   // Processes a RegisterKeyWithChapsTokenRequest and responds with a
     96   // RegisterKeyWithChapsTokenReply.
     97   using RegisterKeyWithChapsTokenCallback =
     98       base::Callback<void(const RegisterKeyWithChapsTokenReply&)>;
     99   virtual void RegisterKeyWithChapsToken(
    100       const RegisterKeyWithChapsTokenRequest& request,
    101       const RegisterKeyWithChapsTokenCallback& callback) = 0;
    102 };
    103 
    104 }  // namespace attestation
    105 
    106 #endif  // ATTESTATION_COMMON_ATTESTATION_INTERFACE_H_
    107