Incorrect HIP RR public key length decode (#1262)
When decoding a HIP resource record, 'base64.StdEncoding.DecodedLen' can return a length larger than the length of the decoded public key. This change decodes the public key and retrieves the correct length. In our tests, the public key length was being set to 33, instead of 32. Below is our offending resource record: '23b5993f649c0827.a.b.c. 3600 IN HIP 5 200100100020001523B5993F649C0827 Cm6k4jhir9YYoKq9JDqD3Ob1hBfCuwbWam1igFPhkGg='
This commit is contained in:
parent
d2b5d38d4f
commit
9922549621
|
@ -734,7 +734,11 @@ func (rr *HIP) parse(c *zlexer, o string) *ParseError {
|
|||
return &ParseError{"", "bad HIP PublicKey", l}
|
||||
}
|
||||
rr.PublicKey = l.token // This cannot contain spaces
|
||||
rr.PublicKeyLength = uint16(base64.StdEncoding.DecodedLen(len(rr.PublicKey)))
|
||||
decodedPK, decodedPKerr := base64.StdEncoding.DecodeString(rr.PublicKey)
|
||||
if decodedPKerr != nil{
|
||||
return &ParseError{"", "bad HIP PublicKey", l}
|
||||
}
|
||||
rr.PublicKeyLength = uint16(len(decodedPK))
|
||||
|
||||
// RendezvousServers (if any)
|
||||
l, _ = c.Next()
|
||||
|
|
Loading…
Reference in New Issue