intbits.c revision 65c4736d9c0ebc6d9b1d991593b55566909da9cd
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews/* Copyright (C) RSA Data Security, Inc. created 1990, 1996. This is an
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington unpublished work protected as such under copyright law. This work
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence contains proprietary, confidential, and trade secret information of
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews RSA Data Security, Inc. Use, disclosure or reproduction without the
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrews express written authorization of RSA Data Security, Inc. is
15a44745412679c30a6d022733925af70a38b715David Lawrence/* Return the number of bits in the canonical, positive integer.
15a44745412679c30a6d022733925af70a38b715David Lawrence IntgerBits (0) = 0.
15a44745412679c30a6d022733925af70a38b715David Lawrenceunsigned int A_IntegerBits (integer, integerLen)
b54630c4518a1a173fee3478f4bf51dff450b6dcMark Andrewsunsigned char *integer;
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence for (bytes = 0; bytes < integerLen && integer[bytes] == 0; bytes++);
34ee961fa2f0f5f2ee3cff40fdb4d7d7b48b7728Mark Andrews /* Get byte to test and increment byte count for final calculation */
e43b9a20054cdda6946ab758e1c2005f2b25641aBrian Wellington /* Get number of bits in most significant byte */
34ee961fa2f0f5f2ee3cff40fdb4d7d7b48b7728Mark Andrews for (bits = 8, mask = 0x80; (byte & mask) == 0; bits--, mask >>= 1);