Coverage Report

Created: 2019-09-11 14:12

/src/botan/build/include/botan/iso9796.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * ISO-9796-2 - Digital signature schemes giving message recovery schemes 2 and 3
3
 * (C) 2016 Tobias Niemann, Hackmanit GmbH
4
 *
5
 * Botan is released under the Simplified BSD License (see license.txt)
6
 */
7
8
#ifndef BOTAN_ISO9796_H_
9
#define BOTAN_ISO9796_H_
10
11
#include <botan/emsa.h>
12
#include <botan/hash.h>
13
14
BOTAN_FUTURE_INTERNAL_HEADER(iso9796.h)
15
16
namespace Botan {
17
18
/**
19
* ISO-9796-2 - Digital signature scheme 2 (probabilistic)
20
*/
21
class BOTAN_PUBLIC_API(2,0) ISO_9796_DS2 final : public EMSA
22
   {
23
   public:
24
      /**
25
       * @param hash function to use
26
       * @param implicit whether or not the trailer is implicit
27
       */
28
      explicit ISO_9796_DS2(HashFunction* hash, bool implicit = false) : m_hash(hash), m_implicit(implicit),
29
0
         m_SALT_SIZE(hash->output_length()) {}
30
31
      /**
32
       * @param hash function to use
33
       * @param implicit whether or not the trailer is implicit
34
       * @param salt_size size of the salt to use in bytes
35
       */
36
      ISO_9796_DS2(HashFunction* hash, bool implicit, size_t salt_size) : m_hash(hash), m_implicit(implicit),
37
0
         m_SALT_SIZE(salt_size) {}
38
39
      EMSA* clone() override;
40
41
      std::string name() const override;
42
   private:
43
      void update(const uint8_t input[], size_t length) override;
44
45
      secure_vector<uint8_t> raw_data() override;
46
47
      secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
48
                                      size_t output_bits,
49
                                      RandomNumberGenerator& rng) override;
50
51
      bool verify(const secure_vector<uint8_t>& coded,
52
                  const secure_vector<uint8_t>& raw,
53
                  size_t key_bits) override;
54
55
      std::unique_ptr<HashFunction> m_hash;
56
      bool m_implicit;
57
      size_t m_SALT_SIZE;
58
      secure_vector<uint8_t> m_msg_buffer;
59
   };
60
61
/**
62
* ISO-9796-2 - Digital signature scheme 3 (deterministic)
63
*/
64
class BOTAN_PUBLIC_API(2,0) ISO_9796_DS3 final : public EMSA
65
   {
66
   public:
67
      /**
68
       * @param hash function to use
69
       * @param implicit whether or not the trailer is implicit
70
       */
71
      ISO_9796_DS3(HashFunction* hash, bool implicit = false) : m_hash(hash), m_implicit(implicit)
72
0
         {}
73
74
      EMSA* clone() override;
75
76
      std::string name() const override;
77
   private:
78
      void update(const uint8_t input[], size_t length) override;
79
80
      secure_vector<uint8_t> raw_data() override;
81
82
      secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
83
                                      size_t output_bits,
84
                                      RandomNumberGenerator& rng) override;
85
86
      bool verify(const secure_vector<uint8_t>& coded,
87
                  const secure_vector<uint8_t>& raw,
88
                  size_t key_bits) override;
89
90
      std::unique_ptr<HashFunction> m_hash;
91
      bool m_implicit;
92
      secure_vector<uint8_t> m_msg_buffer;
93
   };
94
95
}
96
97
#endif
98