MSU-CS4360-JDNS / JDNSS

A leaf DNS server in Java
1 stars 1 forks source link

RRSIG expiration and inception values are being parsed incorrectly #51

Closed cblanto7 closed 6 years ago

cblanto7 commented 6 years ago

Consider the following example:

86400   A   192.168.1.2
            86400   RRSIG   A 10 2 86400 (
                    20180515033855 20180415033855 12023 test.com.
                    gbVzG+2kkalBT3mZIvwRQronDhe2kRNb1ywA
                    YrDdX+jzX2adhJpwhwIWJcYb1wKWjV24ID9Q
                    /mnAxDkkqnDDeMAwy4/Wb5naOFo4i/kaAB6o
                    IJvZ+a+JghMQ7XF2u9FjjS9VbAGXQMQug5l4
                    0wnjAdvzHDB91jY5kiYYtqjiXYH+WkjaIjL4
                    xe72WhNbpYYQcPa8BfRuN2Lo2Gyh3COopXTA
                    j9VvWOMPNsJM+hN9G+te3d0UsO0egihpjok1
                    KjDhRr/C0cwUF5K/n+35riuzQ6E4+5UAzN/G
                    MrJV/AJC4WoNdAVtN1ImOppuNbmAAvYKycHj
                    Z+HW6C5o/aqUWnDrAQ== )

expiration should be 20180515033855 inception should be 20180415033855

when parsed they are being read as int values expiration: -917701531 inception: -917701530

the RRSIG object gets created and when getBytes() is called the values are coming back as expiration: 20770107173251 inception: 20770107173256

I believe this could have something to do with int being a signed value in Java, but I am not sure.

according to the RFC 4034 The Signature Expiration and Inception field values specify a date and time in the form of a 32-bit unsigned number of seconds elapsed since 1 January 1970 00:00:00 UTC, ignoring leap seconds, in network byte order.