Botan 2.19.1
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/emsa.h>
12#include <botan/hash.h>
13
15
16namespace Botan {
17
18/**
19* ISO-9796-2 - Digital signature scheme 2 (probabilistic)
20*/
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 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 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
46
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*/
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 {}
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
81
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
virtual secure_vector< uint8_t > encoding_of(const secure_vector< uint8_t > &msg, size_t output_bits, RandomNumberGenerator &rng)=0
virtual bool verify(const secure_vector< uint8_t > &coded, const secure_vector< uint8_t > &raw, size_t key_bits)=0
virtual secure_vector< uint8_t > raw_data()=0
virtual std::string name() const =0
virtual EMSA * clone()=0
virtual void update(const uint8_t input[], size_t length)=0
ISO_9796_DS2(HashFunction *hash, bool implicit=false)
Definition: iso9796.h:28
ISO_9796_DS2(HashFunction *hash, bool implicit, size_t salt_size)
Definition: iso9796.h:36
ISO_9796_DS3(HashFunction *hash, bool implicit=false)
Definition: iso9796.h:71
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
MechanismType hash
size_t salt_size