cbc.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 
3 // Copyright (c) 2019-2020 Mikhail Komarov <nemo@nil.foundation>
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_BLOCK_MODE_CIPHER_BLOCK_CHAINING_HPP
27 #define CRYPTO3_BLOCK_MODE_CIPHER_BLOCK_CHAINING_HPP
28 
29 #include <boost/integer.hpp>
30 
34 
36 
37 //#include <nil/crypto3/codec/logic.hpp>
38 
39 namespace nil {
40  namespace crypto3 {
41  namespace block {
42  namespace modes {
43  namespace detail {
44  template<typename Cipher, typename Padding, template<typename> class Allocator = std::allocator>
45  struct cbc_policy {
46  typedef std::size_t size_type;
47 
48  typedef Cipher cipher_type;
49  typedef Padding padding_type;
50 
51  constexpr static const size_type block_bits = cipher_type::block_bits;
52  constexpr static const size_type block_words = cipher_type::block_words;
53  typedef typename cipher_type::block_type block_type;
54 
55  typedef std::vector<boost::uint_t<CHAR_BIT>, Allocator<boost::uint_t<CHAR_BIT>>> iv_type;
56  };
57 
58  template<typename Cipher, typename Padding, typename CiphertextStealingMode>
59  struct cbc_encryption_policy : public cbc_policy<Cipher, Padding> {};
60 
61  template<typename Cipher, typename Padding>
62  struct cbc_encryption_policy<Cipher, Padding, cts<0, Cipher, Padding>>
63  : public cbc_policy<Cipher, Padding> {
65 
68 
72 
74 
75  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
76  const iv_type &iv = iv_type()) {
77  block_type block = {0};
78 
79  // codec::encode<codec::encoder::logic_xor>(plaintext, iv,
80  // block.begin());
81 
82  return cipher.encrypt(block);
83  }
84 
85  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
86  const block_type &previous = block_type()) {
87  block_type block = {0};
88 
89  // codec::encode<codec::encoder::logic_xor>(plaintext, previous,
90  // block.begin());
91 
92  return cipher.encrypt(block);
93  }
94 
95  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
96  const block_type &previous = block_type(),
97  const iv_type &iv = iv_type()) {
98  block_type result = {0};
99  std::array<uint8_t, block_bits / CHAR_BIT> byte_array = {0};
100 
101  pack(plaintext, byte_array);
102 
103  size_type rem = std::count(byte_array.begin(), byte_array.end(), block_type::value_type()) %
104  (block_bits / CHAR_BIT);
105  if (rem || padding_type::always_pad) {
106  block_type padbuffer = padding_type::pad(plaintext, rem), block;
107  // codec::encode<codec::encoder::logic_xor>(!iv.empty() ? iv
108  // : previous, padbuffer, block .begin());
109  result = cipher.encrypt(block);
110  }
111 
112  return result;
113  }
114  };
115 
116  template<typename Cipher, typename Padding>
117  struct cbc_encryption_policy<Cipher, Padding, cts<1, Cipher, Padding>>
118  : public cbc_policy<Cipher, Padding> {
120 
123 
127 
129 
130  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
131  const iv_type &iv = iv_type()) {
132  block_type block = {0};
133 
134  // codec::encode<codec::encoder::logic_xor>(plaintext, iv,
135  // block.begin());
136 
137  return cipher.encrypt(block);
138  }
139 
140  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
141  const block_type &previous = block_type()) {
142  block_type block = {0};
143 
144  // codec::encode<codec::encoder::logic_xor>(plaintext, previous,
145  // block.begin());
146 
147  return cipher.encrypt(block);
148  }
149 
150  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
151  const block_type &previous = block_type(),
152  const iv_type &iv = iv_type()) {
153  block_type result = {0};
154  std::array<uint8_t, block_bits / CHAR_BIT> byte_array = {0};
155 
156  pack(plaintext, byte_array);
157 
158  size_type rem = std::count(byte_array.begin(), byte_array.end(), block_type::value_type()) %
159  (block_bits / CHAR_BIT);
160  if (rem || padding_type::always_pad) {
161  block_type padbuffer = padding_type::pad(plaintext, rem), block;
162  // codec::encode<codec::encoder::logic_xor>(!iv.empty() ? iv
163  // : previous, padbuffer, block .begin());
164  result = cipher.encrypt(block);
165  }
166 
167  return result;
168  }
169  };
170 
171  template<typename Cipher, typename Padding>
172  struct cbc_encryption_policy<Cipher, Padding, cts<2, Cipher, Padding>>
173  : public cbc_policy<Cipher, Padding> {
175 
178 
182 
184 
185  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
186  const iv_type &iv = iv_type()) {
187  block_type block = {0};
188 
189  // codec::encode<codec::encoder::logic_xor>(plaintext, iv,
190  // block.begin());
191 
192  return cipher.encrypt(block);
193  }
194 
195  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
196  const block_type &previous = block_type()) {
197  block_type block = {0};
198 
199  // codec::encode<codec::encoder::logic_xor>(plaintext, previous,
200  // block.begin());
201 
202  return cipher.encrypt(block);
203  }
204 
205  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
206  const block_type &previous = block_type(),
207  const iv_type &iv = iv_type()) {
208  block_type result = {0};
209  std::array<uint8_t, block_bits / CHAR_BIT> byte_array = {0};
210 
211  pack(plaintext, byte_array);
212 
213  size_type rem = std::count(byte_array.begin(), byte_array.end(), block_type::value_type()) %
214  (block_bits / CHAR_BIT);
215  if (rem || padding_type::always_pad) {
216  block_type padbuffer = padding_type::pad(plaintext, rem), block;
217  // codec::encode<codec::encoder::logic_xor>(!iv.empty() ? iv
218  // : previous, padbuffer, block .begin());
219  result = cipher.encrypt(block);
220  }
221 
222  return result;
223  }
224  };
225 
226  template<typename Cipher, typename Padding>
227  struct cbc_encryption_policy<Cipher, Padding, cts<3, Cipher, Padding>>
228  : public cbc_policy<Cipher, Padding> {
230 
233 
237 
239 
240  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
241  const iv_type &iv = iv_type()) {
242  block_type block = {0};
243 
244  // codec::encode<codec::encoder::logic_xor>(plaintext, iv,
245  // block.begin());
246 
247  return cipher.encrypt(block);
248  }
249 
250  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
251  const block_type &previous = block_type()) {
252  block_type block = {0};
253 
254  // codec::encode<codec::encoder::logic_xor>(plaintext, previous,
255  // block.begin());
256 
257  return cipher.encrypt(block);
258  }
259 
260  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
261  const block_type &previous = block_type(),
262  const iv_type &iv = iv_type()) {
263  BOOST_ASSERT_MSG(buffer.size() >= offset, "Offset is sane");
264  uint8_t *buf = buffer.data() + offset;
265  const size_t sz = buffer.size() - offset;
266 
267  const size_t BS = block_size();
268 
269  if (sz < BS + 1) {
270  throw encoding_error(name() + ": insufficient data to encipher");
271  }
272 
273  if (sz % BS == 0) {
274  update(buffer, offset);
275 
276  // swap last two blocks
277  for (size_t i = 0; i != BS; ++i) {
278  std::swap(buffer[buffer.size() - BS + i], buffer[buffer.size() - 2 * BS + i]);
279  }
280  } else {
281  const size_t full_blocks = ((sz / BS) - 1) * BS;
282  const size_t final_bytes = sz - full_blocks;
283  BOOST_ASSERT_MSG(final_bytes > BS && final_bytes < 2 * BS,
284  "Left over size in expected range");
285 
286  secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
287  buffer.resize(full_blocks + offset);
288  update(buffer, offset);
289 
290  xor_buf(last.data(), state_ptr(), BS);
291  cipher().encrypt(last.data());
292 
293  for (size_t i = 0; i != final_bytes - BS; ++i) {
294  last[i] ^= last[i + BS];
295  last[i + BS] ^= last[i];
296  }
297 
298  cipher().encrypt(last.data());
299 
300  buffer += last;
301  }
302  }
303  };
304 
305  template<typename Cipher, typename Padding, typename CiphertextStealingMode>
306  struct cbc_decryption_policy : public cbc_policy<Cipher, Padding> {};
307 
308  template<typename Cipher, typename Padding>
309  struct cbc_decryption_policy<Cipher, Padding, cts<0, Cipher, Padding>>
310  : public cbc_policy<Cipher, Padding> {
312 
315 
316  constexpr static const std::size_t block_bits = cbc_policy<Cipher, Padding>::block_bits;
317  constexpr static const std::size_t block_words = cbc_policy<Cipher, Padding>::block_words;
319 
321 
322  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
323  const iv_type &iv = iv_type()) {
324  block_type block = cipher.decrypt(plaintext);
325 
326  // codec::encode<codec::encoder::logic_xor>(block, iv);
327 
328  return block;
329  }
330 
331  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
332  const block_type &previous = block_type()) {
333  const size_t BS = block_size();
334 
335  BOOST_ASSERT_MSG(sz % BS == 0, "Input is full blocks");
336  size_t blocks = sz / BS;
337 
338  while (blocks) {
339  const size_t to_proc = std::min(BS * blocks, m_tempbuf.size());
340 
341  cipher().decrypt_n(buf, m_tempbuf.data(), to_proc / BS);
342 
343  xor_buf(m_tempbuf.data(), state_ptr(), BS);
344  xor_buf(&m_tempbuf[BS], buf, to_proc - BS);
345  copy_mem(state_ptr(), buf + (to_proc - BS), BS);
346 
347  copy_mem(buf, m_tempbuf.data(), to_proc);
348 
349  buf += to_proc;
350  blocks -= to_proc / BS;
351  }
352 
353  return sz;
354  }
355 
356  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
357  const iv_type &iv = iv_type()) {
358  BOOST_ASSERT_MSG(buffer.size() >= offset, "Offset is sane");
359  const size_t sz = buffer.size() - offset;
360 
361  const size_t BS = block_size();
362 
363  if (sz == 0 || sz % BS) {
364  throw decoding_error(name() + ": Ciphertext not a multiple of block size");
365  }
366 
367  update(buffer, offset);
368 
369  const size_t pad_bytes = BS - padding().unpad(&buffer[buffer.size() - BS], BS);
370  buffer.resize(buffer.size() - pad_bytes); // remove padding
371  if (pad_bytes == 0 && padding().name() != "NoPadding") {
372  throw decoding_error(name());
373  }
374  }
375  };
376 
377  template<typename Cipher, typename Padding>
378  struct cbc_decryption_policy<Cipher, Padding, cts<1, Cipher, Padding>>
379  : public cbc_policy<Cipher, Padding> {
381 
384 
385  constexpr static const std::size_t block_bits = cbc_policy<Cipher, Padding>::block_bits;
386  constexpr static const std::size_t block_words = cbc_policy<Cipher, Padding>::block_words;
388 
390 
391  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
392  const iv_type &iv = iv_type()) {
393  block_type block = cipher.decrypt(plaintext);
394 
395  // codec::encode<codec::encoder::logic_xor>(block, iv);
396 
397  return block;
398  }
399 
400  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
401  const block_type &previous = block_type()) {
402  block_type result = cipher.decrypt(plaintext);
403 
404  // codec::encode<codec::encoder::logic_xor>(result, previous);
405 
406  return result;
407  }
408 
409  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
410  const iv_type &iv = iv_type()) {
411  block_type result = cipher.decrypt(plaintext);
412 
413  // codec::encode<codec::encoder::logic_xor>(result, iv);
414 
415  return result;
416  }
417  };
418 
419  template<typename Cipher, typename Padding>
420  struct cbc_decryption_policy<Cipher, Padding, cts<2, Cipher, Padding>>
421  : public cbc_policy<Cipher, Padding> {
423 
426 
427  constexpr static const std::size_t block_bits = cbc_policy<Cipher, Padding>::block_bits;
428  constexpr static const std::size_t block_words = cbc_policy<Cipher, Padding>::block_words;
430 
432 
433  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
434  const iv_type &iv = iv_type()) {
435  block_type block = cipher.decrypt(plaintext);
436 
437  // codec::encode<codec::encoder::logic_xor>(block, iv);
438 
439  return block;
440  }
441 
442  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
443  const block_type &previous = block_type()) {
444  block_type result = cipher.decrypt(plaintext);
445 
446  // codec::encode<codec::encoder::logic_xor>(result, previous);
447 
448  return result;
449  }
450 
451  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
452  const iv_type &iv = iv_type()) {
453  block_type result = cipher.decrypt(plaintext);
454 
455  // codec::encode<codec::encoder::logic_xor>(result, iv);
456 
457  return result;
458  }
459  };
460 
461  template<typename Cipher, typename Padding>
462  struct cbc_decryption_policy<Cipher, Padding, cts<3, Cipher, Padding>>
463  : public cbc_policy<Cipher, Padding> {
465 
468 
469  constexpr static const std::size_t block_bits = cbc_policy<Cipher, Padding>::block_bits;
470  constexpr static const std::size_t block_words = cbc_policy<Cipher, Padding>::block_words;
472 
474 
475  inline static block_type begin_message(const cipher_type &cipher, const block_type &plaintext,
476  const iv_type &iv = iv_type()) {
477  block_type block = cipher.decrypt(plaintext);
478 
479  // codec::encode<codec::encoder::logic_xor>(block, iv);
480 
481  return block;
482  }
483 
484  inline static block_type process_block(const cipher_type &cipher, const block_type &plaintext,
485  const block_type &previous = block_type()) {
486  block_type result = cipher.decrypt(plaintext);
487 
488  // codec::encode<codec::encoder::logic_xor>(result, previous);
489 
490  return result;
491  }
492 
493  inline static block_type end_message(const cipher_type &cipher, const block_type &plaintext,
494  const iv_type &iv = iv_type()) {
495  BOOST_ASSERT_MSG(buffer.size() >= offset, "Offset is sane");
496  const size_t sz = buffer.size() - offset;
497  uint8_t *buf = buffer.data() + offset;
498 
499  const size_t BS = block_size();
500 
501  if (sz < BS + 1) {
502  throw encoding_error(name() + ": insufficient data to isomorphic_decryption_mode");
503  }
504 
505  if (sz % BS == 0) {
506  // swap last two blocks
507 
508  for (size_t i = 0; i != BS; ++i) {
509  std::swap(buffer[buffer.size() - BS + i], buffer[buffer.size() - 2 * BS + i]);
510  }
511 
512  update(buffer, offset);
513  } else {
514  const size_t full_blocks = ((sz / BS) - 1) * BS;
515  const size_t final_bytes = sz - full_blocks;
516  BOOST_ASSERT_MSG(final_bytes > BS && final_bytes < 2 * BS, "Left over size in expected range");
517 
518  secure_vector<uint8_t> last(buf + full_blocks, buf + full_blocks + final_bytes);
519  buffer.resize(full_blocks + offset);
520  update(buffer, offset);
521 
522  cipher().decrypt(last.data());
523 
524  xor_buf(last.data(), &last[BS], final_bytes - BS);
525 
526  for (size_t i = 0; i != final_bytes - BS; ++i) {
527  std::swap(last[i], last[i + BS]);
528  }
529 
530  cipher().decrypt(last.data());
531  xor_buf(last.data(), state_ptr(), BS);
532 
533  buffer += last;
534  }
535  }
536  };
537 
538  template<typename Policy>
540  typedef Policy policy_type;
541 
542  public:
543  typedef typename policy_type::cipher_type cipher_type;
544  typedef typename policy_type::padding_type padding_type;
545 
546  typedef typename policy_type::size_type size_type;
547 
548  typedef typename cipher_type::key_type key_type;
549  typedef typename policy_type::iv_type iv_type;
550 
551  constexpr static const size_type block_bits = policy_type::block_bits;
552  constexpr static const size_type block_words = policy_type::block_words;
553  typedef typename cipher_type::block_type block_type;
554 
556  }
557 
558  block_type begin_message(const block_type &plaintext, const iv_type &iv = iv_type()) {
559  previous = policy_type::begin_message(cipher, plaintext, iv);
560  return previous;
561  }
562 
563  block_type process_block(const block_type &plaintext) {
564  previous = policy_type::process_block(cipher, plaintext, previous);
565  return previous;
566  }
567 
568  block_type end_message(const block_type &plaintext, const iv_type &iv = iv_type()) {
569  return policy_type::end_message(cipher, plaintext, iv);
570  }
571 
572  inline static size_type required_output_size(size_type inputlen) {
573  return padding_type::required_output_size(inputlen);
574  }
575 
576  protected:
579  };
580  } // namespace detail
581 
590  template<typename Cipher, template<typename> class Padding,
591  template<typename, template<typename> class> class CiphertextStealingMode = cts0>
593  typedef Cipher cipher_type;
594  typedef Padding<Cipher> padding_type;
595  typedef CiphertextStealingMode<Cipher, Padding> ciphertext_stealing_type;
596 
601 
602  template<template<typename, typename> class Policy>
603  struct bind {
605  };
606  };
607 
616  template<typename Cipher, template<typename> class Padding,
617  template<typename, template<typename> class> class CiphertextStealingMode>
619  } // namespace modes
620  } // namespace block
621  } // namespace crypto3
622 } // namespace nil
623 
624 #endif
block_type end_message(const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:568
cipher_type::block_type block_type
Definition: cbc.hpp:553
static size_type required_output_size(size_type inputlen)
Definition: cbc.hpp:572
policy_type::padding_type padding_type
Definition: cbc.hpp:544
constexpr static const size_type block_words
Definition: cbc.hpp:552
constexpr static const size_type block_bits
Definition: cbc.hpp:551
cipher_block_chaining(const cipher_type &cipher)
Definition: cbc.hpp:555
cipher_type::key_type key_type
Definition: cbc.hpp:548
policy_type::iv_type iv_type
Definition: cbc.hpp:549
policy_type::size_type size_type
Definition: cbc.hpp:546
block_type begin_message(const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:558
block_type process_block(const block_type &plaintext)
Definition: cbc.hpp:563
policy_type::cipher_type cipher_type
Definition: cbc.hpp:543
void pack(InputIterator first, InputIterator last, std::random_access_iterator_tag, OutputIterator out)
Packs elements from the range [first, last) into elements starting from out. Works for input containe...
Definition: block/include/nil/crypto3/detail/pack.hpp:835
constexpr T min(const vector< T, N > &v)
computes the minimum valued element
Definition: algebra/include/nil/crypto3/algebra/vector/math.hpp:135
boost::mpl::apply< AccumulatorSet, tag::block< Mode > >::type::result_type block(const AccumulatorSet &acc)
Definition: accumulators/block.hpp:259
void xor_buf(uint8_t out[], const uint8_t in[], size_t length)
Definition: memory_operations.hpp:245
void copy_mem(T *out, const T *in, size_t n)
Definition: memory_operations.hpp:186
Definition: pair.hpp:31
Definition: cipher.hpp:38
detail::cipher_block_chaining< Policy< cipher_type, padding_type > > type
Definition: cbc.hpp:604
Cipher Block Chaining Mode (CBC). Xors previous cipher text with current plaintext before encryption.
Definition: cbc.hpp:592
CiphertextStealingMode< Cipher, Padding > ciphertext_stealing_type
Definition: cbc.hpp:595
Padding< Cipher > padding_type
Definition: cbc.hpp:594
detail::cbc_encryption_policy< cipher_type, padding_type, ciphertext_stealing_type > encryption_policy
Definition: cbc.hpp:598
detail::cbc_decryption_policy< cipher_type, padding_type, ciphertext_stealing_type > decryption_policy
Definition: cbc.hpp:600
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:451
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:442
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:425
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:433
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:400
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:383
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:409
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:391
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:467
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:484
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:493
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:475
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:331
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:322
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:356
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:314
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:140
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:130
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type(), const iv_type &iv=iv_type())
Definition: cbc.hpp:150
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:122
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:85
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:67
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type(), const iv_type &iv=iv_type())
Definition: cbc.hpp:95
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:75
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type(), const iv_type &iv=iv_type())
Definition: cbc.hpp:205
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:185
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:195
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:177
static block_type begin_message(const cipher_type &cipher, const block_type &plaintext, const iv_type &iv=iv_type())
Definition: cbc.hpp:240
cbc_policy< Cipher, Padding >::padding_type padding_type
Definition: cbc.hpp:232
static block_type process_block(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type())
Definition: cbc.hpp:250
static block_type end_message(const cipher_type &cipher, const block_type &plaintext, const block_type &previous=block_type(), const iv_type &iv=iv_type())
Definition: cbc.hpp:260
std::vector< boost::uint_t< CHAR_BIT >, Allocator< boost::uint_t< CHAR_BIT > > > iv_type
Definition: cbc.hpp:55
Padding padding_type
Definition: cbc.hpp:49
Cipher cipher_type
Definition: cbc.hpp:48
cipher_type::block_type block_type
Definition: cbc.hpp:53
constexpr static const size_type block_bits
Definition: cbc.hpp:51
std::size_t size_type
Definition: cbc.hpp:46
constexpr static const size_type block_words
Definition: cbc.hpp:52