diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libresolv2/common/dnssafe/intbits.c | |
download | illumos-gate-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libresolv2/common/dnssafe/intbits.c')
-rw-r--r-- | usr/src/lib/libresolv2/common/dnssafe/intbits.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/usr/src/lib/libresolv2/common/dnssafe/intbits.c b/usr/src/lib/libresolv2/common/dnssafe/intbits.c new file mode 100644 index 0000000000..6a213d30ee --- /dev/null +++ b/usr/src/lib/libresolv2/common/dnssafe/intbits.c @@ -0,0 +1,41 @@ +/* + * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* Copyright (C) RSA Data Security, Inc. created 1990, 1996. This is an + unpublished work protected as such under copyright law. This work + contains proprietary, confidential, and trade secret information of + RSA Data Security, Inc. Use, disclosure or reproduction without the + express written authorization of RSA Data Security, Inc. is + prohibited. + */ + +#include "port_before.h" +#include "global.h" +#include "algae.h" +#include "port_after.h" + +/* Return the number of bits in the canonical, positive integer. + IntgerBits (0) = 0. + */ +unsigned int A_IntegerBits (integer, integerLen) +const unsigned char *integer; +unsigned int integerLen; +{ + unsigned char mask, byte; + unsigned int bytes, bits; + + for (bytes = 0; bytes < integerLen && integer[bytes] == 0; bytes++); + if (bytes == integerLen) + return (0); + + /* Get byte to test and increment byte count for final calculation */ + byte = integer[bytes++]; + + /* Get number of bits in most significant byte */ + for (bits = 8, mask = 0x80; (byte & mask) == 0; bits--, mask >>= 1); + return (8 * (integerLen - bytes) + bits); +} |