1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3
4 /**
5 @file ocb3_int_ntz.c
6 OCB implementation, INTERNAL ONLY helper, by Tom St Denis
7 */
8 #include "tomcrypt_private.h"
9
10 #ifdef LTC_OCB3_MODE
11
12 /**
13 Returns the number of leading zero bits [from lsb up] (internal function)
14 @param x The 32-bit value to observe
15 @return The number of bits [from the lsb up] that are zero
16 */
ocb3_int_ntz(unsigned long x)17 int ocb3_int_ntz(unsigned long x)
18 {
19 int c;
20 x &= 0xFFFFFFFFUL;
21 c = 0;
22 while ((x & 1) == 0) {
23 ++c;
24 x >>= 1;
25 }
26 return c;
27 }
28
29 #endif
30