intel / cryptography-primitives

Intel® Cryptography Primitives Library is a secure, fast and lightweight library of building blocks for cryptography, highly-optimized for various Intel® CPUs
Apache License 2.0
327 stars 86 forks source link

Undefined behavior issue in cpGetBitSize() #55

Closed xhuan28 closed 1 year ago

xhuan28 commented 1 year ago

In pcpmont_set.c ,

__INLINE int cpGetBitSize(Ipp32u offset, Ipp32u val)  
{  
    int bitSize = 32;  
    if (val == 0) return 0;  
    while ((val & (1 << bitSize)) == 0) bitSize--;  
    return (int)offset + bitSize;  
}

1 << 32 may lead to an undefined behavior issue.

xhuan28 commented 1 year ago

https://github.com/intel/ipp-crypto/pull/56 may fix this issue.