Skip to content

x/crypto/openpgp: How to decrypt message when ReadMessage method received interface KeyRing #41640

@jirawat-opn

Description

@jirawat-opn

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

$ go version
go version go1.15 darwin/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="/Users/ntsd/git/go/bin"
GOCACHE="/Users/ntsd/Library/Caches/go-build"
GOENV="/Users/ntsd/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ntsd/git/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ntsd/git/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ntsd/git/go/src/github.com/omiselabs/s3-sftp-lambda/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y2/qwk84xfn4vj35h_7100sr6540000gp/T/go-build030774959=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I want to use the ReadMessage method

https://github.com/golang/crypto/blob/530e935923ad688be97c15eeb8e5ee42ebf2b54a/openpgp/read.go#L86

I found that receive the KeyRing interface as a parameter

https://github.com/golang/crypto/blob/e1dfcc566284e143ba8f9afbb3fa563f2a0d212b/openpgp/keys.go#L61

What did you expect to see?

I can't find anything to return the KeyRing interface and implement it with the KeyRing interface. I don't know how to use the ReadMessage method to Decrypt message with my GPG private key.

What did you see instead?

I don't know how to create KeyRing. I see the other example and tutorial over the internet they can use *[]EntityList that returns from ReadKeyRing and ReadArmoredKeyRing

https://github.com/golang/crypto/blob/e1dfcc566284e143ba8f9afbb3fa563f2a0d212b/openpgp/keys.go#L253

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions