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

Upgrade to Go 1.20 #427

Closed

Conversation

cmenginnz
Copy link
Contributor

Due to changes in the internal implementation of Go, upgrading from Go 1.19 (or earlier) to Go 1.20 will have two impacts on Chisel:

  1. Given a key-seed, Go 1.19 and Go 1.20 will generate different private keys.
  2. Given a key-seed, Go 1.20 will generate two different private keys.
    Generating different private keys implies generating different fingerprints.

My software heavily relies on Chisel. There are hundreds of client nodes that store their own fingerprints. When upgrading to Go 1.20, the changed fingerprints will cause all client nodes to lose connections to the server.

This PR attempts to address the two issues above by:

  1. Allows users to specify a private key file instead of generating it through a key-seed.
  2. When ecdsa.GenerateKey tries to read 1 byte from the DetermRand reader, DetermRand skips moving to the next hash. In this way, it can neutralize the effects of MaybeReadRand() and always generates the same private key for a given key-seed.

Copy link
Owner

@jpillora jpillora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! will likely merge this soon

main.go Outdated Show resolved Hide resolved
jpillora added a commit that referenced this pull request Jul 9, 2023
commit 234a8f6
Author: cmeng <[email protected]>
Date:   Tue May 16 10:26:19 2023 +1200

    allow users to specify a private key file

commit 85a7d96
Author: cmeng <[email protected]>
Date:   Tue May 16 10:25:20 2023 +1200

    generate deterministic key with a given seed
@cmenginnz
Copy link
Contributor Author

jpillora, thanks for your review.

@jpillora
Copy link
Owner

jpillora commented Aug 7, 2023

hey @cmenginnz I bumped modules, and merged this PR into https://github.com/jpillora/chisel/compare/go120 but still failing (https://github.com/jpillora/chisel/actions/runs/5785559596) did you see this failure as well?

@cmenginnz
Copy link
Contributor Author

Hey @jpillora, I pushed a commit into this PR to fix the test failure. Thanks.

@jpillora
Copy link
Owner

jpillora commented Aug 7, 2023

Oh, I'm hoping we can use the same fingerprints - the standard lib explicitly says that it's not deterministic, so we might need to change the key gen library - and offer an easier way generate key files

@jpillora
Copy link
Owner

jpillora commented Aug 7, 2023

based on this golang/go#38548 (comment) Go is guarding against chisel's use case explicitly - bad decision by me early on to have a key seed option though here we are

we have two options:

  1. copy and paste the go 1.19 and earlier generate key algorithm out of the standard library and directly into chisel

  2. I think from the next release, key seed won't generate a deterministic key - instead it'll exit with a message saying "use the server --keygen /file/path, followed by a server --keyfile /file/path" option which will output a generated key there

option 1 could be considered insecure, so I think if we should support both 1 and 2, and if we go with 1 it should print the deprecation message above and suggest 2

@jpillora jpillora changed the title Deterministic private key with Go 1.20 Upgrade to Go 1.20 Aug 7, 2023
@cmenginnz
Copy link
Contributor Author

@jpillora yes, it's good if we can use the same fingerprint. I will try to support options 1 and 2.

Currently, in my PR, the argument name is "--private-key-file". Could you confirm that you want to rename it to "--keyfile"? Thanks.

@jpillora
Copy link
Owner

jpillora commented Aug 8, 2023 via email

@cmenginnz
Copy link
Contributor Author

@jpillora, Following your comments, both options are implemented.

chisel server --key=test123
Start a chisel server that has the same fingerprint as Go1.19.

chisel server --keygen=/tmp/key
Generate an ssh key file.

chisel server --keyfile=/tmp/key
Start a Chisel server using the specified ssh key file.

@jpillora
Copy link
Owner

Closed with #440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants