1 /**
2 * PK Operation Types
3 *
4 * Copyright:
5 * (C) 2010 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 modulebotan.pubkey.pk_ops;
12 13 importbotan.constants;
14 staticif (BOTAN_HAS_PUBLIC_KEY_CRYPTO):
15 16 publicimportbotan.asn1.alg_id;
17 publicimportbotan.rng.rng;
18 publicimportbotan.pubkey.pk_keys;
19 importmemutils.vector;
20 21 /**
22 * Public key encryption interface
23 */24 interfaceEncryption25 {
26 public:
27 abstractsize_tmaxInputBits() const;
28 29 abstractSecureVector!ubyteencrypt(const(ubyte)* msg, size_tmsg_len, RandomNumberGeneratorrng);
30 31 }
32 33 /**
34 * Public key decryption interface
35 */36 interfaceDecryption37 {
38 public:
39 abstractsize_tmaxInputBits() const;
40 41 abstractSecureVector!ubytedecrypt(const(ubyte)* msg, size_tmsg_len);
42 43 }
44 45 /**
46 * Public key signature creation interface
47 */48 interfaceSignature49 {
50 public:
51 /**
52 * Find out the number of message parts supported by this scheme.
53 * Returns: number of message parts
54 */55 abstractsize_tmessageParts() const;
56 57 /**
58 * Find out the message part size supported by this scheme/key.
59 * Returns: size of the message parts
60 */61 abstractsize_tmessagePartSize() const;
62 63 /**
64 * Get the maximum message size in bits supported by this public key.
65 * Returns: maximum message in bits
66 */67 abstractsize_tmaxInputBits() const;
68 69 /*
70 * Perform a signature operation
71 * Params:
72 * msg = the message
73 * msg_len = the length of msg in bytes
74 * rng = a random number generator
75 */76 abstractSecureVector!ubytesign(const(ubyte)* msg, size_tmsg_len, RandomNumberGeneratorrng);
77 78 }
79 80 /**
81 * Public key signature verification interface
82 */83 interfaceVerification84 {
85 public:
86 /**
87 * Get the maximum message size in bits supported by this public key.
88 * Returns: maximum message in bits
89 */90 abstractsize_tmaxInputBits() const;
91 92 /**
93 * Find out the number of message parts supported by this scheme.
94 * Returns: number of message parts
95 */96 abstractsize_tmessageParts() const;
97 98 /**
99 * Find out the message part size supported by this scheme/key.
100 * Returns: size of the message parts
101 */102 abstractsize_tmessagePartSize() const;
103 104 /**
105 * Returns: boolean specifying if this key type supports message
106 * recovery and thus if you need to call verify() or verifyMr()
107 */108 abstractboolwithRecovery() const;
109 110 /*
111 * Perform a signature check operation
112 * Params:
113 * msg = the message
114 * msg_len = the length of msg in bytes
115 * sig = the signature
116 * sig_len = the length of sig in bytes
117 * Returns: true if signature is a valid one for message
118 */119 abstractboolverify(const(ubyte)* msg, size_tmsg_len, const(ubyte)* sig, size_tsig_len);
120 121 /*
122 * Perform a signature operation (with message recovery)
123 * Only call this if withRecovery() returns true
124 * Params:
125 * msg = the message
126 * msg_len = the length of msg in bytes
127 * Returns:s recovered message
128 */129 abstractSecureVector!ubyteverifyMr(const(ubyte)* msg, size_tmsg_len);
130 131 }
132 133 /**
134 * A generic key agreement Operation (eg DH or ECDH)
135 */136 interfaceKeyAgreement137 {
138 public:
139 /*
140 * Perform a key agreement operation
141 * Params:
142 * w = the other key value
143 * w_len = the length of w in bytes
144 * Returns:s the agreed key
145 */146 abstractSecureVector!ubyteagree(const(ubyte)* w, size_tw_len);
147 }