codec_modes.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2019 Aleksey Moskvin <zerg1996@yandex.ru>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_PREPROCESSING_MODES_HPP
27 #define CRYPTO3_PREPROCESSING_MODES_HPP
28 
29 namespace nil {
30  namespace crypto3 {
31  namespace codec {
32  namespace detail {
33  template<typename Codec>
35  typedef Codec codec_type;
36 
37  typedef typename codec_type::encoded_value_type encoded_value_type;
38  typedef typename codec_type::encoded_block_type encoded_block_type;
39 
40  typedef typename codec_type::decoded_value_type decoded_value_type;
41  typedef typename codec_type::decoded_block_type decoded_block_type;
42  };
43 
44  template<typename Codec>
47 
48  constexpr static const std::size_t input_value_bits = codec_type::decoded_value_bits;
50 
51  constexpr static const std::size_t input_block_bits = codec_type::decoded_block_bits;
52  constexpr static const std::size_t input_block_values = codec_type::decoded_block_values;
54 
55  constexpr static const std::size_t output_value_bits = codec_type::encoded_value_bits;
57 
58  constexpr static const std::size_t output_block_bits = codec_type::encoded_block_bits;
59  constexpr static const std::size_t output_block_values = codec_type::encoded_block_values;
61 
62  typedef typename codec_type::encoding_finalizer_type finalizer_type;
63  typedef typename codec_type::encoding_preprocessor_type preprocessor_type;
64 
65  static inline output_block_type process_block(const input_block_type &plaintext) {
66  return codec_type::encode(plaintext);
67  }
68  };
69 
70  template<typename Codec>
73 
74  constexpr static const std::size_t input_value_bits = codec_type::encoded_value_bits;
76 
78  constexpr static const std::size_t input_block_bits = codec_type::encoded_block_bits;
79  constexpr static const std::size_t input_block_values = codec_type::encoded_block_values;
80 
81  constexpr static const std::size_t output_value_bits = codec_type::decoded_value_bits;
83 
85  constexpr static const std::size_t output_block_bits = codec_type::decoded_block_bits;
86  constexpr static const std::size_t output_block_values = codec_type::decoded_block_values;
87 
88  typedef typename codec_type::decoding_finalizer_type finalizer_type;
89  typedef typename codec_type::decoding_preprocessor_type preprocessor_type;
90 
91  static inline output_block_type process_block(const input_block_type &plaintext) {
92  return codec_type::decode(plaintext);
93  }
94  };
95  } // namespace detail
96  } // namespace codec
97  } // namespace crypto3
98 } // namespace nil
99 
100 #endif // CRYPTO3_PREPROCESSING_MODES_HPP
boost::mpl::apply< AccumulatorSet, tag::codec< typename Codec::stream_decoder_type > >::type::result_type decode(const AccumulatorSet &acc)
Definition: accumulators/codec.hpp:275
boost::mpl::apply< AccumulatorSet, tag::codec< Mode > >::type::result_type codec(const AccumulatorSet &acc)
Definition: accumulators/codec.hpp:261
boost::mpl::apply< AccumulatorSet, tag::codec< typename Codec::stream_encoder_type > >::type::result_type encode(const AccumulatorSet &acc)
Definition: accumulators/codec.hpp:268
Definition: pair.hpp:31
constexpr static const std::size_t output_value_bits
Definition: codec_modes.hpp:81
constexpr static const std::size_t output_block_values
Definition: codec_modes.hpp:86
stream_processor_mode< Codec >::encoded_value_type input_value_type
Definition: codec_modes.hpp:75
stream_processor_mode< Codec >::encoded_block_type input_block_type
Definition: codec_modes.hpp:77
stream_processor_mode< Codec >::codec_type codec_type
Definition: codec_modes.hpp:72
codec_type::decoding_preprocessor_type preprocessor_type
Definition: codec_modes.hpp:89
codec_type::decoding_finalizer_type finalizer_type
Definition: codec_modes.hpp:88
constexpr static const std::size_t output_block_bits
Definition: codec_modes.hpp:85
stream_processor_mode< Codec >::decoded_value_type output_value_type
Definition: codec_modes.hpp:82
constexpr static const std::size_t input_value_bits
Definition: codec_modes.hpp:74
constexpr static const std::size_t input_block_values
Definition: codec_modes.hpp:79
stream_processor_mode< Codec >::decoded_block_type output_block_type
Definition: codec_modes.hpp:84
constexpr static const std::size_t input_block_bits
Definition: codec_modes.hpp:78
static output_block_type process_block(const input_block_type &plaintext)
Definition: codec_modes.hpp:91
static output_block_type process_block(const input_block_type &plaintext)
Definition: codec_modes.hpp:65
constexpr static const std::size_t input_block_bits
Definition: codec_modes.hpp:51
constexpr static const std::size_t output_value_bits
Definition: codec_modes.hpp:55
stream_processor_mode< Codec >::decoded_value_type input_value_type
Definition: codec_modes.hpp:49
stream_processor_mode< Codec >::encoded_block_type output_block_type
Definition: codec_modes.hpp:60
constexpr static const std::size_t output_block_values
Definition: codec_modes.hpp:59
stream_processor_mode< Codec >::decoded_block_type input_block_type
Definition: codec_modes.hpp:53
stream_processor_mode< Codec >::encoded_value_type output_value_type
Definition: codec_modes.hpp:56
codec_type::encoding_finalizer_type finalizer_type
Definition: codec_modes.hpp:62
constexpr static const std::size_t input_value_bits
Definition: codec_modes.hpp:48
stream_processor_mode< Codec >::codec_type codec_type
Definition: codec_modes.hpp:46
constexpr static const std::size_t input_block_values
Definition: codec_modes.hpp:52
constexpr static const std::size_t output_block_bits
Definition: codec_modes.hpp:58
codec_type::encoding_preprocessor_type preprocessor_type
Definition: codec_modes.hpp:63
codec_type::decoded_block_type decoded_block_type
Definition: codec_modes.hpp:41
codec_type::decoded_value_type decoded_value_type
Definition: codec_modes.hpp:40
codec_type::encoded_value_type encoded_value_type
Definition: codec_modes.hpp:37
codec_type::encoded_block_type encoded_block_type
Definition: codec_modes.hpp:38
Codec codec_type
Definition: codec_modes.hpp:35