Botan 2.19.5 Crypto and TLS for C&

emsa.h
Go to the documentation of this file.
1/*
2* EMSA Classes
3* (C) 1999-2007 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_PUBKEY_EMSA_H_
9#define BOTAN_PUBKEY_EMSA_H_
10
11#include <botan/secmem.h>
12#include <botan/asn1_obj.h>
13#include <string>
14
15 BOTAN_FUTURE_INTERNAL_HEADER(emsa.h)
16
17namespace Botan {
18
19 class Private_Key;
20 class RandomNumberGenerator;
21
22/**
23* EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix
24*
25* Any way of encoding/padding signatures
26*/
27 class BOTAN_PUBLIC_API(2,0) EMSA
28 {
29 public:
30 virtual ~EMSA() {}
31
32 /**
33 * Add more data to the signature computation
34 * @param input some data
35 * @param length length of input in bytes
36 */
37 virtual void update(const uint8_t input[], size_t length) = 0;
38
39 /**
40 * @return raw hash
41 */
42 virtual secure_vector<uint8_t> raw_data() = 0;
43
44 /**
45 * Return the encoding of a message
46 * @param msg the result of raw_data()
47 * @param output_bits the desired output bit size
48 * @param rng a random number generator
49 * @return encoded signature
50 */
51 virtual secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
52 size_t output_bits,
53 RandomNumberGenerator& rng) = 0;
54
55 /**
56 * Verify the encoding
57 * @param coded the received (coded) message representative
58 * @param raw the computed (local, uncoded) message representative
59 * @param key_bits the size of the key in bits
60 * @return true if coded is a valid encoding of raw, otherwise false
61 */
62 virtual bool verify(const secure_vector<uint8_t>& coded,
63 const secure_vector<uint8_t>& raw,
64 size_t key_bits) = 0;
65
66 /**
67 * Prepare sig_algo for use in choose_sig_format for x509 certs
68 *
69 * @param key used for checking compatibility with the encoding scheme
70 * @param cert_hash_name is checked to equal the hash for the encoding
71 * @return algorithm identifier to signatures created using this key,
72 * padding method and hash.
73 */
74 virtual AlgorithmIdentifier config_for_x509(const Private_Key& key,
75 const std::string& cert_hash_name) const;
76
77 /**
78 * @return a new object representing the same encoding method as *this
79 */
80 virtual EMSA* clone() = 0;
81
82 /**
83 * @return the SCAN name of the encoding/padding scheme
84 */
85 virtual std::string name() const = 0;
86 };
87
88/**
89* Factory method for EMSA (message-encoding methods for signatures
90* with appendix) objects
91* @param algo_spec the name of the EMSA to create
92* @return pointer to newly allocated object of that type
93*/
94 BOTAN_PUBLIC_API(2,0) EMSA* get_emsa(const std::string& algo_spec);
95
96/**
97* Returns the hash function used in the given EMSA scheme
98* If the hash function is not specified or not understood,
99* returns "SHA-512"
100* @param algo_spec the name of the EMSA
101* @return hash function used in the given EMSA scheme
102*/
103 BOTAN_PUBLIC_API(2,0) std::string hash_for_emsa(const std::string& algo_spec);
104
105}
106
107#endif
Botan::AlgorithmIdentifier
Definition: asn1_obj.h:430
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::~EMSA
virtual ~EMSA()
Definition: emsa.h:30
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::Private_Key
Definition: pk_keys.h:181
Botan::RandomNumberGenerator
Definition: rng.h:26
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::hash_for_emsa
std::string hash_for_emsa(const std::string &algo_spec)
Definition: emsa.cpp:189
Botan::get_emsa
EMSA * get_emsa(const std::string &algo_spec)
Definition: emsa.cpp:44
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
std
Definition: bigint.h:1155