1 /*
2 * Keypair Checks
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_KEYPAIR_CHECKS_H_
9 #define BOTAN_KEYPAIR_CHECKS_H_
10
11 #include <botan/pk_keys.h>
12
13 BOTAN_FUTURE_INTERNAL_HEADER(keypair.h)
14
15 namespace Botan {
16
17 namespace KeyPair {
18
19 /**
20 * Tests whether the key is consistent for encryption; whether
21 * encrypting and then decrypting gives to the original plaintext.
22 * @param rng the rng to use
23 * @param private_key the key to test
24 * @param public_key the key to test
25 * @param padding the encryption padding method to use
26 * @return true if consistent otherwise false
27 */
28 BOTAN_PUBLIC_API(2,0) bool
29 encryption_consistency_check(RandomNumberGenerator& rng,
30 const Private_Key& private_key,
31 const Public_Key& public_key,
32 const std::string& padding);
33
34 /**
35 * Tests whether the key is consistent for signatures; whether a
36 * signature can be created and then verified
37 * @param rng the rng to use
38 * @param private_key the key to test
39 * @param public_key the key to test
40 * @param padding the signature padding method to use
41 * @return true if consistent otherwise false
42 */
43 BOTAN_PUBLIC_API(2,0) bool
44 signature_consistency_check(RandomNumberGenerator& rng,
45 const Private_Key& private_key,
46 const Public_Key& public_key,
47 const std::string& padding);
48
49 /**
50 * Tests whether the key is consistent for encryption; whether
51 * encrypting and then decrypting gives to the original plaintext.
52 * @param rng the rng to use
53 * @param key the key to test
54 * @param padding the encryption padding method to use
55 * @return true if consistent otherwise false
56 */
57 inline bool
encryption_consistency_check(RandomNumberGenerator & rng,const Private_Key & key,const std::string & padding)58 encryption_consistency_check(RandomNumberGenerator& rng,
59 const Private_Key& key,
60 const std::string& padding)
61 {
62 return encryption_consistency_check(rng, key, key, padding);
63 }
64
65 /**
66 * Tests whether the key is consistent for signatures; whether a
67 * signature can be created and then verified
68 * @param rng the rng to use
69 * @param key the key to test
70 * @param padding the signature padding method to use
71 * @return true if consistent otherwise false
72 */
73 inline bool
signature_consistency_check(RandomNumberGenerator & rng,const Private_Key & key,const std::string & padding)74 signature_consistency_check(RandomNumberGenerator& rng,
75 const Private_Key& key,
76 const std::string& padding)
77 {
78 return signature_consistency_check(rng, key, key, padding);
79 }
80
81 }
82
83 }
84
85 #endif
86