Skip to content

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

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

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

Comments

@mattn
Copy link
Member

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
Contributor

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 pushed 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>
c-expert-zigbee pushed a commit to c-expert-zigbee/crypto_go that referenced this issue Mar 28, 2022
…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>
c-expert-zigbee pushed a commit to c-expert-zigbee/crypto_go that referenced this issue Mar 29, 2022
…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>
LewiGoddard pushed a commit to LewiGoddard/crypto that referenced this issue Feb 16, 2023
…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>
BiiChris pushed a commit to BiiChris/crypto that referenced this issue Sep 15, 2023
…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>
desdeel2d0m added a commit to desdeel2d0m/crypto that referenced this issue Jul 1, 2024
…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
Development

No branches or pull requests

2 participants