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

crypto/x509: division by zero #11233

Closed
dvyukov opened this issue Jun 16, 2015 · 2 comments
Closed

crypto/x509: division by zero #11233

dvyukov opened this issue Jun 16, 2015 · 2 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jun 16, 2015

This is a regression from 1.4.2.

The following program crashes with the panic:

package main

import "crypto/x509"

func main() {
    data := []byte("0\x16\x02\x00\x02\x02\u007f\x00\x02\x0200\x02\x0200\x02\x02\x00\x01\x02\x02\u007f\x00")
    x509.ParsePKCS1PrivateKey(data)
}
panic: division by zero

goroutine 1 [running]:
math/big.nat.div(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc208016750, 0x1, 0x5, 0xc208016780, ...)
    src/math/big/nat.go:529 +0xc0
math/big.(*Int).QuoRem(0xc208089bd8, 0xc208089d10, 0xc208089cf0, 0xc208089d30, 0x466a57, 0xc208016780)
    src/math/big/int.go:227 +0xe6
math/big.(*Int).Mod(0xc208089d30, 0xc208089d10, 0xc208089cf0, 0xc208089cf0)
    src/math/big/int.go:258 +0x149
crypto/rsa.(*PrivateKey).Validate(0xc20801e180, 0x0, 0x0)
    src/crypto/rsa/rsa.go:165 +0x3c5
crypto/x509.ParsePKCS1PrivateKey(0xc208010580, 0x18, 0x20, 0xc20801e180, 0x0, 0x0)
    src/crypto/x509/pkcs1.go:77 +0x6af
main.main()
    pkcs.go:7 +0x66

go version devel +4105265 Fri Jun 12 15:51:21 2015 +0000 linux/amd64

@bradfitz bradfitz added this to the Go1.5 milestone Jun 16, 2015
@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@agl agl closed this as completed in 2814906 Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 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