blob: 816ffa78a0b47191bb23ed3a2225b9cb79cd62a7 [file] [log] [blame]
Shawn Willden907c3012014-12-08 15:51:55 -07001/*
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 Willden07970162018-01-08 00:48:10 -070020#include <openssl/aes.h>
Shawn Willdenf0f68b92014-12-30 16:03:28 -070021
Shawn Willdena2f1a9b2018-01-09 09:37:43 -070022#include "block_cipher_operation.h"
Shawn Willden907c3012014-12-08 15:51:55 -070023
24namespace keymaster {
25
Shawn Willden07970162018-01-08 00:48:10 -070026class 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
38class AesOperationFactory : public BlockCipherOperationFactory {
39 public:
Chih-Hung Hsieh82ac3412019-01-02 13:34:23 -080040 explicit AesOperationFactory(keymaster_purpose_t purpose)
41 : BlockCipherOperationFactory(purpose) {}
Shawn Willden07970162018-01-08 00:48:10 -070042 const EvpCipherDescription& GetCipherDescription() const override;
Shawn Willden06298102015-05-25 23:12:48 -060043};
44
Shawn Willden907c3012014-12-08 15:51:55 -070045} // namespace keymaster
46
47#endif // SYSTEM_KEYMASTER_AES_OPERATION_H_