lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87lh9y1520.fsf@kamboji.qca.qualcomm.com>
Date:	Mon, 16 Nov 2015 14:50:47 +0200
From:	Kalle Valo <kvalo@....qualcomm.com>
To:	<linux-kernel@...r.kernel.org>
CC:	<ath10k@...ts.infradead.org>, <linux-wireless@...r.kernel.org>
Subject: Matching crc32 checksums from kernel and user space

Hi,

I want ath10k to print a checksum for the firmware image and include
that to the firmware crash dump file as well. Then I want to print the
same checksum from user space scripts and verify it with the crash dump
file.

I thought that crc32 would be good enough for me but it wasn't that
simple as I can't seem to getting matching checksums, at least not with
the user space tools I found. For a test case I created a simple file:

$ xxd /lib/firmware/ath10k/crc-test.bin 
00000000: 3132 3334 3536 3738 3930 0a              1234567890.

In kernel I get these checksums:

[  574.867724] crc32_le(0) 8916bc26
[  574.867739] crc32_le(~0) 1d6ef235
[  574.867743] crc32_be(0) b9346a4c
[  574.867746] crc32_be(~0) 71467465

And from python I got (value in parenthesis is the seed I used):

binascii.crc32(00000000) 0xe2910dcaL
binascii.crc32(ffffffff) 0x76e943d9L
binascii.crc32(edb88320) 0x8256622aL
binascii.crc32(82f63b78) 0xc291ff04L
binascii.crc32(04c11db7) 0x6d877563L
binascii.crc32(104c11db7) 0x6d877563L
binascii.crc32(edb88320) 0x8256622aL
binascii.crc32(82608edb) 0x7b5e5884L

Or with crc32 tool from libarchive-zip-perl:

$ crc32 /lib/firmware/ath10k/crc-test.bin 
e2910dca

So libarchive-zip-perl and python match, but the kernel checksums are
totally different.

I tried md5 the same file and I get the matching id
7c12772809c1c0c3deda6103b10fdfa0 both with md5sum tool in user space and
crypto_shash_update() in kernel. But md5sum is really overkill for me. I
just want to verify that the firmware image is not corrupted or
otherwise broken, the checksum does not need to be secure in any way.
And preferably the checksum would be short enough to make it easy to
print in logs etc.

Any ideas how to match kernel crc32 implementation with user space? Or
am I doing something wrong?

Here's the kernel code I used for testing:

  printk("crc32_le(0) %08x\n", crc32_le(0, fw->data, fw->size));
  printk("crc32_le(~0) %08x\n", crc32_le(~0, fw->data, fw->size));
  printk("crc32_be(0) %08x\n", crc32_be(0, fw->data, fw->size));
  printk("crc32_be(~0) %08x\n", crc32_be(~0, fw->data, fw->size));

-- 
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