Skip to content

How to extract the IV of AES-GCM in "crypto/cipher" #32742

Closed
@jyxjjj

Description

@jyxjjj

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

go version go1.12.6 linux/amd64

Does this issue reproduce with the latest release?

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/data/Projects/Go/gopath"
GOPROXY=""
GORACE=""
GOROOT="/data/go"
GOTMPDIR=""
GOTOOLDIR="/data/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build319981367=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Developing an "AES-256-GCM" Client Interacting with PHP-openssl-ext

What did you expect to see?

Like this (It's Pseudo-code and only my target):

It's Pseudo-code and only my target:

func encrypt("123"(data),"123"(key))
return encryptedData(hex)+"|"+iv(hex)+"|"+nonce(hex)

then:

encryptedData = split(return)[0]
iv = split(return)[1]
nonce = split(return)[2]
decrypt(encryptedData , iv , nonce)
return decryptedData

What did you see instead?

1.Golang has no iv, only nonce.(I found Python maybe hasn't too. But C and PHP has. And the RFC doc said it should have.)
2.Golang doesn't support un-fixed very short length password.(like "123" will cause error because of its short.)(It doesn't mean i can't do any padding for the password(key), If I do, it can't crypt as well as php.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions