Botan 2.19.5 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
14 BOTAN_FUTURE_INTERNAL_HEADER(iso9796.h)
15
16namespace 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 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
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 {}
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
Botan::EMSA
Definition: emsa.h:28
Botan::EMSA::encoding_of
virtual secure_vector< uint8_t > encoding_of(const secure_vector< uint8_t > &msg, size_t output_bits, RandomNumberGenerator &rng)=0
Botan::EMSA::verify
virtual bool verify(const secure_vector< uint8_t > &coded, const secure_vector< uint8_t > &raw, size_t key_bits)=0
Botan::EMSA::raw_data
virtual secure_vector< uint8_t > raw_data()=0
Botan::EMSA::name
virtual std::string name() const =0
Botan::EMSA::clone
virtual EMSA * clone()=0
Botan::EMSA::update
virtual void update(const uint8_t input[], size_t length)=0
Botan::HashFunction
Definition: hash.h:21
Botan::ISO_9796_DS2
Definition: iso9796.h:22
Botan::ISO_9796_DS2::ISO_9796_DS2
ISO_9796_DS2(HashFunction *hash, bool implicit=false)
Definition: iso9796.h:28
Botan::ISO_9796_DS2::ISO_9796_DS2
ISO_9796_DS2(HashFunction *hash, bool implicit, size_t salt_size)
Definition: iso9796.h:36
Botan::ISO_9796_DS3
Definition: iso9796.h:65
Botan::ISO_9796_DS3::ISO_9796_DS3
ISO_9796_DS3(HashFunction *hash, bool implicit=false)
Definition: iso9796.h:71
Botan::RandomNumberGenerator
Definition: rng.h:26
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
hash
MechanismType hash
Definition: p11_mechanism.cpp:64
salt_size
size_t salt_size
Definition: p11_mechanism.cpp:70