Skip to content

x/crypto/openpgp/clearsign: CRLF line endings not preserved in plaintext #43437

Closed
@benprew

Description

@benprew

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

$ go version
go version go1.15.5 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=""
GOCACHE="/Users/bprew/Library/Caches/go-build"
GOENV="/Users/bprew/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/bprew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/bprew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/v2/83cnrrx13rn5q7l3qj_vkk4sc90dkq/T/go-build010582822=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Hi, I'm a new Go user and this is my first issue, apologies in advance if I missed anything.

I'm trying to preserve CRLF line endings in a clearsigned message.

openpgp/clearsign.Encode strips out trailing whitespace and the line ending and replaces it with CRLF when passing it to the hasher (which matches RFC-4880). But for the plaintext, it replaces it with LF (which I didn't see specified in the RFC). I would like the CRLF to persist in the plaintext.

(Note: keeping CRLF in the clearsigned message matches the behavior of gpg 2.2.24)

Here's an example of the behavior:

https://play.golang.org/p/EC_S61QqbSJ

Also, I have a change that preserves trailing whitespace and line endings in the plaintext, and am happy to submit a PR to fix this behavior.

What did you expect to see?

I expected to see CRLF line endings in the clearsigned message.

What did you see instead?

The clearsigned message used LF as line endings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions