miekg / dns

DNS library in Go
https://miek.nl/2014/august/16/go-dns-package
BSD 3-Clause "New" or "Revised" License
7.86k stars 1.12k forks source link

Set public key from private key in DNSKEY instead of copying it from DNSKEY to private key #1560

Open baest opened 2 months ago

baest commented 2 months ago

Previously when loading a PrivateKey into a DNSKEY we would return the PrivateKey with the PublicKey set from the DNSKEY struct. Now that behaviour is flipped and the PublicKey is taken from the PrivateKey and set in the DNSKEY.

miekg commented 3 weeks ago

what motivates this change?

baest commented 3 weeks ago

what motivates this change?

I have private keys stored in a database and I need to load those, get the public key from it and also use that to create the DS. The previous version took the public key from the DNSKEY object and then copied it into the private key. To me it makes more sense to just keep the public key stored inside the private key (and it also serves my needs to be fair). Also this change makes it simpler to load a private key, since an almost empty DNSKEY object can be used to load the private key.