1 /**
2 * EMSA Classes
3 *
4 * Copyright:
5 * (C) 1999-2007 Jack Lloyd
6 * (C) 2014-2015 Etienne Cimon
7 *
8 * License:
9 * Botan is released under the Simplified BSD License (see LICENSE.md)
10 */
11 module botan.pk_pad.emsa;
12
13 import memutils.vector;
14 public import botan.rng.rng;
15 /**
16 * Encoding Method for Signatures, Appendix
17 */
18 interface EMSA
19 {
20 public:
21 /**
22 * Add more data to the signature computation
23 * Params:
24 * input = some data
25 * length = length of input in bytes
26 */
27 abstract void update(const(ubyte)* input, size_t length);
28
29 /**
30 * Returns: raw hash
31 */
32 abstract SecureVector!ubyte rawData();
33
34 /**
35 * Return the encoding of a message
36 * Params:
37 * msg = the result of rawData()
38 * output_bits = the desired output bit size
39 * rng = a random number generator
40 * Returns: encoded signature
41 */
42 abstract SecureVector!ubyte encodingOf(const ref SecureVector!ubyte msg,
43 size_t output_bits,
44 RandomNumberGenerator rng);
45
46 /// ditto
47 final SecureVector!ubyte encodingOf(const SecureVector!ubyte msg,
48 size_t output_bits,
49 RandomNumberGenerator rng)
50 {
51 return encodingOf(msg, output_bits, rng);
52 }
53
54 /**
55 * Verify the encoding
56 * Params:
57 * coded = the received (coded) message representative
58 * raw = the computed (local, uncoded) message representative
59 * key_bits = the size of the key in bits
60 * Returns: true if coded is a valid encoding of raw, otherwise false
61 */
62 abstract bool verify(const ref SecureVector!ubyte coded,
63 const ref SecureVector!ubyte raw,
64 size_t key_bits);
65 }