Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/crypto/ssh: ParsePrivateKeyWithPassphrase returns an opaque error in case of wrong passphrase #20781

Closed
mattn opened this issue Jun 24, 2017 · 1 comment
Milestone

Comments

@mattn
Copy link
Member

@mattn mattn commented Jun 24, 2017

What version of Go are you using (go version)?

go version devel +2f73efa971 Wed May 31 21:03:26 2017 +0000 windows/amd64

What operating system and processor architecture are you using (go env)?

windows amd64

What did you do?

_, err = ssh.ParsePrivateKeyWithPassphrase(pembytes, []byte("incorrect"))
if err != nil {
  if isWrongPassword(err) {
    println("wrong password")
  } else {
    println("invalid key")
  }
}

It's difficult to implement isWrongPassword.

_, err = ssh.ParsePrivateKeyWithPassphrase(pembytes, []byte("incorrect"))
if err != nil {
  if err == ssh.ErrorXXX {
    println("wrong password")
  } else {
    println("invalid key")
  }
}

Hope to check with constant err value

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 24, 2017

CL https://golang.org/cl/46439 mentions this issue.

@mikioh mikioh changed the title crypto/ssh: ParsePrivateKeyWithPassphrase return error not constant. x/crypto/ssh: ParsePrivateKeyWithPassphrase returns an opaque error in case of wrong passphrase Jun 24, 2017
@gopherbot gopherbot added this to the Unreleased milestone Jun 24, 2017
tg123 added a commit to tg123/sshpiper that referenced this issue Jul 29, 2017
…rdError

Fixes golang/go#20781

Change-Id: Iae42fff3c9b0b9984509e44a92f9bc99a1a12470
Reviewed-on: https://go-review.googlesource.com/46439
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Jun 28, 2018
bored-engineer pushed a commit to bored-engineer/ssh that referenced this issue Oct 13, 2019
…rdError

Fixes golang/go#20781

Change-Id: Iae42fff3c9b0b9984509e44a92f9bc99a1a12470
Reviewed-on: https://go-review.googlesource.com/46439
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
bored-engineer pushed a commit to bored-engineer/ssh that referenced this issue Oct 13, 2019
…rdError

Fixes golang/go#20781

Change-Id: Iae42fff3c9b0b9984509e44a92f9bc99a1a12470
Reviewed-on: https://go-review.googlesource.com/46439
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.