Shawn Willden | 907c301 | 2014-12-08 15:51:55 -0700 | [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_AES_OPERATION_H_ |
| 18 | #define SYSTEM_KEYMASTER_AES_OPERATION_H_ |
| 19 | |
Shawn Willden | 0797016 | 2018-01-08 00:48:10 -0700 | [diff] [blame] | 20 | #include <openssl/aes.h> |
Shawn Willden | f0f68b9 | 2014-12-30 16:03:28 -0700 | [diff] [blame] | 21 | |
Shawn Willden | a2f1a9b | 2018-01-09 09:37:43 -0700 | [diff] [blame] | 22 | #include "block_cipher_operation.h" |
Shawn Willden | 907c301 | 2014-12-08 15:51:55 -0700 | [diff] [blame] | 23 | |
| 24 | namespace keymaster { |
| 25 | |
Shawn Willden | 0797016 | 2018-01-08 00:48:10 -0700 | [diff] [blame] | 26 | class AesEvpCipherDescription : public EvpCipherDescription { |
| 27 | public: |
| 28 | keymaster_algorithm_t algorithm() const override { return KM_ALGORITHM_AES; } |
| 29 | |
| 30 | const keymaster_block_mode_t* SupportedBlockModes(size_t* block_mode_count) const override; |
| 31 | |
| 32 | const EVP_CIPHER* GetCipherInstance(size_t key_size, keymaster_block_mode_t block_mode, |
| 33 | keymaster_error_t* error) const override; |
| 34 | |
| 35 | size_t block_size_bytes() const override { return AES_BLOCK_SIZE; } |
| 36 | }; |
| 37 | |
| 38 | class AesOperationFactory : public BlockCipherOperationFactory { |
| 39 | public: |
Chih-Hung Hsieh | 82ac341 | 2019-01-02 13:34:23 -0800 | [diff] [blame] | 40 | explicit AesOperationFactory(keymaster_purpose_t purpose) |
| 41 | : BlockCipherOperationFactory(purpose) {} |
Shawn Willden | 0797016 | 2018-01-08 00:48:10 -0700 | [diff] [blame] | 42 | const EvpCipherDescription& GetCipherDescription() const override; |
Shawn Willden | 0629810 | 2015-05-25 23:12:48 -0600 | [diff] [blame] | 43 | }; |
| 44 | |
Shawn Willden | 907c301 | 2014-12-08 15:51:55 -0700 | [diff] [blame] | 45 | } // namespace keymaster |
| 46 | |
| 47 | #endif // SYSTEM_KEYMASTER_AES_OPERATION_H_ |