⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lip.h

📁 应用密码学这本书的源代码
💻 H
📖 第 1 页 / 共 5 页
字号:
        * c gets 0 if b <= 0        * p starts counting at 0        \******************************************************************/    long zsetbit(verylong *a, long p);        /******************************************************************\        * returns original value of |p|th bit of |a|, and replaces        * |p|th bit of a by 1 if it was zero        * p starts counting at 0        \******************************************************************/    long zswitchbit(verylong *a, long p);        /******************************************************************\        * returns original value of |p|th bit of |a|, and switches        * the value of |p|th bit of a        * p starts counting at 0        \******************************************************************/    long zreverses(long aa);        /******************************************************************\        * returns the bit reverse of |a|        * i.e., zreverses(11001010) is 1010011        \******************************************************************/    void zreverse(verylong a, verylong *b);        /******************************************************************\        * b gets the bit reverse of |a|	* i.e., zintoz(11,&a); zlshift(a,100,&a); zreverse(a,&b);        *       produces b with value 13        \******************************************************************//******************************************************************************\*  Comparison, signs, copying, logarithms\******************************************************************************/    long zscompare(verylong a, long b);        /******************************************************************\        * if (a > b)        *     return (1);        * if (a == b)        *     return (0);        * if (a < b)        *     return (-1);        \******************************************************************/    long zcompare(verylong a, verylong b);        /******************************************************************\        * if (a > b)        *     return (1);        * if (a == b)        *     return (0);        * if (a < b)        *     return (-1);        \******************************************************************/    long ziszero (verylong a);        /******************************************************************\        * if (a == 0)        *     return (1);        * if (a != 0)        *     return (0);        \******************************************************************/    long zsign(verylong a);        /******************************************************************\        * if (a > 0)        *     return (1);        * if (a == 0)        *     return (0);        * if (a < 0)        *     return (-1);        \******************************************************************/    void zabs(verylong *a);        /******************************************************************\        * *a = abs(a);        *         \******************************************************************/    void znegate(verylong *a);        /******************************************************************\        * *a = -a;        *         * has no effect on zero a        \******************************************************************/    void zcopy(verylong a, verylong *b);        /******************************************************************\        * *b = a;        \******************************************************************/    void zswap(verylong *a, verylong *b);        /******************************************************************\        * exchange values of *a and *b        \******************************************************************/    long z2logs(long a);        /******************************************************************\        * return (1 + log2(abs(a));        *         * the number of binary bits to represent a,        * returns 0 if a = 0        \******************************************************************/    long z2log(verylong a);        /******************************************************************\        * return (1 + log2(abs(a));        *         * the number of binary bits to represent a,        * returns 0 if a = 0        \******************************************************************/    double zln(verylong a);        /******************************************************************\        * return (approximation to the natural logarithm of |a|);        *         * only for a != 0        *        * possible error message:        *   non-positive argument in zln        * result undefined if error occurs        \******************************************************************/    double zslog(verylong a, long b);        /******************************************************************\        * return (approximation of the logarithm of |a|, base b);        *         * only for a != 0, b >= 2        \******************************************************************/    double zlog(verylong a, verylong b);        /******************************************************************\        * return (approximation of the logarithm of |a|, base b);        *         * only for a != 0, b >= 2        \******************************************************************/    double zdlog(verylong a, double b);        /******************************************************************\        * return (approximation of the logarithm of |a|, base b);        *         * only for a != 0, b > 1        \******************************************************************//******************************************************************************\*  Conversion**  Conversion between very long ints and ordinary longs or doubles.*  Conversion for very long ints to arbitrary basis and back.\******************************************************************************/            void zzero(verylong *a);        /******************************************************************\        * *a = 0;        *         * allocated zero        \******************************************************************/    void zone(verylong *a);        /******************************************************************\        * *a = 1;        *         \******************************************************************/    void zintoz(long d, verylong *a);        /******************************************************************\        * *a = d;        *         \******************************************************************/    void zuintoz(unsigned long d, verylong *a);        /******************************************************************\        * *a = d;        *         \******************************************************************/    void zultoz(unsigned long row[], long len, verylong *a);        /******************************************************************\        * *a = sum row[i]X^i, sum from i=0 to len-1, where        * X = 2^{CHARL*SIZEOFLONG}        * to convert base 2^32 (or 2^64) representation to verylong         *         \******************************************************************/    long ztoint(verylong a);        /******************************************************************\        * return (attempted conversion of a`s value to long);        * no overflow check        *         \******************************************************************/    unsigned long ztouint(verylong a);        /******************************************************************\        * return (attempted conversion of |a|`s value to unsigned long);        * no overflow check        *         \******************************************************************/    long ztoul(verylong a, unsigned long row[], long *len);        /******************************************************************\        * sets *len to m and row[i] such that        * |a| = sum from i = 0 to i = m - 1 of row[i] * X ^ i,        * with 0 <= row[i] < X = 2^{CHARL*SIZEOFLONG}        * returns 1 if m <= *len on input (which should on input be        * the length of row[]) returns 0 if *len on input is too small to        * represent |a| in *len blocks        \******************************************************************/    long zstrtozbas(char *s, long b, verylong *a);        /******************************************************************\        * a gets the value of s whose characters are interpreted as base |b|        * integers, for 0<|b|<=16. First character of s may be a `-` or a `_`        * to indicate negative number. Reads until it finds a character that        * cannot be correctly interpreted as a base |b| digit. Returns the        * number of characters read (excluding the sign), returns 0 for        * b zero, or |b| > 16.        *         \******************************************************************/    long zstrtoz(char *s, verylong *a);        /******************************************************************\        * as zstrtozbas with b = 10        \******************************************************************/    double zdoub(verylong n);        /******************************************************************\        * return (attempted conversion of a`s value to double);        *         * no overflow check        \******************************************************************/    void zsbastoz(long base, long row[], long len, verylong *n);        /******************************************************************\        * *n = sum from i = 0 to i = len - 1 of row[i] * base ^ i        *         \******************************************************************/    void zbastoz(verylong base, verylong row[], long len, verylong *n);        /******************************************************************\        * *n = sum from i = 0 to i = len - 1 of row[i] * base ^ i        *         \******************************************************************/    long zstobas(verylong n, long base, long row[], long *len);        /******************************************************************\        * sets *len to m and row[i] such that |n| equals        * sum from i = 0 to i = m - 1 of row[i] * |base| ^ i,        * with 0 <= row[i] < |base|        * returns 1 if m <= *len on input        * (which should on input be the length of row[])        * returns 0 if *len on input is too small to represent        * n in *len blocks or if |base| <= 1        \******************************************************************/    long ztobas(verylong n, verylong base, verylong row[], long *len);        /******************************************************************\        * same as zstobas, but with a very long int base        *         \******************************************************************/    long zstosymbas(verylong n, long base, long row[], long *len);        /******************************************************************\        * same as zstobas, except that |row[i]| <= |base| / 2        *         \******************************************************************/    long ztosymbas(verylong n, verylong base, verylong row[], long *len);        /******************************************************************\        * same as zstosymbas, but with a very long int base        *         \******************************************************************//******************************************************************************\*  Non-modular exponentiation **  Exponentiation, squareroots  and arbitrary roots.\******************************************************************************/    void zsexp(verylong a, long e, verylong *b);        /******************************************************************\        * *b = a ^ e;        *         * arguments cannot be the same,        * e must be >= 0 if abs(a) != 1        \******************************************************************/    void zexp(verylong a, verylong e, verylong *b);        /******************************************************************\        * *b = a ^ e;        *         * arguments cannot be the same,        * e must be >= 0 if abs(a) != 1,        * better be sure that you know what you`re         * doing before you call this        *        * possible error message:        *   negative exponent in zexp        * result undefined if error occurs        \******************************************************************/    long zsqrts(long n);        /******************************************************************\        * if (n > 0)        *     return ([sqrt(n)]);        * else        *     return (0);        \******************************************************************/    long zsqrt(verylong n, verylong *r, verylong *dif);        /******************************************************************\        * *r = [sqrt(n)];        * *dif = n - r ^ 2;        * if (n perfect square)        *     return (1)        * else        *     return (0)        *         * n must be >= 0        *        * possible error message:        *   negative argument in zsqrt        * result undefined if error occurs        \******************************************************************/    long zroot(verylong a, long n, verylong *b);        /******************************************************************\        * *b = nth root of a;        * 	* if (n perfect dth root)	*	return 1	* else if (no dth root)	*	return -1	* else	*	return 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -