]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/pkcs11signers.hh
Merge remote-tracking branch 'origin/master' into rec-edsn-unaligned-test
[thirdparty/pdns.git] / pdns / pkcs11signers.hh
1 /*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22 #ifndef PDNS_PKCS11SIGNERS_HH
23 #define PDNS_PKCS11SIGNERS_HH
24
25 class PKCS11DNSCryptoKeyEngine : public DNSCryptoKeyEngine
26 {
27 protected:
28 std::string d_module;
29 std::string d_slot_id;
30 std::string d_pin;
31 std::string d_label;
32 std::string d_pub_label;
33
34 public:
35 PKCS11DNSCryptoKeyEngine(unsigned int algorithm);
36 ~PKCS11DNSCryptoKeyEngine();
37
38 bool operator<(const PKCS11DNSCryptoKeyEngine& rhs) const
39 {
40 return false;
41 }
42 PKCS11DNSCryptoKeyEngine(const PKCS11DNSCryptoKeyEngine& orig);
43
44 string getName() const override { return "P11 Kit PKCS#11"; };
45
46 void create(unsigned int bits) override;
47
48 storvector_t convertToISCVector() const override;
49
50 std::string sign(const std::string& msg) const override;
51
52 std::string hash(const std::string& msg) const override;
53
54 bool verify(const std::string& msg, const std::string& signature) const override;
55
56 std::string getPubKeyHash() const override;
57
58 std::string getPublicKeyString() const override;
59 int getBits() const override;
60
61 void fromISCMap(DNSKEYRecordContent& drc, stormap_t& stormap) override;
62
63 void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) override { throw "Unimplemented"; };
64 void fromPublicKeyString(const std::string& content) override { throw "Unimplemented"; };
65
66 static std::shared_ptr<DNSCryptoKeyEngine> maker(unsigned int algorithm);
67 };
68
69 bool PKCS11ModuleSlotLogin(const std::string& module, const string& tokenId, const std::string& pin);
70
71 #endif /* PDNS_PKCS11SIGNERS_HH */