crypto/tinycrypt: fix undefined behavior in CTR mode counter assembly
Cast nonce bytes to uint32_t before left shift to avoid signed integer overflow when byte value >= 128. This fixes UBSan runtime error: “left shift of N by 24 places cannot be represented in type ‘int’”.
Signed-off-by: makejian makejian@xiaomi.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
================================================================================
================================================================================
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
Overview:
The TinyCrypt Library provides an implementation for constrained devices of a minimal set of standard cryptography primitives.
Please, SEE THE DOCUMENTATION folder for more information on the supported cryptographic primitives and the limitations of TinyCrypt library. For usage, security and technicalities, please see the corresponding header file of each cryptographic primitive.
================================================================================
Organization:
/lib: C source code of the cryptographic primitives. /lib/include/tinycrypt: C header files of the cryptographic primitives. /tests: Test vectors of the cryptographic primitives. /doc: Documentation of TinyCrypt.
================================================================================
Building:
================================================================================