Skip Menu |

This queue is for tickets about the Digest-CRC CPAN distribution.

Report information
The Basics
Id: 72387
Status: resolved
Priority: 0/
Queue: Digest-CRC

People
Owner: OLIMAUL [...] cpan.org
Requestors: dkg [...] fifthhorseman.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: add OpenPGP ASCII armor checksum to Digest::CRC
Date: Sat, 12 Nov 2011 15:04:02 -0500
To: bug-Digest-CRC [...] rt.cpan.org, submit [...] bugs.debian.org
From: Daniel Kahn Gillmor <dkg [...] fifthhorseman.net>
Package: libdigest-crc-perl Version: 0.17-1 Severity: wishlist Tags: patch upstream One common CRC used on the 'net today is the radix-64 armor checksum specified in the OpenPGP standard: https://tools.ietf.org/html/rfc4880#section-6 This is already possible to implement with Digest::CRC using the following object: my $ctx = Digest::CRC->new(width => 24, init=> 0xB704CE, xorout => 0x000000, refout => 0, poly => 0x864CFB, refin => 0, cont => 1); But this is kind of bulky and inconvenient to use. The attached patch enhances Digest::CRC by adding a crcopenpgparmor type, and exporting a function of the same name. It should apply to version 0.17 of Digest::CRC. I'd be happy to have this patch included upstream, and release it under the same terms as the upstream source. Thanks for Digest::CRC, it's very much appreciated. Regards, --dkg
--- lib/Digest/CRC.pm 2011-11-12 14:47:51.000000000 -0500 +++ /usr/lib/perl5/Digest/CRC.pm 2011-11-12 14:32:31.000000000 -0500 @@ -8,11 +8,12 @@ @ISA = qw(Exporter); @EXPORT_OK = qw( - crc8 crcccitt crc16 crc32 crc64 crc + crc8 crcccitt crc16 crcopenpgparmor crc32 crc64 crc crc_hex crc_base64 crcccitt_hex crcccitt_base64 crc8_hex crc8_base64 crc16_hex crc16_base64 + crcopenpgparmor_hex crcopenpgparmor_base64 crc32_hex crc32_base64 crc64_hex crc64_base64 ); @@ -126,6 +127,7 @@ crc8 => [8,0,0,0,0x07,0,0], crcccitt => [16,0xffff,0,0,0x1021,0,0], crc16 => [16,0,0,1,0x8005,1,0], + crcopenpgparmor => [24,0xB704CE,0,0,0x864CFB,0,0], crc32 => [32,0xffffffff,0xffffffff,1,0x04C11DB7,1,0], ); @@ -273,6 +275,12 @@ sub crc16 { crc($_[0],@{$_typedef{crc16}}) } +# CRC-24 for OpenPGP ASCII Armor checksum +# https://tools.ietf.org/html/rfc4880#section-6 +# poly: 0x864CFB, width: 24, init: 0xB704CE, refin: no, refout: no, xorout: no + +sub crcopenpgparmor { crc($_[0],@{$_typedef{crcopenpgparmor}}) } + # CRC32 # poly: 04C11DB7, width: 32, init: FFFFFFFF, revin: yes, revout: yes, # xorout: FFFFFFFF @@ -301,6 +309,10 @@ sub crc16_base64 { _encode_base64 &crc16 } +sub crcopenpgparmor_hex { _encode_hex &crcopenpgparmor } + +sub crcopenpgparmor_base64 { _encode_base64 &crcopenpgparmor } + sub crc32_hex { _encode_hex &crc32 } sub crc32_base64 { _encode_base64 &crc32 } @@ -320,12 +332,13 @@ # Functional style - use Digest::CRC qw(crc64 crc32 crc16 crcccitt crc crc8); + use Digest::CRC qw(crc64 crc32 crc16 crcccitt crc crc8 crcopenpgparmor); $crc = crc64("123456789"); $crc = crc32("123456789"); $crc = crc16("123456789"); $crc = crcccitt("123456789"); $crc = crc8("123456789"); + $crc = crcopenpgparmor("123456789"); $crc = crc($input,$width,$init,$xorout,$refout,$poly,$refin,$cont); @@ -348,7 +361,12 @@ The B<Digest::CRC> module calculates CRC sums of all sorts. It contains wrapper functions with the correct parameters for CRC-CCITT, -CRC-16, CRC-32 and CRC-64. +CRC-16, CRC-32 and CRC-64, as well as the CRC used in OpenPGP's +ASCII-armored checksum. + +=head1 SEE ALSO + +https://tools.ietf.org/html/rfc4880#section-6 =head1 AUTHOR
Download (untitled)
application/pgp-signature 965b

Message body not shown because it is not plain text.

Hi, thanks for the patch. It is part of version 0.18 which I uploaded a few minutes ago. Oliver