Home | History | Annotate | Download | only in km_openssl
      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:
     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 
     35     size_t block_size_bytes() const override { return 8 /* DES_BLOCK_SIZE */; }
     36 };
     37 
     38 class TripleDesOperationFactory : public BlockCipherOperationFactory {
     39   public:
     40     TripleDesOperationFactory(keymaster_purpose_t purpose) : BlockCipherOperationFactory(purpose) {}
     41     const EvpCipherDescription& GetCipherDescription() const override;
     42 };
     43 
     44 }  // namespace keymaster
     45 
     46 #endif  // SYSTEM_KEYMASTER_TRIPLE_DES_OPERATION_H_
     47