Botan 3.7.1
Crypto and TLS for C&
keypair.h
Go to the documentation of this file.
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
13namespace Botan::KeyPair {
14
15/**
16* Tests whether the key is consistent for encryption; whether
17* encrypting and then decrypting gives to the original plaintext.
18* @param rng the rng to use
19* @param private_key the key to test
20* @param public_key the key to test
21* @param padding the encryption padding method to use
22* @return true if consistent otherwise false
23*/
24bool encryption_consistency_check(RandomNumberGenerator& rng,
25 const Private_Key& private_key,
26 const Public_Key& public_key,
27 std::string_view padding);
28
29/**
30* Tests whether the key is consistent for signatures; whether a
31* signature can be created and then verified
32* @param rng the rng to use
33* @param private_key the key to test
34* @param public_key the key to test
35* @param padding the signature padding method to use
36* @return true if consistent otherwise false
37*/
38bool signature_consistency_check(RandomNumberGenerator& rng,
39 const Private_Key& private_key,
40 const Public_Key& public_key,
41 std::string_view padding);
42
43/**
44* Tests whether the key is consistent for encryption; whether
45* encrypting and then decrypting gives to the original plaintext.
46* @param rng the rng to use
47* @param sk the key to test
48* @param padding the encryption padding method to use
49* @return true if consistent otherwise false
50*/
51inline bool encryption_consistency_check(RandomNumberGenerator& rng, const Private_Key& sk, std::string_view padding) {
52 auto pk = sk.public_key();
53 return encryption_consistency_check(rng, sk, *pk, padding);
54}
55
56/**
57* Tests whether the key is consistent for signatures; whether a
58* signature can be created and then verified
59* @param rng the rng to use
60* @param sk the key to test
61* @param padding the signature padding method to use
62* @return true if consistent otherwise false
63*/
64inline bool signature_consistency_check(RandomNumberGenerator& rng, const Private_Key& sk, std::string_view padding) {
65 auto pk = sk.public_key();
66 return signature_consistency_check(rng, sk, *pk, padding);
67}
68
69} // namespace Botan::KeyPair
70
71#endif
virtual std::unique_ptr< Public_Key > public_key() const =0
bool signature_consistency_check(RandomNumberGenerator &rng, const Private_Key &private_key, const Public_Key &public_key, std::string_view padding)
Definition keypair.cpp:49
bool encryption_consistency_check(RandomNumberGenerator &rng, const Private_Key &private_key, const Public_Key &public_key, std::string_view padding)
Definition keypair.cpp:18