Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
parsing zonemd in rfc3597
Browse files Browse the repository at this point in the history
  • Loading branch information
madestro committed Jan 26, 2021
1 parent 8c462fe commit 678d105
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scan_rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,38 @@ func (rr *CSYNC) parse(c *zlexer, o string) *ParseError {

func (rr *ZONEMD) parse(c *zlexer, o string) *ParseError {
l, _ := c.Next()
if (l.token == "\\#") {
c.Next() // spaces
l, _ = c.Next()
i, e := strconv.ParseUint(l.token, 10, 32)
if e != nil || l.err {
return &ParseError{"", "error Parsing RFC 3597 RR...",l}
}
hexlen := int(i)
c.Next() // spaces
l, _ = c.Next()
if len(l.token)/2 != hexlen {
return &ParseError{"","Error hexadecimal wrong size",l}
}
// Start parsing
i, e = strconv.ParseUint(l.token[0:8], 16, 32)
if e != nil || l.err {
return &ParseError{"", "bad ZONEMD Serial", l}
}
rr.Serial = uint32(i)
i, e1 := strconv.ParseUint(l.token[8:10], 16, 8)
if e1 != nil {
return &ParseError{"", "bad ZONEMD Scheme", l}
}
rr.Scheme = uint8(i)
i, err := strconv.ParseUint(l.token[10:12], 16, 8)
if err != nil {
return &ParseError{"", "bad ZONEMD Hash Algorithm", l}
}
rr.Hash = uint8(i)
rr.Digest = l.token[12:]
return nil
}
i, e := strconv.ParseUint(l.token, 10, 32)
if e != nil || l.err {
return &ParseError{"", "bad ZONEMD Serial", l}
Expand Down

0 comments on commit 678d105

Please sign in to comment.