Search code examples
perldns

Random characters in DS record from Net::DNS:RR when calling print/string


The Net::DNS version is 1.22.


I'm playing around with Net::DNS::RR and I am a bit confused about some random characters appearing in the output of DS records when I call Net::DNS::RR->string(or Net::DNS::RR->print). The output for Net::DNS::RR->plain is what I expected.

#!/usr/bin/perl

use strict;
use warnings; 

use Net::DNS; 

my @rr = rr("gov.uk", "DS");
print STDERR $_->plain . "\n" foreach (@rr);
print STDERR $_->string . "\n" foreach (@rr);

The output is as follows:

gov.uk. 300 IN DS 17539 8 2 2f0a0a65db9e930f5b2c0425f67df66416c076124652a281d9a8ffa773828f57
gov.uk. 300 IN DS 695 8 2 7277592dbd8993bde70704dbabd30afdbb85057e658ef1428f18f5d9a534bce0
gov.uk. 300     IN      DS      ( 17539 8 2
        2f0a0a65db9e930f5b2c0425f67df66416c076124652a281d9a8ffa773828f57 )
        ; xerob-pidyk-hukan-vagab-zokod-seced-hetal-tutok-gohys-bityc-ducih-demom-cekup-mazip-lasem-difoh-lixex
gov.uk. 300     IN      DS      ( 695 8 2
        7277592dbd8993bde70704dbabd30afdbb85057e658ef1428f18f5d9a534bce0 )
        ; xisil-lykud-tazum-nagar-tynib-licot-repat-fydoz-tivam-hicul-vunim-vosag-dofic-metyt-nunuf-gezev-byxex

As one can see, the plain response is as expected, meanwhile the string output has a bunch of seemingly random characters after the record (xerob-pidyk-huk...).

Can anyone shed light on what's happening here?


Solution

  • You get those comments if Digest::BubbleBabble is installed.

    It's an alternate representation of the digest in the record.

    hex_to_babble:

    #!/usr/bin/perl
    use v5.36;
    use Digest::BubbleBabble qw( bubblebabble );
    die( "usage" ) if @ARGV != 1 || $ARGV[0] !~ /^(?:[0-9a-fA-F]{2})*\z/;
    say bubblebabble( Digest => pack( "H*", $ARGV[0] ) );
    
    $ hex_to_babble 2f0a0a65db9e930f5b2c0425f67df66416c076124652a281d9a8ffa773828f57
    xerob-pidyk-hukan-vagab-zokod-seced-hetal-tutok-gohys-bityc-ducih-demom-cekup-mazip-lasem-difoh-lixex
    
    $ hex_to_babble 7277592dbd8993bde70704dbabd30afdbb85057e658ef1428f18f5d9a534bce0
    xisil-lykud-tazum-nagar-tynib-licot-repat-fydoz-tivam-hicul-vunim-vosag-dofic-metyt-nunuf-gezev-byxex
    

    The point is to make it easier for humans to transcribe the digest or compare two digests.