Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 SYSTEM_KEYMASTER_OPERATION_H_ |
| 18 | #define SYSTEM_KEYMASTER_OPERATION_H_ |
| 19 | |
| 20 | #include <assert.h> |
| 21 | #include <stdint.h> |
| 22 | #include <stdlib.h> |
| 23 | |
| 24 | #include <keymaster/google_keymaster_utils.h> |
Shawn Willden | b9d584d | 2015-01-22 16:35:00 -0700 | [diff] [blame] | 25 | #include <hardware/keymaster_defs.h> |
Shawn Willden | f6ca3a3 | 2014-09-11 15:11:32 -0600 | [diff] [blame] | 26 | #include <keymaster/logger.h> |
Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 27 | |
| 28 | namespace keymaster { |
| 29 | |
Shawn Willden | 111edb3 | 2015-02-05 22:44:24 -0700 | [diff] [blame^] | 30 | class AuthorizationSet; |
| 31 | |
Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 32 | /** |
| 33 | * Abstract base for all cryptographic operations. |
| 34 | */ |
| 35 | class Operation { |
| 36 | public: |
Shawn Willden | f6ca3a3 | 2014-09-11 15:11:32 -0600 | [diff] [blame] | 37 | Operation(keymaster_purpose_t purpose, const Logger& logger) |
| 38 | : purpose_(purpose), logger_(logger) {} |
| 39 | virtual ~Operation() {} |
Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 40 | |
Shawn Willden | f6ca3a3 | 2014-09-11 15:11:32 -0600 | [diff] [blame] | 41 | keymaster_purpose_t purpose() const { return purpose_; } |
| 42 | |
| 43 | const Logger& logger() { return logger_; } |
Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 44 | |
Shawn Willden | 111edb3 | 2015-02-05 22:44:24 -0700 | [diff] [blame^] | 45 | virtual keymaster_error_t Begin(const AuthorizationSet& input_params, |
| 46 | AuthorizationSet* output_params) = 0; |
Shawn Willden | b736113 | 2014-12-08 08:15:14 -0700 | [diff] [blame] | 47 | virtual keymaster_error_t Update(const Buffer& input, Buffer* output, |
| 48 | size_t* input_consumed) = 0; |
Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 49 | virtual keymaster_error_t Finish(const Buffer& signature, Buffer* output) = 0; |
| 50 | virtual keymaster_error_t Abort() = 0; |
| 51 | |
| 52 | private: |
| 53 | const keymaster_purpose_t purpose_; |
Shawn Willden | f6ca3a3 | 2014-09-11 15:11:32 -0600 | [diff] [blame] | 54 | const Logger& logger_; |
Shawn Willden | 0a4df7e | 2014-08-28 16:09:05 -0600 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | } // namespace keymaster |
| 58 | |
| 59 | #endif // SYSTEM_KEYMASTER_OPERATION_H_ |