Skip to content

Commit 661ec47

Browse files
committed
improve compatibility
1 parent 7385861 commit 661ec47

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

keys/pem.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ const HostEd25519PrivateKeyBanner = "DEFINED HOST ED25519 PRIVATE KEY"
1414
const HostP256PublicKeyBanner = "DEFINED HOST P256 PUBLIC KEY"
1515
const HostP256PrivateKeyBanner = "DEFINED HOST P256 PRIVATE KEY"
1616

17+
const NebulaP256PublicKeyBanner = "NEBULA P256 PUBLIC KEY"
1718
const NebulaECDSAP256PublicKeyBanner = "NEBULA ECDSA P256 PUBLIC KEY"
1819
const NebulaEd25519PublicKeyBanner = "NEBULA ED25519 PUBLIC KEY"
20+
const NebulaX25519PublicKeyBanner = "NEBULA X25519 PUBLIC KEY"
1921

2022
func MarshalHostEd25519PublicKey(k ed25519.PublicKey) ([]byte, error) {
2123
b, err := x509.MarshalPKIXPublicKey(k)
@@ -164,14 +166,14 @@ func UnmarshalTrustedKey(b []byte) (TrustedKey, []byte, error) {
164166
}
165167

166168
switch k.Type {
167-
case NebulaECDSAP256PublicKeyBanner:
169+
case NebulaECDSAP256PublicKeyBanner, NebulaP256PublicKeyBanner:
168170
if len(k.Bytes) != 65 {
169171
return nil, r, fmt.Errorf("key was not 65 bytes, is invalid P256 public key")
170172
}
171173

172174
x, y := elliptic.Unmarshal(elliptic.P256(), k.Bytes)
173175
return P256TrustedKey{&ecdsa.PublicKey{X: x, Y: y, Curve: elliptic.P256()}}, r, nil
174-
case NebulaEd25519PublicKeyBanner:
176+
case NebulaEd25519PublicKeyBanner, NebulaX25519PublicKeyBanner:
175177
if len(k.Bytes) != ed25519.PublicKeySize {
176178
return nil, r, fmt.Errorf("key was not 32 bytes, is invalid ed25519 public key")
177179
}

0 commit comments

Comments
 (0)