aboutsummaryrefslogtreecommitdiff
path: root/ssh/keys.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2025-01-27 17:27:48 +0700
committerShulhan <m.shulhan@gmail.com>2026-03-27 02:56:30 +0700
commitf88a1e842ae6c96508e445694e94e1b7d84415a5 (patch)
tree12dc9adbaa7cd3ccbc5af955ca7f1e8002b61477 /ssh/keys.go
parent8400f4a938077a7a7817ab7d163d148e371b320b (diff)
downloadgo-x-crypto-f88a1e842ae6c96508e445694e94e1b7d84415a5.tar.xz
ssh: implement method Is in PassphraseMissingError
The Is method allow the returned error checked using errors.Is againts PassphraseMissingError.
Diffstat (limited to 'ssh/keys.go')
-rw-r--r--ssh/keys.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/ssh/keys.go b/ssh/keys.go
index 47a0753..18851e7 100644
--- a/ssh/keys.go
+++ b/ssh/keys.go
@@ -1271,6 +1271,12 @@ func (*PassphraseMissingError) Error() string {
return "ssh: this private key is passphrase protected"
}
+// Is return true if the target is an instance of PassphraseMissingError.
+func (errPassMissing *PassphraseMissingError) Is(target error) (ok bool) {
+ _, ok = target.(*PassphraseMissingError)
+ return ok
+}
+
// ParseRawPrivateKey returns a private key from a PEM encoded private key. It supports
// RSA, DSA, ECDSA, and Ed25519 private keys in PKCS#1, PKCS#8, OpenSSL, and OpenSSH
// formats. If the private key is encrypted, it will return a PassphraseMissingError.