~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to src/lib/stream/ofb/ofb.h

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* OFB Mode
 
3
* (C) 1999-2007 Jack Lloyd
 
4
*
 
5
* Botan is released under the Simplified BSD License (see license.txt)
 
6
*/
 
7
 
 
8
#ifndef BOTAN_OUTPUT_FEEDBACK_MODE_H_
 
9
#define BOTAN_OUTPUT_FEEDBACK_MODE_H_
 
10
 
 
11
#include <botan/stream_cipher.h>
 
12
#include <botan/block_cipher.h>
 
13
 
 
14
namespace Botan {
 
15
 
 
16
/**
 
17
* Output Feedback Mode
 
18
*/
 
19
class BOTAN_PUBLIC_API(2,0) OFB final : public StreamCipher
 
20
   {
 
21
   public:
 
22
      void cipher(const uint8_t in[], uint8_t out[], size_t length) override;
 
23
 
 
24
      void set_iv(const uint8_t iv[], size_t iv_len) override;
 
25
 
 
26
      bool valid_iv_length(size_t iv_len) const override
 
27
         { return (iv_len <= m_cipher->block_size()); }
 
28
 
 
29
      Key_Length_Specification key_spec() const override
 
30
         {
 
31
         return m_cipher->key_spec();
 
32
         }
 
33
 
 
34
      std::string name() const override;
 
35
 
 
36
      OFB* clone() const override
 
37
         { return new OFB(m_cipher->clone()); }
 
38
 
 
39
      void clear() override;
 
40
 
 
41
      /**
 
42
      * @param cipher the block cipher to use
 
43
      */
 
44
      explicit OFB(BlockCipher* cipher);
 
45
 
 
46
      void seek(uint64_t offset) override;
 
47
   private:
 
48
      void key_schedule(const uint8_t key[], size_t key_len) override;
 
49
 
 
50
      std::unique_ptr<BlockCipher> m_cipher;
 
51
      secure_vector<uint8_t> m_buffer;
 
52
      size_t m_buf_pos;
 
53
   };
 
54
 
 
55
}
 
56
 
 
57
#endif