crc // wrong poly for crc_xmodem_type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

crc // wrong poly for crc_xmodem_type

Boost - Dev mailing list
Hello All,

I've discovered that current typedef crc_xmodem_type uses wrong poly.

Current release and master branch:
>  typedef crc_optimal<16, 0x8408, 0, 0, true, true>         crc_xmodem_type;

Should be (ref:
http://reveng.sourceforge.net/crc-catalogue/16.htm#crc.cat-bits.16)
> typedef crc_optimal<16, 0x1021, 0, 0, false, false>

Develop branch already have some changes which address this error (for
ex. https://github.com/boostorg/crc/commit/328bf50f666c463901e2179aa2d890916c3b66ed),
but master and boost release does not.

Who currently owns boost::crc and can fix this issue?

Thank you.

--
Best Regards,
Sergei Nikulov

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: crc // wrong poly for crc_xmodem_type

Boost - Dev mailing list
Hi Sergei.

> I've discovered that current typedef crc_xmodem_type uses wrong poly.

I'm not an expert in CRCs and I have no idea whether Boost's implementation is
wrong, but it's interesting that:

    bin(0x8408) = reverse(bin(0x1021))

Maybe this isn't a real problem, but simply someone decided to intentionally
flip the poly in the CRC implementation, and the computation still leads to
correct results?

——— Pavel K.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: crc // wrong poly for crc_xmodem_type

Boost - Dev mailing list
Hi Pavel,

2017-05-15 19:40 GMT+03:00 Pavel Kretov <[hidden email]>:

> Hi Sergei.
>
>> I've discovered that current typedef crc_xmodem_type uses wrong poly.
>
> I'm not an expert in CRCs and I have no idea whether Boost's implementation is
> wrong, but it's interesting that:
>
>     bin(0x8408) = reverse(bin(0x1021))
>
> Maybe this isn't a real problem, but simply someone decided to intentionally
> flip the poly in the CRC implementation, and the computation still leads to
> correct results?
>
> ——— Pavel K.

I believe this is real problem

CRC16 calculator from here
https://www.lammertbies.nl/comm/info/crc-calculation.html

XMODEM for string "123456789" gives 0x31C3

Test case

>>>>>>>>>>>>>> cut here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#define CATCH_CONFIG_MAIN
// This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"

#include <boost/crc.hpp>

TEST_CASE("boost_checksum_crc16", "[checksum]")
{

    std::string xmt{"123456789"};

    boost::crc_xmodem_type bxmt;
    bxmt.process_bytes(xmt.c_str(), xmt.length());
    unsigned xmv = bxmt.checksum();
    CHECK(xmv == 0x31C3);

    boost::crc_optimal<16, 0x1021, 0, 0, false, false> crc_xmt;
    crc_xmt.process_bytes(xmt.c_str(), xmt.length());
    unsigned xmvr = crc_xmt.checksum();
    CHECK(xmvr == 0x31C3);
}
>>>>>>>>>>>>>> cut here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

First one check fails with

../test/test_3.cpp:136: FAILED:
  CHECK( xmv == 0x31C3 )
with expansion:
  3187 (0xc73) == 12739 (0x31c3)

The second one is passed.

--
Best Regards,
Sergei Nikulov

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost