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