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

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

?? bn_exp.c

?? openssl包含TLS
?? C
?? 第 1 頁 / 共 2 頁
字號:
				/* wvalue will be an odd number < 2^window */		if (!BN_mod_mul_montgomery(r,r,&(val[wvalue>>1]),mont,ctx))			goto err;		/* move the 'window' down further */		wstart-=wend+1;		wvalue=0;		start=0;		if (wstart < 0) break;		}	if (!BN_from_montgomery(rr,r,mont,ctx)) goto err;	ret=1;err:	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);	BN_CTX_end(ctx);	for (i=0; i<ts; i++)		BN_clear_free(&(val[i]));	return(ret);	}/* BN_mod_exp_mont_consttime() stores the precomputed powers in a specific layout * so that accessing any of these table values shows the same access pattern as far * as cache lines are concerned.  The following functions are used to transfer a BIGNUM * from/to that table. */static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)	{	size_t i, j;	if (bn_wexpand(b, top) == NULL)		return 0;	while (b->top < top)		{		b->d[b->top++] = 0;		}		for (i = 0, j=idx; i < top * sizeof b->d[0]; i++, j+=width)		{		buf[j] = ((unsigned char*)b->d)[i];		}	bn_fix_top(b);	return 1;	}static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)	{	size_t i, j;	if (bn_wexpand(b, top) == NULL)		return 0;	for (i=0, j=idx; i < top * sizeof b->d[0]; i++, j+=width)		{		((unsigned char*)b->d)[i] = buf[j];		}	b->top = top;	bn_fix_top(b);	return 1;	}	/* Given a pointer value, compute the next address that is a cache line multiple. */#define MOD_EXP_CTIME_ALIGN(x_) \	((unsigned char*)(x_) + (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - (((BN_ULONG)(x_)) & (MOD_EXP_CTIME_MIN_CACHE_LINE_MASK))))/* This variant of BN_mod_exp_mont() uses fixed windows and the special * precomputation memory layout to limit data-dependency to a minimum * to protect secret exponents (cf. the hyper-threading timing attacks * pointed out by Colin Percival, * http://www.daemonology.net/hyperthreading-considered-harmful/) */int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,		    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)	{	int i,bits,ret=0,idx,window,wvalue;	int top; 	BIGNUM *r;	const BIGNUM *aa;	BN_MONT_CTX *mont=NULL;	int numPowers;	unsigned char *powerbufFree=NULL;	int powerbufLen = 0;	unsigned char *powerbuf=NULL;	BIGNUM *computeTemp=NULL, *am=NULL;	bn_check_top(a);	bn_check_top(p);	bn_check_top(m);	top = m->top;	if (!(m->d[0] & 1))		{		BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME,BN_R_CALLED_WITH_EVEN_MODULUS);		return(0);		}	bits=BN_num_bits(p);	if (bits == 0)		{		ret = BN_one(rr);		return ret;		} 	/* Initialize BIGNUM context and allocate intermediate result */	BN_CTX_start(ctx);	r = BN_CTX_get(ctx);	if (r == NULL) goto err;	/* Allocate a montgomery context if it was not supplied by the caller.	 * If this is not done, things will break in the montgomery part. 	 */	if (in_mont != NULL)		mont=in_mont;	else		{		if ((mont=BN_MONT_CTX_new()) == NULL) goto err;		if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;		}	/* Get the window size to use with size of p. */	window = BN_window_bits_for_ctime_exponent_size(bits);	/* Allocate a buffer large enough to hold all of the pre-computed	 * powers of a.	 */	numPowers = 1 << window;	powerbufLen = sizeof(m->d[0])*top*numPowers;	if ((powerbufFree=(unsigned char*)OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)		goto err;			powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);	memset(powerbuf, 0, powerbufLen); 	/* Initialize the intermediate result. Do this early to save double conversion,	 * once each for a^0 and intermediate result.	 */ 	if (!BN_to_montgomery(r,BN_value_one(),mont,ctx)) goto err;	if (!MOD_EXP_CTIME_COPY_TO_PREBUF(r, top, powerbuf, 0, numPowers)) goto err;	/* Initialize computeTemp as a^1 with montgomery precalcs */	computeTemp = BN_CTX_get(ctx);	am = BN_CTX_get(ctx);	if (computeTemp==NULL || am==NULL) goto err;	if (a->neg || BN_ucmp(a,m) >= 0)		{		if (!BN_mod(am,a,m,ctx))			goto err;		aa= am;		}	else		aa=a;	if (!BN_to_montgomery(am,aa,mont,ctx)) goto err;	if (!BN_copy(computeTemp, am)) goto err;	if (!MOD_EXP_CTIME_COPY_TO_PREBUF(am, top, powerbuf, 1, numPowers)) goto err;	/* If the window size is greater than 1, then calculate	 * val[i=2..2^winsize-1]. Powers are computed as a*a^(i-1)	 * (even powers could instead be computed as (a^(i/2))^2	 * to use the slight performance advantage of sqr over mul).	 */	if (window > 1)		{		for (i=2; i<numPowers; i++)			{			/* Calculate a^i = a^(i-1) * a */			if (!BN_mod_mul_montgomery(computeTemp,am,computeTemp,mont,ctx))				goto err;			if (!MOD_EXP_CTIME_COPY_TO_PREBUF(computeTemp, top, powerbuf, i, numPowers)) goto err;			}		} 	/* Adjust the number of bits up to a multiple of the window size. 	 * If the exponent length is not a multiple of the window size, then 	 * this pads the most significant bits with zeros to normalize the 	 * scanning loop to there's no special cases. 	 * 	 * * NOTE: Making the window size a power of two less than the native	 * * word size ensures that the padded bits won't go past the last 	 * * word in the internal BIGNUM structure. Going past the end will 	 * * still produce the correct result, but causes a different branch 	 * * to be taken in the BN_is_bit_set function. 	 */ 	bits = ((bits+window-1)/window)*window; 	idx=bits-1;	/* The top bit of the window */ 	/* Scan the exponent one window at a time starting from the most 	 * significant bits. 	 */ 	while (idx >= 0)  		{ 		wvalue=0; /* The 'value' of the window */ 		 		/* Scan the window, squaring the result as we go */ 		for (i=0; i<window; i++,idx--) 			{			if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))	goto err;			wvalue = (wvalue<<1)+BN_is_bit_set(p,idx);  			} 				/* Fetch the appropriate pre-computed value from the pre-buf */		if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(computeTemp, top, powerbuf, wvalue, numPowers)) goto err; 		/* Multiply the result into the intermediate result */ 		if (!BN_mod_mul_montgomery(r,r,computeTemp,mont,ctx)) goto err;  		} 	/* Convert the final result from montgomery to standard format */	if (!BN_from_montgomery(rr,r,mont,ctx)) goto err;	ret=1;err:	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);	if (powerbuf!=NULL)		{		OPENSSL_cleanse(powerbuf,powerbufLen);		OPENSSL_free(powerbufFree);		} 	if (am!=NULL) BN_clear(am); 	if (computeTemp!=NULL) BN_clear(computeTemp);	BN_CTX_end(ctx);	return(ret);	}int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)	{	BN_MONT_CTX *mont = NULL;	int b, bits, ret=0;	int r_is_one;	BN_ULONG w, next_w;	BIGNUM *d, *r, *t;	BIGNUM *swap_tmp;#define BN_MOD_MUL_WORD(r, w, m) \		(BN_mul_word(r, (w)) && \		(/* BN_ucmp(r, (m)) < 0 ? 1 :*/  \			(BN_mod(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1))))		/* BN_MOD_MUL_WORD is only used with 'w' large,		 * so the BN_ucmp test is probably more overhead		 * than always using BN_mod (which uses BN_copy if		 * a similar test returns true). */		/* We can use BN_mod and do not need BN_nnmod because our		 * accumulator is never negative (the result of BN_mod does		 * not depend on the sign of the modulus).		 */#define BN_TO_MONTGOMERY_WORD(r, w, mont) \		(BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx))	if (BN_get_flags(p, BN_FLG_EXP_CONSTTIME) != 0)		{		/* BN_FLG_EXP_CONSTTIME only supported by BN_mod_exp_mont() */		BNerr(BN_F_BN_MOD_EXP_MONT_WORD,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);		return -1;		}	bn_check_top(p);	bn_check_top(m);	if (m->top == 0 || !(m->d[0] & 1))		{		BNerr(BN_F_BN_MOD_EXP_MONT_WORD,BN_R_CALLED_WITH_EVEN_MODULUS);		return(0);		}	if (m->top == 1)		a %= m->d[0]; /* make sure that 'a' is reduced */	bits = BN_num_bits(p);	if (bits == 0)		{		ret = BN_one(rr);		return ret;		}	if (a == 0)		{		ret = BN_zero(rr);		return ret;		}	BN_CTX_start(ctx);	d = BN_CTX_get(ctx);	r = BN_CTX_get(ctx);	t = BN_CTX_get(ctx);	if (d == NULL || r == NULL || t == NULL) goto err;	if (in_mont != NULL)		mont=in_mont;	else		{		if ((mont = BN_MONT_CTX_new()) == NULL) goto err;		if (!BN_MONT_CTX_set(mont, m, ctx)) goto err;		}	r_is_one = 1; /* except for Montgomery factor */	/* bits-1 >= 0 */	/* The result is accumulated in the product r*w. */	w = a; /* bit 'bits-1' of 'p' is always set */	for (b = bits-2; b >= 0; b--)		{		/* First, square r*w. */		next_w = w*w;		if ((next_w/w) != w) /* overflow */			{			if (r_is_one)				{				if (!BN_TO_MONTGOMERY_WORD(r, w, mont)) goto err;				r_is_one = 0;				}			else				{				if (!BN_MOD_MUL_WORD(r, w, m)) goto err;				}			next_w = 1;			}		w = next_w;		if (!r_is_one)			{			if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) goto err;			}		/* Second, multiply r*w by 'a' if exponent bit is set. */		if (BN_is_bit_set(p, b))			{			next_w = w*a;			if ((next_w/a) != w) /* overflow */				{				if (r_is_one)					{					if (!BN_TO_MONTGOMERY_WORD(r, w, mont)) goto err;					r_is_one = 0;					}				else					{					if (!BN_MOD_MUL_WORD(r, w, m)) goto err;					}				next_w = a;				}			w = next_w;			}		}	/* Finally, set r:=r*w. */	if (w != 1)		{		if (r_is_one)			{			if (!BN_TO_MONTGOMERY_WORD(r, w, mont)) goto err;			r_is_one = 0;			}		else			{			if (!BN_MOD_MUL_WORD(r, w, m)) goto err;			}		}	if (r_is_one) /* can happen only if a == 1*/		{		if (!BN_one(rr)) goto err;		}	else		{		if (!BN_from_montgomery(rr, r, mont, ctx)) goto err;		}	ret = 1;err:	if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);	BN_CTX_end(ctx);	return(ret);	}/* The old fallback, simple version :-) */int BN_mod_exp_simple(BIGNUM *r,	const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,	BN_CTX *ctx)	{	int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0;	int start=1;	BIGNUM *d;	BIGNUM val[TABLE_SIZE];	if (BN_get_flags(p, BN_FLG_EXP_CONSTTIME) != 0)		{		/* BN_FLG_EXP_CONSTTIME only supported by BN_mod_exp_mont() */		BNerr(BN_F_BN_MOD_EXP_SIMPLE,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);		return -1;		}	bits=BN_num_bits(p);	if (bits == 0)		{		ret = BN_one(r);		return ret;		}	BN_CTX_start(ctx);	if ((d = BN_CTX_get(ctx)) == NULL) goto err;	BN_init(&(val[0]));	ts=1;	if (!BN_nnmod(&(val[0]),a,m,ctx)) goto err;		/* 1 */	if (BN_is_zero(&(val[0])))		{		ret = BN_zero(r);		goto err;		}	window = BN_window_bits_for_exponent_size(bits);	if (window > 1)		{		if (!BN_mod_mul(d,&(val[0]),&(val[0]),m,ctx))			goto err;				/* 2 */		j=1<<(window-1);		for (i=1; i<j; i++)			{			BN_init(&(val[i]));			if (!BN_mod_mul(&(val[i]),&(val[i-1]),d,m,ctx))				goto err;			}		ts=i;		}	start=1;	/* This is used to avoid multiplication etc			 * when there is only the value '1' in the			 * buffer. */	wvalue=0;	/* The 'value' of the window */	wstart=bits-1;	/* The top bit of the window */	wend=0;		/* The bottom bit of the window */	if (!BN_one(r)) goto err;	for (;;)		{		if (BN_is_bit_set(p,wstart) == 0)			{			if (!start)				if (!BN_mod_mul(r,r,r,m,ctx))				goto err;			if (wstart == 0) break;			wstart--;			continue;			}		/* We now have wstart on a 'set' bit, we now need to work out		 * how bit a window to do.  To do this we need to scan		 * forward until the last set bit before the end of the		 * window */		j=wstart;		wvalue=1;		wend=0;		for (i=1; i<window; i++)			{			if (wstart-i < 0) break;			if (BN_is_bit_set(p,wstart-i))				{				wvalue<<=(i-wend);				wvalue|=1;				wend=i;				}			}		/* wend is the size of the current window */		j=wend+1;		/* add the 'bytes above' */		if (!start)			for (i=0; i<j; i++)				{				if (!BN_mod_mul(r,r,r,m,ctx))					goto err;				}				/* wvalue will be an odd number < 2^window */		if (!BN_mod_mul(r,r,&(val[wvalue>>1]),m,ctx))			goto err;		/* move the 'window' down further */		wstart-=wend+1;		wvalue=0;		start=0;		if (wstart < 0) break;		}	ret=1;err:	BN_CTX_end(ctx);	for (i=0; i<ts; i++)		BN_clear_free(&(val[i]));	return(ret);	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
