• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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_TRIPLE_DES_OPERATION_H_
18 #define SYSTEM_KEYMASTER_TRIPLE_DES_OPERATION_H_
19 
20 #include <openssl/des.h>
21 
22 #include "block_cipher_operation.h"
23 
24 namespace keymaster {
25 
26 class TripleDesEvpCipherDescription : public EvpCipherDescription {
27   public:
algorithm()28     keymaster_algorithm_t algorithm() const override { return KM_ALGORITHM_TRIPLE_DES; }
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 
block_size_bytes()35     size_t block_size_bytes() const override { return 8 /* DES_BLOCK_SIZE */; }
36 };
37 
38 class TripleDesOperationFactory : public BlockCipherOperationFactory {
39   public:
TripleDesOperationFactory(keymaster_purpose_t purpose)40     explicit TripleDesOperationFactory(keymaster_purpose_t purpose)
41         : BlockCipherOperationFactory(purpose) {}
42     const EvpCipherDescription& GetCipherDescription() const override;
43 };
44 
45 }  // namespace keymaster
46 
47 #endif  // SYSTEM_KEYMASTER_TRIPLE_DES_OPERATION_H_
48