Commit 8281f6bd authored by Adam Langley's avatar Adam Langley

crypto/openpgp/packet: fix private key checksum

I misinterpreted http://tools.ietf.org/html/rfc4880#section-5.5.3
and implemented the sum of 16-bit values, rather than the 16-bit sum
of 8-bit values.

Thanks to Szabolcs Nagy for pointing it out.

R=bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/5372091
parent f2c85874
......@@ -99,13 +99,9 @@ func (pk *PrivateKey) parse(r io.Reader) (err error) {
}
func mod64kHash(d []byte) uint16 {
h := uint16(0)
for i := 0; i < len(d); i += 2 {
v := uint16(d[i]) << 8
if i+1 < len(d) {
v += uint16(d[i+1])
}
h += v
var h uint16
for _, b := range d {
h += uint16(b)
}
return h
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment