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: Unmarshal allows arbitrary numbers of leading zeros when decoding integers #12622

Closed
alex opened this issue Sep 15, 2015 · 2 comments
Milestone

Comments

@alex
Copy link
Contributor

alex commented Sep 15, 2015

Example:

package main

import (
    "encoding/asn1"
    "fmt"
    "math/big"
)

func main() {
    data := &struct {
        A int64
        B *big.Int
    }{}
    _, err := asn1.Unmarshal([]byte{0x30, 0x0e, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01}, data)
    if err != nil {
        panic(err)
    }
    fmt.Printf("%#v\n", data)
}

Per the DER spec, INTEGER must be minimally encoded.

$ go version
go version go1.5.1 darwin/amd64
@bradfitz bradfitz added this to the Go1.6 milestone Sep 15, 2015
@gopherbot
Copy link

CL https://golang.org/cl/16517 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/17008 mentions this issue.

@golang golang locked and limited conversation to collaborators Dec 1, 2016
@rsc rsc unassigned agl Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants