Skip to content

Commit 4414468

Browse files
committed
Validate key when loading from ISC map
1 parent c163d41 commit 4414468

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

pdns/pkcs11signers.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,21 @@ DNSCryptoKeyEngine::storvector_t PKCS11DNSCryptoKeyEngine::convertToISCVector()
857857
return storvect;
858858
};
859859

860+
void PKCS11DNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, stormap_t& stormap) {
861+
drc.d_algorithm = atoi(stormap["algorithm"].c_str());
862+
d_module = stormap["engine"];
863+
d_slot_id = atoi(stormap["slot"].c_str());
864+
d_pin = stormap["pin"];
865+
d_label = stormap["label"];
866+
// validate parameters
867+
868+
boost::shared_ptr<Pkcs11Token> d_slot;
869+
d_slot = Pkcs11Token::GetToken(d_module, d_slot_id, d_label);
870+
if (d_pin != "" && d_slot->LoggedIn() == false)
871+
if (d_slot->Login(d_pin) == false)
872+
throw PDNSException("Could not log in to token (PIN wrong?)");
873+
};
874+
860875
DNSCryptoKeyEngine* PKCS11DNSCryptoKeyEngine::maker(unsigned int algorithm)
861876
{
862877
return new PKCS11DNSCryptoKeyEngine(algorithm);

pdns/pkcs11signers.hh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ class PKCS11DNSCryptoKeyEngine : public DNSCryptoKeyEngine
3333
std::string getPublicKeyString() const;
3434
int getBits() const;
3535

36-
void fromISCMap(DNSKEYRecordContent& drc, stormap_t& stormap) {
37-
drc.d_algorithm = atoi(stormap["algorithm"].c_str());
38-
d_module = stormap["engine"];
39-
d_slot_id = atoi(stormap["slot"].c_str());
40-
d_pin = stormap["pin"];
41-
d_label = stormap["label"];
42-
};
36+
void fromISCMap(DNSKEYRecordContent& drc, stormap_t& stormap);
4337

4438
void fromPEMString(DNSKEYRecordContent& drc, const std::string& raw) { throw "Unimplemented"; };
4539
void fromPublicKeyString(const std::string& content) { throw "Unimplemented"; };

0 commit comments

Comments
 (0)