亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mpi.c

?? PeerSec Networks MatrixSSL?is an embedded SSL implementation designed for small footprint applicatio
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*	 *	mpi.c *	Release $Name: MATRIXSSL_1_7_3_OPEN $ * *	multiple-precision integer library *//* *	Copyright (c) PeerSec Networks, 2002-2005. All Rights Reserved. *	The latest version of this code is available at http://www.matrixssl.org * *	This software is open source; you can redistribute it and/or modify *	it under the terms of the GNU General Public License as published by *	the Free Software Foundation; either version 2 of the License, or *	(at your option) any later version. * *	This General Public License does NOT permit incorporating this software  *	into proprietary programs.  If you are unable to comply with the GPL, a  *	commercial license for this software may be purchased from PeerSec Networks *	at http://www.peersec.com *	 *	This program is distributed in WITHOUT ANY WARRANTY; without even the  *	implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  *	See the GNU General Public License for more details. *	 *	You should have received a copy of the GNU General Public License *	along with this program; if not, write to the Free Software *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *	http://www.gnu.org/copyleft/gpl.html *//******************************************************************************/#include "../cryptoLayer.h"#include <stdarg.h>static int32 mp_exptmod_fast (psPool_t *pool, mp_int * G, mp_int * X,				mp_int * P, mp_int * Y, int32 redmode);/******************************************************************************//*	FUTURE	1. Convert the mp_init and mp_clear functions to not use malloc + free,	but to use static storage within the bignum variable instead - but	how to handle grow()?  Maybe use a simple memory allocator	2. verify stack usage of all functions and use of MP_LOW_MEM:		fast_mp_montgomery_reduce		fast_s_mp_mul_digs		fast_s_mp_sqr		fast_s_mp_mul_high_digs	3. HAC stands for Handbook of Applied Cryptography		http://www.cacr.math.uwaterloo.ca/hac/*//******************************************************************************//*	Utility functions*/void psZeromem(void *dst, size_t len){	unsigned char *mem = (unsigned char *)dst;		if (dst == NULL) {		return;	}	while (len-- > 0) {		*mem++ = 0;	}}void psBurnStack(unsigned long len){	unsigned char buf[32];		psZeromem(buf, sizeof(buf));	if (len > (unsigned long)sizeof(buf)) {		psBurnStack(len - sizeof(buf));	}}/******************************************************************************//*	Multiple precision integer functions	Note: we don't use va_args here to prevent portability issues.*/int32 _mp_init_multi(psPool_t *pool, mp_int *mp0, mp_int *mp1, mp_int *mp2, 					mp_int *mp3, mp_int *mp4, mp_int *mp5, 					mp_int *mp6, mp_int *mp7){	mp_err	res		= MP_OKAY;		/* Assume ok until proven otherwise */	int32		n		= 0;			/* Number of ok inits */	mp_int	*tempArray[9] = {mp0, mp1, mp2, mp3, mp4, mp5, mp6, mp7, NULL};	while (tempArray[n] != NULL) {		if (mp_init(pool, tempArray[n]) != MP_OKAY) {			res = MP_MEM;			break;		}		n++;	}	if (res == MP_MEM) {		n = 0;		while (tempArray[n] != NULL) {			mp_clear(tempArray[n]);			n++;		}	}	return res;		/* Assumed ok, if error flagged above. */}/******************************************************************************//*	Reads a unsigned char array, assumes the msb is stored first [big endian] */int32 mp_read_unsigned_bin (mp_int * a, unsigned char *b, int32 c){	int32		res;/*	Make sure there are at least two digits. */	if (a->alloc < 2) {		if ((res = mp_grow(a, 2)) != MP_OKAY) {			return res;		}	}/*	Zero the int32. */	mp_zero (a);/*	read the bytes in */	while (c-- > 0) {		if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) {			return res;		}#ifndef MP_8BIT		a->dp[0] |= *b++;		a->used += 1;#else		a->dp[0] = (*b & MP_MASK);		a->dp[1] |= ((*b++ >> 7U) & 1);		a->used += 2;#endif /* MP_8BIT */	}	mp_clamp (a);	return MP_OKAY;}/******************************************************************************//* 	Compare two ints (signed) */int32 mp_cmp (mp_int * a, mp_int * b){/*	compare based on sign */	if (a->sign != b->sign) {		if (a->sign == MP_NEG) {			return MP_LT;		} else {			return MP_GT;		}	}/*	compare digits */	if (a->sign == MP_NEG) {		/* if negative compare opposite direction */		return mp_cmp_mag(b, a);	} else {		return mp_cmp_mag(a, b);	}}/******************************************************************************//*	Store in unsigned [big endian] format.*/int32 mp_to_unsigned_bin(psPool_t *pool, mp_int * a, unsigned char *b){	int32			x, res;	mp_int		t;	if ((res = mp_init_copy(pool, &t, a)) != MP_OKAY) {		return res;	}	x = 0;	while (mp_iszero (&t) == 0) {#ifndef MP_8BIT		b[x++] = (unsigned char) (t.dp[0] & 255);#else		b[x++] = (unsigned char) (t.dp[0] | ((t.dp[1] & 0x01) << 7));#endif /* MP_8BIT */		if ((res = mp_div_2d (pool, &t, 8, &t, NULL)) != MP_OKAY) {			mp_clear (&t);			return res;		}	}	bn_reverse (b, x);	mp_clear (&t);	return MP_OKAY;}void _mp_clear_multi(mp_int *mp0, mp_int *mp1, mp_int *mp2, mp_int *mp3,				  mp_int *mp4, mp_int *mp5, mp_int *mp6, mp_int *mp7){	int32		n		= 0;		/* Number of ok inits */	mp_int	*tempArray[9] = {mp0, mp1, mp2, mp3, mp4, mp5, mp6, mp7, NULL};	for (n = 0; tempArray[n] != NULL; n++) {		mp_clear(tempArray[n]);	}}/******************************************************************************//*	Init a new mp_int.*/int32 mp_init (psPool_t *pool, mp_int * a){	int32		i;/*	allocate memory required and clear it */	a->dp = OPT_CAST(mp_digit) psMalloc(pool, sizeof (mp_digit) * MP_PREC);	if (a->dp == NULL) {		return MP_MEM;	}/*	set the digits to zero */	for (i = 0; i < MP_PREC; i++) {		a->dp[i] = 0;	}/*	set the used to zero, allocated digits to the default precision and sign	to positive */	a->used  = 0;	a->alloc = MP_PREC;	a->sign  = MP_ZPOS;	return MP_OKAY;}/******************************************************************************//*	clear one (frees). */void mp_clear (mp_int * a){	int32		i;/*	only do anything if a hasn't been freed previously */	if (a->dp != NULL) {/*		first zero the digits */		for (i = 0; i < a->used; i++) {			a->dp[i] = 0;		}		/* free ram */		psFree (a->dp);/*		reset members to make debugging easier */		a->dp		= NULL;		a->alloc	= a->used = 0;		a->sign		= MP_ZPOS;	}}/******************************************************************************//*	Get the size for an unsigned equivalent. */int32 mp_unsigned_bin_size (mp_int * a){	int32		size = mp_count_bits (a);	return	(size / 8 + ((size & 7) != 0 ? 1 : 0));}/******************************************************************************//*	Trim unused digits 	This is used to ensure that leading zero digits are trimed and the 	leading "used" digit will be non-zero. Typically very fast.  Also fixes 	the sign if there are no more leading digits*/void mp_clamp (mp_int * a){/*	decrease used while the most significant digit is zero. */	while (a->used > 0 && a->dp[a->used - 1] == 0) {		--(a->used);	}/*	reset the sign flag if used == 0 */	if (a->used == 0) {		a->sign = MP_ZPOS;	}}/******************************************************************************//*	Shift left by a certain bit count. */int32 mp_mul_2d (mp_int * a, int32 b, mp_int * c){	mp_digit	d;	int32			res;/*	Copy */	if (a != c) {		if ((res = mp_copy (a, c)) != MP_OKAY) {			return res;		}	}	if (c->alloc < (int32)(c->used + b/DIGIT_BIT + 1)) {		if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) {			return res;		}	}/*	Shift by as many digits in the bit count */	if (b >= (int32)DIGIT_BIT) {		if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) {			return res;		}	}/*	shift any bit count < DIGIT_BIT */	d = (mp_digit) (b % DIGIT_BIT);	if (d != 0) {		register mp_digit *tmpc, shift, mask, r, rr;		register int32 x;/*		bitmask for carries */		mask = (((mp_digit)1) << d) - 1;/*		shift for msbs */		shift = DIGIT_BIT - d;		/* alias */		tmpc = c->dp;		/* carry */		r = 0;		for (x = 0; x < c->used; x++) {/*			get the higher bits of the current word */			rr = (*tmpc >> shift) & mask;/*			shift the current word and OR in the carry */			*tmpc = ((*tmpc << d) | r) & MP_MASK;			++tmpc;/*			set the carry to the carry bits of the current word */			r = rr;		}/*		set final carry */		if (r != 0) {			c->dp[(c->used)++] = r;		}	}	mp_clamp (c);	return MP_OKAY;}/******************************************************************************//* 	Set to zero. */void mp_zero (mp_int * a){	int			n;	mp_digit	*tmp;	a->sign = MP_ZPOS;	a->used = 0;	tmp = a->dp;	for (n = 0; n < a->alloc; n++) {		*tmp++ = 0;	}}#ifdef MP_LOW_MEM#define TAB_SIZE 32#else#define TAB_SIZE 256#endif /* MP_LOW_MEM *//******************************************************************************//*	Compare maginitude of two ints (unsigned). */int32 mp_cmp_mag (mp_int * a, mp_int * b){	int32			n;	mp_digit	*tmpa, *tmpb;/*	compare based on # of non-zero digits */	if (a->used > b->used) {		return MP_GT;	}	if (a->used < b->used) {		return MP_LT;	}	/* alias for a */	tmpa = a->dp + (a->used - 1);	/* alias for b */	tmpb = b->dp + (a->used - 1);/*	compare based on digits */	for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {		if (*tmpa > *tmpb) {			return MP_GT;		}		if (*tmpa < *tmpb) {			return MP_LT;		}	}	return MP_EQ;}/******************************************************************************//*	computes Y == G**X mod P, HAC pp.616, Algorithm 14.85	Uses a left-to-right k-ary sliding window to compute the modular 	exponentiation. The value of k changes based on the size of the exponent.	Uses Montgomery or Diminished Radix reduction [whichever appropriate]*/int32 mp_exptmod(psPool_t *pool, mp_int * G, mp_int * X, mp_int * P, mp_int * Y){/*	modulus P must be positive */	if (P->sign == MP_NEG) {		return MP_VAL;	}/*	if exponent X is negative we have to recurse */	if (X->sign == MP_NEG) {		mp_int tmpG, tmpX;		int32 err;/*		first compute 1/G mod P */		if ((err = mp_init(pool, &tmpG)) != MP_OKAY) {			return err;		}		if ((err = mp_invmod(pool, G, P, &tmpG)) != MP_OKAY) {			mp_clear(&tmpG);			return err;		}/*		now get |X| */		if ((err = mp_init(pool, &tmpX)) != MP_OKAY) {			mp_clear(&tmpG);			return err;		}		if ((err = mp_abs(X, &tmpX)) != MP_OKAY) {			mp_clear(&tmpG);			mp_clear(&tmpX);			return err;		}/*		and now compute (1/G)**|X| instead of G**X [X < 0] */		err = mp_exptmod(pool, &tmpG, &tmpX, P, Y);		mp_clear(&tmpG);		mp_clear(&tmpX);		return err;	}/*	if the modulus is odd or dr != 0 use the fast method */	if (mp_isodd (P) == 1) {		return mp_exptmod_fast (pool, G, X, P, Y, 0);	} else {/*		no exptmod for evens */		return MP_VAL;	}}/******************************************************************************//*	Call only from mp_exptmod to make sure this fast version qualifies*/static int32 mp_exptmod_fast(psPool_t *pool, mp_int * G, mp_int * X,				mp_int * P, mp_int * Y, int32 redmode){	mp_int		M[TAB_SIZE], res;	mp_digit	buf, mp;	int32		err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;/*	use a pointer to the reduction algorithm.  This allows us to use	one of many reduction algorithms without modding the guts of	the code with if statements everywhere. */	int32	(*redux)(mp_int*,mp_int*,mp_digit);/*	find window size */	x = mp_count_bits (X);	if (x <= 7) {		winsize = 2;	} else if (x <= 36) {		winsize = 3;	} else if (x <= 140) {		winsize = 4;	} else if (x <= 450) {		winsize = 5;	} else if (x <= 1303) {		winsize = 6;	} else if (x <= 3529) {		winsize = 7;	} else {		winsize = 8;	}#ifdef MP_LOW_MEM	if (winsize > 5) {		winsize = 5;	}#endif/*	init M array	init first cell */	if ((err = mp_init(pool, &M[1])) != MP_OKAY) {		return err;	}/*	now init the second half of the array */	for (x = 1<<(winsize-1); x < (1 << winsize); x++) {		if ((err = mp_init(pool, &M[x])) != MP_OKAY) {			for (y = 1<<(winsize-1); y < x; y++) {				mp_clear(&M[y]);			}			mp_clear(&M[1]);			return err;		}	}/*	now setup montgomery */	if ((err = mp_montgomery_setup(P, &mp)) != MP_OKAY) {		goto LBL_M;	}/*	automatically pick the comba one if available */	if (((P->used * 2 + 1) < MP_WARRAY) &&			P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {		redux = fast_mp_montgomery_reduce;	} else {/*		use slower baseline Montgomery method */		redux = mp_montgomery_reduce;	}/*	setup result */	if ((err = mp_init(pool, &res)) != MP_OKAY) {		goto LBL_M;	}/*	create M table. The first half of the table is not computed	though accept for M[0] and M[1]*//*	now we need R mod m */	if ((err = mp_montgomery_calc_normalization(&res, P)) != MP_OKAY) {		goto LBL_RES;	}/*	now set M[1] to G * R mod m */	if ((err = mp_mulmod(pool, G, &res, P, &M[1])) != MP_OKAY) {		goto LBL_RES;	}/*	compute the value at M[1<<(winsize-1)] by squaring	M[1] (winsize-1) times*/	if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {		goto LBL_RES;	}	for (x = 0; x < (winsize - 1); x++) {		if ((err = mp_sqr(pool, &M[1 << (winsize - 1)],				&M[1 << (winsize - 1)])) != MP_OKAY) {			goto LBL_RES;		}		if ((err = redux(&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {			goto LBL_RES;		}	}/*	create upper table */	for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {		if ((err = mp_mul(pool, &M[x - 1], &M[1], &M[x])) != MP_OKAY) {			goto LBL_RES;		}		if ((err = redux(&M[x], P, mp)) != MP_OKAY) {			goto LBL_RES;		}	}/*	set initial mode and bit cnt */	mode   = 0;	bitcnt = 1;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本欧美久久久久免费播放网| 99久久精品免费精品国产| 国产成人激情av| 色婷婷久久久久swag精品| 欧美一区二区三区电影| 亚洲男人电影天堂| 国产suv精品一区二区三区| 欧美一区二区三区在线观看| 一级中文字幕一区二区| 国产精品123| 日韩精品一区二| 丝袜诱惑亚洲看片| 欧洲国内综合视频| 亚洲欧洲国产专区| 成人小视频在线| 久久精品一区二区三区不卡牛牛 | 一区二区三区丝袜| 国产酒店精品激情| 久久综合九色综合97婷婷女人 | 欧美一区二区三区免费视频| 亚洲一区二区在线观看视频| 91色|porny| 中文字幕日韩一区| 99精品在线观看视频| 国产精品不卡在线| 91免费视频大全| 亚洲欧美日韩国产综合| 91麻豆免费视频| 亚洲色图制服丝袜| 色哟哟一区二区在线观看| 亚洲欧美综合色| 9久草视频在线视频精品| 国产调教视频一区| 成人一区二区三区视频在线观看 | 久久久久久久久久久电影| 久久99精品国产麻豆不卡| 91精品国产综合久久精品图片| 亚洲国产中文字幕在线视频综合 | 99re热视频这里只精品| 国产精品毛片高清在线完整版| 国产成人av电影在线| 国产午夜精品理论片a级大结局| 国产伦精品一区二区三区免费| 久久久亚洲高清| 成人一级片网址| 日韩理论片在线| 欧美性生活大片视频| 天天做天天摸天天爽国产一区| 日韩午夜精品视频| 国产精品一区二区你懂的| 国产精品久久久久久久岛一牛影视| 成人永久看片免费视频天堂| 亚洲综合成人网| 欧美一级欧美三级| 国产a视频精品免费观看| 亚洲视频一区在线| 日韩欧美三级在线| 国产精品亚洲专一区二区三区| 成人免费在线视频| 欧美欧美午夜aⅴ在线观看| 国产最新精品免费| 亚洲素人一区二区| 日韩精品一区二区三区蜜臀| 不卡电影免费在线播放一区| 亚洲超丰满肉感bbw| 久久综合精品国产一区二区三区| 成人精品免费网站| 五月婷婷激情综合网| 国产精品午夜春色av| 欧美精品一卡二卡| 成人免费视频caoporn| 偷拍亚洲欧洲综合| 中文字幕在线一区| 精品久久久久香蕉网| 色婷婷综合五月| 国产精品综合在线视频| 午夜激情久久久| 国产精品久久三| 欧美变态tickle挠乳网站| 色综合久久综合中文综合网| 国产美女娇喘av呻吟久久| 午夜久久久久久| 亚洲欧美综合色| 久久久综合网站| 欧美一区二区日韩| 色综合天天综合狠狠| 国产精品性做久久久久久| 日韩精品久久久久久| 樱桃视频在线观看一区| 国产精品无人区| 久久综合九色综合97_久久久| 欧美另类z0zxhd电影| 91日韩一区二区三区| 成人免费毛片aaaaa**| 国产资源在线一区| 美女在线一区二区| 性久久久久久久| 一区二区三区四区在线播放| 中文成人av在线| 久久久久综合网| 久久久久久久久久美女| 91精品国产一区二区人妖| 欧美日韩不卡一区| 欧洲视频一区二区| 91福利在线免费观看| 91年精品国产| 在线免费亚洲电影| 色香色香欲天天天影视综合网| av在线不卡电影| 91丨porny丨国产| av在线免费不卡| 色综合中文字幕国产| 国产成人aaa| 国产久卡久卡久卡久卡视频精品| 韩国av一区二区三区四区| 久久精品国产99国产精品| 精品中文字幕一区二区小辣椒| 日韩av不卡一区二区| 强制捆绑调教一区二区| 美美哒免费高清在线观看视频一区二区 | 久久蜜臀精品av| 国产亚洲1区2区3区| 国产精品视频免费看| 国产精品色在线观看| 国产精品的网站| 一区二区三区在线播| 日韩成人dvd| 国产一区二区网址| 99免费精品视频| 欧美怡红院视频| 日韩欧美综合一区| 久久精品一区二区三区四区| 国产精品久久久久7777按摩 | 精品一区免费av| 国产成人在线视频网站| 99久久综合狠狠综合久久| 91成人在线免费观看| 日韩一卡二卡三卡四卡| 久久久久高清精品| 亚洲黄色片在线观看| 久久国产人妖系列| 成人app网站| 欧美一区二区三区日韩视频| 久久久久九九视频| 一区二区三区四区激情| 日韩av不卡一区二区| 成人免费毛片app| 欧美日韩国产大片| 国产清纯白嫩初高生在线观看91 | 日本一二三不卡| 亚洲午夜久久久| 国产乱码字幕精品高清av| 一本到不卡精品视频在线观看| 制服丝袜中文字幕亚洲| 久久久精品影视| 午夜一区二区三区在线观看| 国产伦精一区二区三区| 欧美日韩在线观看一区二区| 国产日韩视频一区二区三区| 亚洲123区在线观看| 国产成人av电影在线观看| 精品视频一区三区九区| 中文字幕免费观看一区| 日本伊人精品一区二区三区观看方式| 国产在线播放一区二区三区| 欧美日韩免费观看一区二区三区| 久久久久久久久97黄色工厂| 午夜国产不卡在线观看视频| 91在线精品秘密一区二区| 久久久精品欧美丰满| 日韩成人伦理电影在线观看| 91成人在线精品| 国产精品久久久久久久第一福利| 狠狠色综合色综合网络| 欧美无砖专区一中文字| 亚洲人成网站色在线观看| 国产成人精品1024| 亚洲精品一区二区三区四区高清| 亚洲综合一二区| 日本精品一级二级| 国产精品三级视频| 国产一区二区三区| 精品欧美久久久| 免费一级片91| 日韩一区二区视频在线观看| 亚洲第一综合色| 欧美日韩一级大片网址| 一区二区三区蜜桃| 91捆绑美女网站| 亚洲丝袜自拍清纯另类| 91伊人久久大香线蕉| 中文字幕一区二区三| 成人avav在线| 国产精品美女久久久久aⅴ国产馆| 国产一区二区三区四区五区美女| 日韩欧美在线影院| 日本va欧美va瓶| 日韩欧美久久久| 国产九色sp调教91| 欧美韩日一区二区三区四区|