randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.55k stars 561 forks source link

roughtime tests failing on big endian arches #2137

Closed sharkcz closed 4 years ago

sharkcz commented 4 years ago

After the last batch of updates from Oct 6-7 our CI builds started to fail on ppc64 and s390x arches in the roughtime tests, which has been just added. Both are big endian platforms, so I suspect an endianness issue has been introduced.

...
rfc3394:
RFC3394 keywrap ran 12 tests in 0.07 msec all ok
rfc6979:
RFC 6979 nonce generation ran 8 tests in 0.17 msec all ok
roughtime:
roughtime ran 1 tests 1 FAILED
Failure 1: Roughtime Tag end index out of bounds
roughtime_nonce_from_blind:
roughtime nonce_from_blind ran 2 tests in 0.02 msec all ok
roughtime_request:
roughtime request ran 2 tests in 0.01 msec all ok
roughtime_response:
roughtime response ran 17 tests in 0.25 msec 3 FAILED
Failure 1: roughtime response Roughtime Tag end index out of bounds produced unexpected result '0' expected '1'
Failure 2: roughtime response Roughtime Tag end index out of bounds produced unexpected result '0' expected '1'
Failure 3: roughtime response Roughtime Tag end index out of bounds produced unexpected result '0' expected '1'
Note 1: roughtime response Test # 1 Valid  failed [Key=050000004000000040000000A40000003C01000053494700504154485352455043455254494E445889AD80EC2EF7E507FD68E4B88F6DB48020807749BCAE886FE8221D31B5EC070FEB25E401FD746D9C2C995B354FFED67F8FC05B56F4844502F632EAD44FD7140E03000000040000000C000000524144494D494450524F4F5440420F0038596D5D678205008DC2277E99668AF765D3D7372D915B904AD6CEB0BAA4262E194C894C0634936DA2CCD92ADBA30FF286ADF5EBF68A5E7BE43559A6226BD3500DDA16083C11C2A202000000400000005349470044454C45A82675D99316586079BDDF8965030CEA112DAAC1D9EADE089CFB7B7C9ABF7D9F87FFDFBB958FCBAC5BE082FBFC110E8B75E11ECEA3DD6D91348AFADCC045260A0300000020000000280000005055424B4D494E544D41585468B3FAF25B844DE2860ECC833283DEBE12A2852E195758B03AA8E39B5247F35E30DFFF4B5E820500303FD7697282050000000000]
Note 2: roughtime response Test # 2 Valid  failed [Key=050000004000000080000000E40000007C01000053494700504154485352455043455254494E4458357CD0583B97ADFFB7AB5EFD932661366EEFD6AB5B204FAB2CBD9F1CFBE2314FD953CCC66E280307BB30C004A838202EE12BBAC5CA6BE0D179C13441072A8102FD2915F34A58CB40516E2731B2884051482D829F7A996EC3D1BF7367CE40AB8EF28C8BD6A04063F0BE45FBBBF3C79332CCE35E82E783800B6B1E814ECE7C815903000000040000000C000000524144494D494450524F4F5440420F005906C7D778820500FB6AF62DD67A7EFA90E64E26DE4B93FB6A3455DA1C73ABE30CFA6FA0BCAD1E56F4C133BAE1FE959EECFF6F674A8FFC95148E723C8D08510C2394326A3C595D9202000000400000005349470044454C457865CA05DFFED083CF78A50A24A7D00E7AC2AC27449C9A8CFDA496DBE8ACC74C2C7B766449CBD085AE88C40627EAE8D0F9D07EC30F4D8F37ABB17842ABDC380A0300000020000000280000005055424B4D494E544D415854A9600D58ECE49A48410ABB4F20FDA858ADF5BE3CCCFF09B4ED028DC76A5956560000000000000000FFFFFFFFFFFFFFFF01000000]
Note 3: roughtime response Test # 3 Valid  failed [Key=0500000040000000C000000024010000BC01000053494700504154485352455043455254494E44583C6348F53968422316DEF44BAAB1D0C55C695B12FA0DC12955DD41768CAE75171C411AB3F39B9B39A0A5F55739B23DA8C9C8AA13EFAFFA36C53B3A5D4C9EB309709B0F0EA767A0A40ECC06F9AD5D0EE93C4DC95E19A43EF2A92851E3D5CD92EE16FF096C0AC926BBEC6226CF7A15D2C6AB7154D2D4638E17CB01CAE047B9B412B367367A74718F21F1A12318E1EC8FDAAE1D3912F9588EF42A8C2F3F2EF27D45DB472770465181672BB9BC1E306D4767E6EE9D3542C603200127E2D8EBF5C29903000000040000000C000000524144494D494450524F4F5440420F00ABB836DD78820500D85F9F5E8879DD9D5F5130E4F3A8B250FAC244754BA536D2C24D08E59C5CEADA79966B39C10E8678C94529F7790421C4AD490FA43A208D9AEF0BB1DE4252F94202000000400000005349470044454C457865CA05DFFED083CF78A50A24A7D00E7AC2AC27449C9A8CFDA496DBE8ACC74C2C7B766449CBD085AE88C40627EAE8D0F9D07EC30F4D8F37ABB17842ABDC380A0300000020000000280000005055424B4D494E544D415854A9600D58ECE49A48410ABB4F20FDA858ADF5BE3CCCFF09B4ED028DC76A5956560000000000000000FFFFFFFFFFFFFFFF02000000]
rsa_blinding:
RSA blinding ran 450 tests all ok
rsa_decrypt:
RSA/OAEP(SHA-224,MGF1(SHA-256)) decryption ran 6 tests in 293.87 msec all ok
RSA/OAEP(SHA-256,MGF1(SHA-1)) decryption ran 6 tests in 348.24 msec all ok
RSA/OAEP(SHA-256,MGF1(SHA-512)) decryption ran 6 tests in 307.17 msec all ok
RSA/OAEP(SHA-512,MGF1(SHA-1)) decryption ran 6 tests in 307.23 msec all ok
RSA/OAEP(SHA-512,MGF1(SHA-512),TCPA) decryption ran 1 tests in 42.27 msec all ok
rsa_encrypt:
...
randombit commented 4 years ago

