1 // SPDX-License-Identifier: BSD-2-Clause
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 *
4 * LibTomCrypt is a library that provides various cryptographic
5 * algorithms in a highly modular and flexible manner.
6 *
7 * The library is free for all purposes without any express
8 * guarantee it works.
9 */
10
11 /**
12 @file ocb3_int_ntz.c
13 OCB implementation, INTERNAL ONLY helper, by Tom St Denis
14 */
15 #include "tomcrypt_private.h"
16
17 #ifdef LTC_OCB3_MODE
18
19 /**
20 Returns the number of leading zero bits [from lsb up] (internal function)
21 @param x The 32-bit value to observe
22 @return The number of bits [from the lsb up] that are zero
23 */
ocb3_int_ntz(unsigned long x)24 int ocb3_int_ntz(unsigned long x)
25 {
26 int c;
27 x &= 0xFFFFFFFFUL;
28 c = 0;
29 while ((x & 1) == 0) {
30 ++c;
31 x >>= 1;
32 }
33 return c;
34 }
35
36 #endif
37
38 /* ref: $Format:%D$ */
39 /* git commit: $Format:%H$ */
40 /* commit time: $Format:%ai$ */
41