Botan 3.9.0
Crypto and TLS for C&
iso9796.h
Go to the documentation of this file.
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/internal/sig_padding.h>
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace Botan {
17
18class HashFunction;
19
20/**
21* ISO-9796-2 - Digital signature scheme 2 (probabilistic)
22*/
24 public:
25 /**
26 * @param hash function to use
27 * @param implicit whether or not the trailer is implicit
28 * @param salt_size size of the salt to use in bytes
29 */
30 ISO_9796_DS2(std::unique_ptr<HashFunction> hash, bool implicit, size_t salt_size) :
31 m_hash(std::move(hash)), m_implicit(implicit), m_salt_len(salt_size) {}
32
33 std::string hash_function() const override;
34
35 std::string name() const override;
36
37 private:
38 void update(const uint8_t input[], size_t length) override;
39
40 std::vector<uint8_t> raw_data() override;
41
42 std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
43 size_t output_bits,
44 RandomNumberGenerator& rng) override;
45
46 bool verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, size_t key_bits) override;
47
48 std::unique_ptr<HashFunction> m_hash;
49 bool m_implicit;
50 size_t m_salt_len;
51 std::vector<uint8_t> m_msg_buffer;
52};
53
54/**
55* ISO-9796-2 - Digital signature scheme 3 (deterministic)
56*/
58 public:
59 /**
60 * @param hash function to use
61 * @param implicit whether or not the trailer is implicit
62 */
63 explicit ISO_9796_DS3(std::unique_ptr<HashFunction> hash, bool implicit = false) :
64 m_hash(std::move(hash)), m_implicit(implicit) {}
65
66 std::string name() const override;
67
68 std::string hash_function() const override;
69
70 private:
71 void update(const uint8_t input[], size_t length) override;
72
73 std::vector<uint8_t> raw_data() override;
74
75 std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
76 size_t output_bits,
77 RandomNumberGenerator& rng) override;
78
79 bool verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, size_t key_bits) override;
80
81 std::unique_ptr<HashFunction> m_hash;
82 bool m_implicit;
83 std::vector<uint8_t> m_msg_buffer;
84};
85
86} // namespace Botan
87
88#endif
std::string name() const override
Definition iso9796.cpp:253
ISO_9796_DS2(std::unique_ptr< HashFunction > hash, bool implicit, size_t salt_size)
Definition iso9796.h:30
std::string hash_function() const override
Definition iso9796.cpp:246
std::string hash_function() const override
Definition iso9796.cpp:291
std::string name() const override
Definition iso9796.cpp:298
ISO_9796_DS3(std::unique_ptr< HashFunction > hash, bool implicit=false)
Definition iso9796.h:63
virtual std::vector< uint8_t > raw_data()=0