Thanks for the report. I've temporarily reverted the merge of Roughtime as there are number of issues in the 2.12.0 release which call for a patch release. But I'll make sure to look at this after Roughtime is merged back into master.

sharkcz commented 4 years ago

Let me know if you need access to a big endian system, I can arrange that.

nunojpg commented 4 years ago

@sharkcz get me access. This should be in some of the places where I used memcpy, but easier to find with a test system.

nunojpg commented 4 years ago

I did a blind attempt to fix it. Could you please give a try on #2143?

sharkcz commented 4 years ago

The PR looks good :-)

roughtime:
roughtime chain ran 14 tests all ok
roughtime nonce ran 4 tests all ok
roughtime server_information ran 14 tests all ok
roughtime_nonce_from_blind:
roughtime nonce_from_blind ran 2 tests in 0.02 msec all ok
roughtime_request:
roughtime request ran 2 tests in 0.01 msec all ok
roughtime_response:
roughtime response ran 23 tests in 4.96 msec all ok

For an account send me your public ssh key to sharkcz at fedoraproject dot org

nunojpg commented 4 years ago

@sharkcz I updated my PR with ready to merge code. I don't anticipate any issues. I ask you to rerun the PR but I don't really need a test machine.

sharkcz commented 4 years ago

Still looking good:

roughtime:
roughtime chain ran 14 tests all ok
roughtime nonce ran 4 tests all ok
roughtime server_information ran 14 tests all ok
roughtime_nonce_from_blind:
roughtime nonce_from_blind ran 2 tests in 0.02 msec all ok
roughtime_request:
roughtime request ran 2 tests in 0.02 msec all ok
roughtime_response:
roughtime response ran 23 tests in 5.02 msec all ok
rsa_blinding:
nunojpg commented 4 years ago

@sharkcz if you have a chance please git it a (last) try. I've made a change to simplify the code and I would sleep better if you tested it.

sharkcz commented 4 years ago

no problem, I run a rebuild and tests and everything is still OK

nunojpg commented 4 years ago

@sharkcz since the code to fix this bug generated a coverity warning I have refactored it slightly. Your human CI would be appreciated for branch roughtime_coverity_warning.

sharkcz commented 4 years ago

@nunojpg, have you removed the branch? Finally I got some time to check it. If it already got merged, then all looks good in our multi-arch CI.

nunojpg commented 4 years ago

@sharkcz yes, it was merged to master now. Thanks.