Compare commits

..

3 Commits

Author SHA1 Message Date
amery 2776bbbc13 jpictl/dns: introduce add command to register new machines
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-26 22:13:48 +01:00
amery 2dee87cff9 dns: refactor asSyncRecords()
for direct access of the unsorted map

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-26 19:50:53 +01:00
amery 4213ae3d5f Merge branch 'pr-amery-dns' into next-amery 2023-10-26 19:50:27 +01:00
+9 -3
View File
@@ -207,14 +207,20 @@ type KeyPair struct {
// Validate checks the PublicKey matches the PrivateKey,
// and sets the PublicKey if missing
func (kp *KeyPair) Validate() error {
keyLen := len(kp.PrivateKey)
pubLen := len(kp.PublicKey)
switch {
case kp.PrivateKey.IsZero():
// no private key
case keyLen != PrivateKeySize:
// bad private key
return ErrInvalidPrivateKey
case kp.PublicKey.IsZero():
case pubLen == 0:
// no public key, set it
kp.PublicKey = kp.PrivateKey.Public()
return nil
case pubLen != PublicKeySize:
// bad public key
return ErrInvalidPublicKey
case !kp.PrivateKey.Public().Equal(kp.PublicKey):
// wrong public key
return ErrInvalidPublicKey