]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/pkcs11signers.hh
Fix compilation on systems that do not define HOST_NAME_MAX
[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 #pragma once
23
24 class PKCS11DNSCryptoKeyEngine : public DNSCryptoKeyEngine
25 {
26 protected:
27 std::string d_module;
28 std::string d_slot_id;
29 std::string d_pin;
30 std::string d_label;
31 std::string d_pub_label;
32
33 public:
34 PKCS11DNSCryptoKeyEngine(unsigned int algorithm);
35 ~PKCS11DNSCryptoKeyEngine();
36
37 bool operator<(const PKCS11DNSCryptoKeyEngine& rhs) const
38 {
39 return false;
40 }
41 PKCS11DNSCryptoKeyEngine(const PKCS11DNSCryptoKeyEngine& orig);
42
43 string getName() const override { return "P11 Kit PKCS#11"; };
44
45 void create(unsigned int bits) override;
46
47 storvector_t convertToISCVector() const override;
48
49 std::string sign(const std::string& msg) const override;
50
51 std::string hash(const std::string& msg) const override;
52
53 bool verify(const std::string& msg, const std::string& signature) const override;
54
55 std::string getPubKeyHash() const override;
56
57 std::string getPublicKeyString() const override;
58 int getBits() const override;
59
60 void fromISCMap(DNSKEYRecordContent& drc, stormap_t& stormap) override;
61
62 void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) override { throw "Unimplemented"; };
63 void fromPublicKeyString(const std::string& content) override { throw "Unimplemented"; };
64
65 static std::shared_ptr<DNSCryptoKeyEngine> maker(unsigned int algorithm);
66 };
67
68 bool PKCS11ModuleSlotLogin(const std::string& module, const string& tokenId, const std::string& pin);