sha256 is broken on MSP430
The test_sha256 on MSB-430h produces
2013-12-19 18:21:24,843 - INFO # Input: 1234567890_1
2013-12-19 18:21:24,856 - INFO # Expected: 3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0
2013-12-19 18:21:24,922 - INFO # Calculated: 738bffcd338e46a144daea84 f 37e9b204cfefd10e616ea498ed3da811e20b6
2013-12-19 18:21:24,923 - INFO #
2013-12-19 18:21:25,009 - INFO # Input: 1234567890_2
2013-12-19 18:21:25,022 - INFO # Expected: a144d0b4d285260ebbbab6840baceaa09eab3e157443c9458de764b7262c8ace
2013-12-19 18:21:25,088 - INFO # Calculated: 17 4135483c354e73a8b98f68d12535b798f 7d0789f2fc6da978c 5 c6bae4c
2013-12-19 18:21:25,088 - INFO #
2013-12-19 18:21:25,175 - INFO # Input: 1234567890_3
2013-12-19 18:21:25,187 - INFO # Expected: 9f839169d293276d1b799707d2171ac1fd5b78d0f3bc7693dbed831524dd2d77
2013-12-19 18:21:25,255 - INFO # Calculated: 2182ca92f0e0581a81f183bb8aa215d7dffc3f 1909967cf824dbe686196397d
2013-12-19 18:21:25,255 - INFO #
2013-12-19 18:21:25,342 - INFO # Input: 1234567890_4
2013-12-19 18:21:25,355 - INFO # Expected: 6c5fe2a8e3de58a5e5ac061031a8e802ae1fb9e7197862ec1aedf236f0e23475
2013-12-19 18:21:25,421 - INFO # Calculated: b0d0 b5e28cb4a4d1eb767c96e1313d4938ad9b961ccb77ae0e2c437f3553c86
2013-12-19 18:21:25,422 - INFO #
2013-12-19 18:21:25,595 - INFO # Input: 0123456789abcde-0123456789abcde-0123456789abcde-0123456789abcde-
2013-12-19 18:21:25,607 - INFO # Expected: 945ab9d52b069923680c2c067fa6092cbbd9234cf7a38628f3033b2d54d3d3bf
2013-12-19 18:21:25,675 - INFO # Calculated: fb64f72c3ac095fc d3f23bf2995feafe5495da61ff1b8857fece07cb6df63f3
2013-12-19 18:21:25,676 - INFO #
2013-12-19 18:21:25,848 - INFO # Input: Franz jagt im komplett verwahrlosten Taxi quer durch Bayern
2013-12-19 18:21:25,860 - INFO # Expected: d32b568cd1b96d459e7291ebf4b25d007f275c9f13149beeb782fac0716613f8
2013-12-19 18:21:25,928 - INFO # Calculated: 18a5c664dd6df61f36efeb7af669d317628ab43f9e711a1aba4f1b47f52d6171
2013-12-19 18:21:25,928 - INFO #
2013-12-19 18:21:26,101 - INFO # Input: Frank jagt im komplett verwahrlosten Taxi quer durch Bayern
2013-12-19 18:21:26,114 - INFO # Expected: 78206a866dbb2bf017d8e34274aed01a8ce405b69d45db30bafa00f5eeed7d5e
2013-12-19 18:21:26,181 - INFO # Calculated: 53764f7f1fdd 4dae0b8ebea9bedbcbead176c542e7b3e7235e0ad5d58c59865
2013-12-19 18:21:26,182 - INFO #
2013-12-19 18:21:26,266 - INFO # Input:
2013-12-19 18:21:26,279 - INFO # Expected: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
2013-12-19 18:21:26,347 - INFO # Calculated: 39c95d37f9b44b36d047fdfb5a217c671a7d8dd4424786926a414a821f4ca6bc
I think this will not get fixed for this release
I think this will not get fixed for this release
I expected this but tagged it for the release so we can put is a known issue into the release notes.
I can find no reason for it in https://github.com/RIOT-OS/RIOT/blob/master/tests/test_sha256/main.c and https://github.com/RIOT-OS/RIOT/blob/master/sys/crypto/sha256/sha256.c
so I have no idea why this code is a problem on 16 bit. @Kijewski do you have an idea?
Please test https://github.com/Kijewski/RIOT/commit/9f73fa626ed387f5be5863f2129bb39bbd7dc668.
@OlegHahm or @LudwigOrtmann you have the hardware to say that this works as expected on msb430
~~ACK~~
NACK
2014-02-12 14:31:14,507 - INFO # RIOT MSP430 hardware initialization complete.
2014-02-12 14:31:14,508 - INFO #
2014-02-12 14:31:14,508 - INFO # kernel_init(): This is RIOT! (Version: 2013.08-1197-g4016-sha)
2014-02-12 14:31:14,509 - INFO # Scheduler...[OK]
2014-02-12 14:31:14,509 - INFO # kernel_init(): jumping into first task...
2014-02-12 14:31:14,510 - INFO # Input: 1234567890_1
2014-02-12 14:31:14,511 - INFO # Expected: 3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0
2014-02-12 14:31:14,512 - INFO # Calculated:568cd1b96d459e7291ebf4b25d007f275c9f13149beeb782fac0716613f8
2014-02-12 14:31:14,526 - INFO # Calculated: 25a08ab54ec1c5fdc134be916afbaf126c91abb82832b57f 03692c261bbb26a
2014-02-12 14:31:14,526 - INFO #
2014-02-12 14:31:14,552 - INFO # Input: Frank jagt im komplett verwahrlosten Taxi quer durch Bayern
2014-02-12 14:31:14,560 - INFO # Expected: 78206a866dbb2bf017d8e34274aed01a8ce405b69d45db30bafa00f5eeed7d5e
2014-02-12 14:31:14,574 - INFO # Calculated: 20a3949a4593a7a1571245994916 b3cdf86b968989ee3643afbe475747a70cf
2014-02-12 14:31:14,574 - INFO #
2014-02-12 14:31:14,585 - INFO # Input:
2014-02-12 14:31:14,598 - INFO # Expected: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
2014-02-12 14:31:14,607 - INFO # Calculated: 1151d786335ae730362828bd38e2afa281f0de8c1f309b86496d9b27831675f4
2014-02-12 14:31:14,607 - INFO #
I'm not sure this is due to some integer type problem ... The msp has severe issues at the moment ;-)
Is there really a space in the output? o_O
This is what it looks like after turning it off and on again.
2014-02-12 14:33:38,489 - INFO # RIOT MSP430 hardware initialization complete.
2014-02-12 14:33:38,490 - INFO #
2014-02-12 14:33:38,496 - INFO # kernel_init(): This is RIOT! (Version: 2013.08-1197-g4016-sha)
2014-02-12 14:33:38,498 - INFO # Scheduler...[OK]
2014-02-12 14:33:38,502 - INFO # kernel_init(): jumping into first task...
2014-02-12 14:33:38,516 - INFO # Input: 1234567890_1
2014-02-12 14:33:38,523 - INFO # Expected: 3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0
2014-02-12 14:33:38,536 - INFO # Calculated: d8815d9434bda7afb2292b 84c4b61a57d49b1fc319451f867e9699264d2ad25
2014-02-12 14:33:38,537 - INFO #
2014-02-12 14:33:38,549 - INFO # Input: 1234567890_2
2014-02-12 14:33:38,557 - INFO # Expected: a144d0b4d285260ebbbab6840baceaa09eab3e157443c9458de764b7262c8ace
2014-02-12 14:33:38,570 - INFO # Calculated: aaafaa97b7f359def55ae996cceff0659b6645e1bd f87fcf5 2a8dff6c133 3
2014-02-12 14:33:38,571 - INFO #
2014-02-12 14:33:38,583 - INFO # Input: 1234567890_3
2014-02-12 14:33:38,591 - INFO # Expected: 9f839169d293276d1b799707d2171ac1fd5b78d0f3bc7693dbed831524dd2d77
2014-02-12 14:33:38,604 - INFO # Calculated: 8c45c2df655cfef830f0e68b31bb28 a1d4e6682b87cb7908b9e9f54b9b5ce9c
2014-02-12 14:33:38,605 - INFO #
2014-02-12 14:33:38,617 - INFO # Input: 1234567890_4
2014-02-12 14:33:38,625 - INFO # Expected: 6c5fe2a8e3de58a5e5ac061031a8e802ae1fb9e7197862ec1aedf236f0e23475
2014-02-12 14:33:38,638 - INFO # Calculated: fb3426 e414cf13b371045d7eebe553c5d6df1424919a25343 03c 0d468d911
2014-02-12 14:33:38,638 - INFO #
2014-02-12 14:33:38,665 - INFO # Input: 0123456789abcde-0123456789abcde-0123456789abcde-0123456789abcde-
2014-02-12 14:33:38,673 - INFO # Expected: 945ab9d52b069923680c2c067fa6092cbbd9234cf7a38628f3033b2d54d3d3bf
2014-02-12 14:33:38,687 - INFO # Calculated: 27 441f5 f434750377daf98 81e41981218b979c1a8d5346852a7 5f128 cd3
2014-02-12 14:33:38,687 - INFO #
2014-02-12 14:33:38,713 - INFO # Input: Franz jagt im komplett verwahrlosten Taxi quer durch Bayern
2014-02-12 14:33:38,721 - INFO # Expected: d32b568cd1b96d459e7291ebf4b25d007f275c9f13149beeb782fac0716613f8
2014-02-12 14:33:38,734 - INFO # Calculated: 25a08ab54ec1c5fdc134be916afbaf126c91abb82832b57f 03692c261bbb26a
2014-02-12 14:33:38,734 - INFO #
2014-02-12 14:33:38,760 - INFO # Input: Frank jagt im komplett verwahrlosten Taxi quer durch Bayern
2014-02-12 14:33:38,768 - INFO # Expected: 78206a866dbb2bf017d8e34274aed01a8ce405b69d45db30bafa00f5eeed7d5e
2014-02-12 14:33:38,782 - INFO # Calculated: 20a3949a4593a7a1571245994916 b3cdf86b968989ee3643afbe475747a70cf
2014-02-12 14:33:38,782 - INFO #
2014-02-12 14:33:38,793 - INFO # Input:
2014-02-12 14:33:38,801 - INFO # Expected: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
2014-02-12 14:33:38,815 - INFO # Calculated: 1151d786335ae730362828bd38e2afa281f0de8c1f309b86496d9b27831675f4
2014-02-12 14:33:38,815 - INFO #
At least this can be consistent over reboots:
2014-02-12 14:37:01,606 - INFO # RIOT MSP430 hardware initialization complete.
2014-02-12 14:37:01,607 - INFO #
2014-02-12 14:37:01,612 - INFO # kernel_init(): This is RIOT! (Version: 2013.08-1197-g4016-sha)
2014-02-12 14:37:01,614 - INFO # Scheduler...[OK]
2014-02-12 14:37:01,619 - INFO # kernel_init(): jumping into first task...
2014-02-12 14:37:01,631 - INFO # Input: 1234567890_1
2014-02-12 14:37:01,639 - INFO # Expected: 3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0
2014-02-12 14:37:01,658 - INFO # Calculated: d8815d9434bda7afb2292b 84c4b61a57d49b1fc319451f867e9699264d2ad25
2014-02-12 14:37:01,658 - INFO #
2014-02-12 14:37:01,665 - INFO # Input: 1234567890_2
2014-02-12 14:37:01,673 - INFO # Expected: a144d0b4d285260ebbbab6840baceaa09eab3e157443c9458de764b7262c8ace
2014-02-12 14:37:01,687 - INFO # Calculated: aaafaa97b7f359def55ae996cceff0659b6645e1bd f87fcf5 2a8dff6c133 3
2014-02-12 14:37:01,687 - INFO #
2014-02-12 14:37:01,699 - INFO # Input: 1234567890_3
2014-02-12 14:37:01,707 - INFO # Expected: 9f839169d293276d1b799707d2171ac1fd5b78d0f3bc7693dbed831524dd2d77
2014-02-12 14:37:01,721 - INFO # Calculated: 8c45c2df655cfef830f0e68b31bb28 a1d4e6682b87cb7908b9e9f54b9b5ce9c
2014-02-12 14:37:01,721 - INFO #
2014-02-12 14:37:01,733 - INFO # Input: 1234567890_4
2014-02-12 14:37:01,741 - INFO # Expected: 6c5fe2a8e3de58a5e5ac061031a8e802ae1fb9e7197862ec1aedf236f0e23475
2014-02-12 14:37:01,755 - INFO # Calculated: fb3426 e414cf13b371045d7eebe553c5d6df1424919a25343 03c 0d468d911
2014-02-12 14:37:01,755 - INFO #
2014-02-12 14:37:01,782 - INFO # Input: 0123456789abcde-0123456789abcde-0123456789abcde-0123456789abcde-
2014-02-12 14:37:01,790 - INFO # Expected: 945ab9d52b069923680c2c067fa6092cbbd9234cf7a38628f3033b2d54d3d3bf
2014-02-12 14:37:01,803 - INFO # Calculated: 27 441f5 f434750377daf98 81e41981218b979c1a8d5346852a7 5f128 cd3
2014-02-12 14:37:01,804 - INFO #
2014-02-12 14:37:01,829 - INFO # Input: Franz jagt im komplett verwahrlosten Taxi quer durch Bayern
2014-02-12 14:37:01,837 - INFO # Expected: d32b568cd1b96d459e7291ebf4b25d007f275c9f13149beeb782fac0716613f8
2014-02-12 14:37:01,851 - INFO # Calculated: 25a08ab54ec1c5fdc134be916afbaf126c91abb82832b57f 03692c261bbb26a
2014-02-12 14:37:01,851 - INFO #
2014-02-12 14:37:01,877 - INFO # Input: Frank jagt im komplett verwahrlosten Taxi quer durch Bayern
2014-02-12 14:37:01,885 - INFO # Expected: 78206a866dbb2bf017d8e34274aed01a8ce405b69d45db30bafa00f5eeed7d5e
2014-02-12 14:37:01,899 - INFO # Calculated: 20a3949a4593a7a1571245994916 b3cdf86b968989ee3643afbe475747a70cf
2014-02-12 14:37:01,899 - INFO #
2014-02-12 14:37:01,910 - INFO # Input:
2014-02-12 14:37:01,918 - INFO # Expected: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
2014-02-12 14:37:01,932 - INFO # Calculated: 1151d786335ae730362828bd38e2afa281f0de8c1f309b86496d9b27831675f4
2014-02-12 14:37:01,932 - INFO #
There are several spaces in the output.
Maybe if you rewrote the test to compare the output instead of printing it ... that would eliminate one possible problem source.
~~Ah, I now see: The printf in MSP430 does not understand %02x. It left pads with spaces.~~
Is there some branch or do we have to cherry-pick this every time?
~~The branch is sha256-impl. But you just showed that it doesn't work, either. :)~~
If I believe the SHA-256 algorithm description here (http://en.wikipedia.org/wiki/SHA-2#Pseudocode), there is a padding step to be done on the message during initialization.
@Rene, I can't see where it is done in your implementation in branch 'sha256-impl'... Is that normal?
@Christian, in the "standard" implementation, the padding is done in function sha256_pad(), but I don't think it is called in any way by the test_sha256/main.c file... Isn't it the cause of the problems?
According to the simulation of https://github.com/mspsim/mspsim the current implementation works on the telosb board, which features the same CPU as MSB-430.
I guess the board code is to blame, not the implementation.
Working on msb-430 now.