26uuu另类欧美亚洲曰本| 美脚の诱脚舐め脚责91| 午夜电影一区二区三区| 国产精品一区久久久久| 欧美日韩一区二区在线观看视频 | 日韩高清在线不卡| 国产一区二区视频在线播放| 在线亚洲免费视频| 国产亚洲婷婷免费| 久色婷婷小香蕉久久| 91豆麻精品91久久久久久| 久久日韩粉嫩一区二区三区 | 国产精品国产三级国产普通话蜜臀| 亚洲成人久久影院| 99久久777色| 国产人成亚洲第一网站在线播放| 蜜臀av一区二区在线观看| 91看片淫黄大片一级| 久久网站最新地址| 奇米精品一区二区三区在线观看 | 成人午夜伦理影院| 精品国产伦一区二区三区免费| 亚洲成av人片观看| 在线观看一区二区视频| 亚洲免费三区一区二区| 成人深夜在线观看| 日本一区二区免费在线观看视频| 久久99精品久久久久久国产越南| 91麻豆精品国产91久久久| 亚洲国产精品久久艾草纯爱| 在线亚洲一区二区| 一区二区三区欧美久久| 色欧美片视频在线观看| 亚洲精品写真福利| 色播五月激情综合网| 亚洲乱码国产乱码精品精小说 | 国产成人在线免费观看| 久久一区二区三区四区| 国产真实乱子伦精品视频| 日韩欧美国产三级电影视频| 久久精品国产久精国产爱| 日韩视频123| 国产一二三精品| 国产亚洲欧美日韩日本| 国产成人精品免费看| 综合自拍亚洲综合图不卡区| 色综合久久久久综合99| 亚洲第一狼人社区| 日韩你懂的电影在线观看| 国产一区二区三区在线观看精品| 久久久影院官网| 99久久精品费精品国产一区二区| 亚洲激情图片qvod| 在线综合视频播放| 国产一区二区三区国产| 中文字幕亚洲综合久久菠萝蜜| 色美美综合视频| 午夜视频一区二区| 精品av久久707| www.亚洲在线| 性感美女久久精品| xf在线a精品一区二区视频网站| 国产91精品一区二区麻豆网站| 国产精品免费看片| 欧美日韩在线播| 国产精品自在在线| 一二三四社区欧美黄| 日韩免费性生活视频播放| 成人动漫在线一区| 亚洲风情在线资源站| 久久久国产综合精品女国产盗摄| 色综合久久综合中文综合网| 久久国产免费看| 樱桃国产成人精品视频| 欧美精品一区二区三区在线| 在线亚洲人成电影网站色www| 激情图区综合网| 亚洲精品福利视频网站| 久久久亚洲国产美女国产盗摄 | 日韩一区二区在线观看视频| kk眼镜猥琐国模调教系列一区二区| 日韩国产高清影视| 亚洲激情图片qvod| 国产午夜精品理论片a级大结局 | 久久精品国产免费看久久精品| 中文字幕久久午夜不卡| 欧美电影免费提供在线观看| 色婷婷综合激情| 国产suv一区二区三区88区| 午夜伦欧美伦电影理论片| 国产精品不卡一区二区三区| 26uuu久久综合| 欧美久久久一区| 欧亚一区二区三区| 丁香亚洲综合激情啪啪综合| 精品一区二区免费视频| 成人在线综合网| 毛片一区二区三区| 性久久久久久久久| 亚洲电影一级黄| 亚洲一区二区在线免费看| 国产精品三级av| 久久久久国产精品麻豆| 欧美大片国产精品| 在线成人小视频| 欧美久久久久久久久中文字幕| 91美女片黄在线| 94色蜜桃网一区二区三区| 成人在线综合网| 北条麻妃国产九九精品视频| 高清成人在线观看| 国产不卡在线播放| 岛国一区二区在线观看| 成人av免费在线播放| 成人精品在线视频观看| 粉嫩一区二区三区在线看| 国产成人综合在线播放| 狠狠色狠狠色综合| 国产乱码精品一区二区三区av| 久久99精品久久久久久国产越南 | 日日摸夜夜添夜夜添亚洲女人| 亚洲综合一区二区三区| 亚洲一区视频在线| 天天av天天翘天天综合网色鬼国产| 亚洲成在人线免费| 奇米888四色在线精品| 狠狠色2019综合网| 成人禁用看黄a在线| 成人激情动漫在线观看| 欧美mv日韩mv国产网站app| 欧美精品一区二区蜜臀亚洲| 国产清纯美女被跳蛋高潮一区二区久久w| 国产视频一区二区在线观看| 综合激情成人伊人| 性欧美疯狂xxxxbbbb| 精品一区二区三区在线视频| 国产精品1区2区3区在线观看| 成人黄页在线观看| 在线视频欧美精品| 欧美高清视频一二三区 | 激情六月婷婷久久| 国产成人aaaa| 色菇凉天天综合网| 精品美女在线观看| 自拍偷拍欧美精品| 五月天亚洲婷婷| 国产成人免费视频一区| 色综合色狠狠天天综合色| 欧美日韩成人一区二区| 欧美大片在线观看| 亚洲欧美日韩国产手机在线| 日本欧美韩国一区三区| 不卡一区在线观看| 91精品国产综合久久蜜臀| 国产精品水嫩水嫩| 日本sm残虐另类| 不卡视频在线看| 日韩三级在线观看| 亚洲视频一区二区在线| 麻豆91在线播放| 欧美在线看片a免费观看| 日韩免费观看高清完整版| 亚洲欧美一区二区三区国产精品| 美国三级日本三级久久99| 91片在线免费观看| 久久人人97超碰com| 亚洲成av人片在www色猫咪| 处破女av一区二区| 欧美一级夜夜爽| 亚洲综合色网站| av动漫一区二区| 久久亚洲精华国产精华液| 亚洲成av人片在线观看无码| 99国产精品久久久久久久久久久| 欧美成人精品3d动漫h| 亚洲综合视频在线| 99精品国产99久久久久久白柏| 2023国产一二三区日本精品2022| 亚洲国产精品久久不卡毛片| 91麻豆产精品久久久久久| 中文字幕乱码亚洲精品一区| 国内成+人亚洲+欧美+综合在线| 欧美日韩黄色一区二区| 亚洲男人电影天堂| av动漫一区二区| 日本一二三四高清不卡| 精品一二线国产| 日韩欧美国产精品| 日韩电影在线观看网站| 欧美视频一区在线| 亚洲高清免费在线| 欧美揉bbbbb揉bbbbb| 亚洲综合成人网| 91福利在线观看| 一区二区免费视频| 欧美日韩五月天| 三级不卡在线观看| 日韩你懂的在线观看| 精品一区二区在线视频| 亚洲精品一区在线观看|