From: Andreas Oberritter <obi@linuxtv.org>
To: linux-media@vger.kernel.org
Cc: LinuxTv <linux-dvb@linuxtv.org>
Subject: Re: [linux-dvb] @Sky Pilot, Neotion Pilot, Checksum hacking
Date: Mon, 22 Jun 2009 07:13:49 +0200 [thread overview]
Message-ID: <4A3F130D.1020909@linuxtv.org> (raw)
In-Reply-To: <200906212002.55867.JuergenUrban@gmx.de>
Juergen Urban wrote:
> Now I've a problem with the 1-byte-checksum calculation. Each message
> which I send to the device has a checksum (last byte). I don't know how to
> calculate the checksum.
> Did someone know how to reverse engineer a 1-byte-checksum?
> Did someone see these type of messages before?
> Did someone detect any algorithm in the checksum values?
>
> Here are examples:
>
> static unsigned char ep03_msg109[] = {
> 0x81, 0x05, 0x01, 0x00, 0x02, 0x01, 0x06, 0x00,
> 0x01, 0xd0, 0x1e, 0x01, 0x00,
> 0xca /* Checksum */
> };
>
> static unsigned char ep03_msg110[] = {
> 0x81, 0x05, 0x01, 0x00, 0x02, 0x01, 0x06, 0x00,
> 0x01, 0xd0, 0x1f, 0x01, 0x00,
> 0xcb /* Checksum */
> };
>
> In the above example the checksum is incremented by one and there is also one
> byte incremented by one in the payload (0x1e -> 0x1f and 0xca -> 0xcb). this
> seems to be a simple addition.
>
> static unsigned char ep03_msg111[] = {
> 0x81, 0x05, 0x01, 0x00, 0x02, 0x01, 0x06, 0x00,
> 0x01, 0xd0, 0x20, 0x01, 0x00,
> 0xf4 /* Checksum */
> };
It's a simple XOR of all bytes with an initial value of 0x84.
unsigned int calc_cs(const unsigned char *buf, unsigned int n)
{
unsigned int i, cs = 0x84;
for (i = 0; i < n; i++)
cs ^= buf[i];
return cs;
}
Regards,
Andreas
next prev parent reply other threads:[~2009-06-22 5:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-21 18:02 [linux-dvb] @Sky Pilot, Neotion Pilot, Checksum hacking Juergen Urban
2009-06-22 5:13 ` Andreas Oberritter [this message]
2009-06-22 21:58 ` Juergen Urban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A3F130D.1020909@linuxtv.org \
--to=obi@linuxtv.org \
--cc=linux-dvb@linuxtv.org \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox