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/openpgp: SerializePrivate output changes after loading with ReadKeyRing/ReadArmoredKeyring #37497

Closed
koshatul opened this issue Feb 27, 2020 · 3 comments

Comments

@koshatul
Copy link

@koshatul koshatul commented Feb 27, 2020

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

$ go version
go version go1.13.8 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/go/github.com/koshatul/openpgp-hash-change/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build778545963=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I made a reproducible test koshatul/openpgp-hash-change.

When loading the private key from a file, and writing it back to a file the output is different, but it seems to alternate back and forth between two versions, so if I load the key from file, write it, it will now have "content b", then when I load and write it again, it will be back to the original content.

What did you expect to see?

Loading and writing a private key to not change the file content.

What did you see instead?

Whenever I read the private key from the drive and write it back the content changes, but it changes back and forth between two different versions of the output.

@gopherbot gopherbot added this to the Unreleased milestone Feb 27, 2020
@koshatul
Copy link
Author

@koshatul koshatul commented Feb 27, 2020

I also tested it with unarmored SerializePrivate and ReadKeyRing

@koshatul koshatul changed the title x/crypto/openpgp: SerializePrivate output changes after loading with ReadArmoredKeyring x/crypto/openpgp: SerializePrivate output changes after loading with ReadKeyRing/ReadArmoredKeyring Feb 27, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Feb 28, 2020

@FiloSottile
Copy link
Contributor

@FiloSottile FiloSottile commented Mar 29, 2021

Per the accepted #44226 proposal and due to lack of maintenance, the golang.org/x/crypto/openpgp package is now frozen and deprecated. No new changes will be accepted except for security fixes. The package will not be removed.

If this is a security issue, please email security@golang.org and we will assess it and provide a fix.

If you're looking for alternatives, consider the crypto/ed25519 package for simple signatures, golang.org/x/mod/sumdb/note for inline signatures, or filippo.io/age for encryption. You can read a summary of OpenPGP issues and alternatives here.

If you are required to interoperate with OpenPGP systems and need a maintained package, we suggest considering one of multiple community forks of golang.org/x/crypto/openpgp. We don't endorse any specific one.

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

Successfully merging a pull request may close this issue.

None yet
4 participants