Reverse Engineering RET Homepage RET Members Reverse Engineering Projects Reverse Engineering Papers Reversing Challenges Reverser Tools RET Re-Search Engine Reverse Engineering Forum Reverse Engineering Links

Go Back   Reverse Engineering Team Board > Reverse Engineering Board > General Forum
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2008, 03:27 PM
rack rack is offline
Member
 
Join Date: Apr 2008
Posts: 6
Default Strange CRC.

Hi,

I try to identify a serial protocol for some devices.

The transmitted strings are in this form (example):

0180007A0405

the last 2 digit are the checksum modulo 256 (100h) of the previous digits as ascii characters (hex):

0=30+
1=31+
8=38+
0=30+
0=30+
0=30+
7=37+
A=41+
0=30+
4=34

summ = 205

CRC= 205 mod 100 = 05

the bytes 7A and 04 are another checksum (BCC) for the digits before those bytes (01 80 00).

This is the only description I've found about this check:

-----
Each message contains a Block Check Sum word BCC, composed by two
bytes ordered as BCC1 & BCC2 which are calculated, using one's complement arithmetic (a carry
resulting from a two byte sum is added to the result), with the following procedure:

- Initialize S1(0)=0 and S2(0)=0

- Perform partial calculation using all message's N bytes B(n) starting form first byte B(1)

S1(n) = S1(n-1) + B(n)
S2(n) = S2(n-1) + S1(n)

- Calculate checksum bytes as

BCC1 = - (S1(N) + S2(N))
BCC2 = S2(N)
-----

I've followed the above steps but the results are always wrong...

Any suggestions, please ?

Thanks in advance.
Reply With Quote
  #2  
Old 08-09-2008, 10:46 AM
kao kao is offline
Senior Member
 
Join Date: Sep 2007
Posts: 184
Default

See Wikipedia for one's complement (http://en.wikipedia.org/wiki/Signed_....27_complement)

Here's how it gets calculated:
Code:
index  | 00 | 01 | 02 | 03
--------------------------
b(x)   | .. | 01 | 80 | 00
s1(x)  | 00 | 01 | 81 | 81
s2(x)  | 00 | 01 | 82 | 04 (*1)

bcc1  = ~(81+4) = ~85 = 7A (*2)
bcc2  = 04
Notes.
*1) 0x81 + 0x82 = 0x103 = 4 ("a carry resulting from a two byte sum is added to the result")
*2) one's complement to 85 is 7A. Its not the same as minus sign in ordinary arithmetics.

Have a nice day,
kao.
Reply With Quote
  #3  
Old 08-09-2008, 02:55 PM
rack rack is offline
Member
 
Join Date: Apr 2008
Posts: 6
Default

Thank you very much kao!!!

My mistake was think at the "BCC" as the "CRC" (last byte) and operate with the ascii values (30,31,38,30,...) instead the simple bytes.

Regards.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump





Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.