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

encoding/asn1: built binary and distributed src seem to be different for encoding/asn1 #18844

Closed
jcmturner opened this issue Jan 29, 2017 · 2 comments

Comments

@jcmturner
Copy link

@jcmturner jcmturner commented Jan 29, 2017

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

go version go1.7.5 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build372878858=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1

Issue

I have been trying to work around some issues with the current implementation of encoding/asn1 by taking a copy of the go files for this package and creating a my own package of them that I can then update. However I get different behaviour using these source files, even when I make no changes to them, than I do with the built go binary.
I copy these source files to my own package directory, make no changes and update the code that uses them to import this location instead for asn1 functionality.
This code can demonstrate this: https://play.golang.org/p/I5EfVpw10y
The code path using "encoding/asn1" generates a different output to identical copy of the asn1 source code.

Bitstring: {Bs:{Bytes:[254 220 186 144] BitLength:32}}
Input bytes:         [48 9 160 7 3 5 0 254 220 186 144]
Output originalasn1: [48 9 160 7 3 5 0 254 220 186 144]
Output copy of asn1: [48 13 160 11 48 9 4 4 254 220 186 144 2 1 32]

So it seems that the source that is distributed as part of 1.7.5 is not what the binary was built from. Or have I got something wrong here?

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Feb 1, 2017

This is a user error. You're mixing two asn1 packages.

If you make your imports simply be:

package main

import (
        "encoding/hex"
        "fmt"
        "os"

        asn1 "github.com/jcmturner/asn1/identicalsrc"
)

.. without importing "encoding/asn1" also, then it works.

You were passing the stdlib's asn1.BitString to your forked package, which didn't recognize that BitString type.

@bradfitz bradfitz closed this Feb 1, 2017
@jcmturner
Copy link
Author

@jcmturner jcmturner commented Feb 2, 2017

Thanks, this makes sense. I suspected it was likely to be my error.

@golang golang locked and limited conversation to collaborators Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.