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

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

?? gf2n.cpp

?? 研讀AxCrypt對加解密的處理方法
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
{
	unsigned i, smallerSize = STDMIN(reg.size(), rhs.reg.size());

	for (i=0; i<smallerSize; i++)
		if (reg[i] != rhs.reg[i]) return false;

	for (i=smallerSize; i<reg.size(); i++)
		if (reg[i] != 0) return false;

	for (i=smallerSize; i<rhs.reg.size(); i++)
		if (rhs.reg[i] != 0) return false;

	return true;
}

std::ostream& operator<<(std::ostream& out, const PolynomialMod2 &a)
{
	// Get relevant conversion specifications from ostream.
	long f = out.flags() & std::ios::basefield;	// Get base digits.
	int bits, block;
	char suffix;
	switch(f)
	{
	case std::ios::oct :
		bits = 3;
		block = 4;
		suffix = 'o';
		break;
	case std::ios::hex :
		bits = 4;
		block = 2;
		suffix = 'h';
		break;
	default :
		bits = 1;
		block = 8;
		suffix = 'b';
	}

	if (!a)
		return out << '0' << suffix;

	SecBlock<char> s(a.BitCount()/bits+1);
	unsigned i;
	const char vec[]="0123456789ABCDEF";

	for (i=0; i*bits < a.BitCount(); i++)
	{
		int digit=0;
		for (int j=0; j<bits; j++)
			digit |= a[i*bits+j] << j;
		s[i]=vec[digit];
	}

	while (i--)
	{
		out << s[i];
		if (i && (i%block)==0)
			out << ',';
	}

	return out << suffix;
}

PolynomialMod2 PolynomialMod2::Gcd(const PolynomialMod2 &a, const PolynomialMod2 &b)
{
	return EuclideanDomainOf<PolynomialMod2>().Gcd(a, b);
}

PolynomialMod2 PolynomialMod2::InverseMod(const PolynomialMod2 &modulus) const
{
	typedef EuclideanDomainOf<PolynomialMod2> Domain;
	return QuotientRing<Domain>(Domain(), modulus).MultiplicativeInverse(*this);
}

bool PolynomialMod2::IsIrreducible() const
{
	signed int d = Degree();
	if (d <= 0)
		return false;

	PolynomialMod2 t(2), u(t);
	for (int i=1; i<=d/2; i++)
	{
		u = u.Squared()%(*this);
		if (!Gcd(u+t, *this).IsUnit())
			return false;
	}
	return true;
}

// ********************************************************

GF2NP::GF2NP(const PolynomialMod2 &modulus)
	: QuotientRing<EuclideanDomainOf<PolynomialMod2> >(EuclideanDomainOf<PolynomialMod2>(), modulus), m(modulus.Degree()) 
{
}

GF2NP::Element GF2NP::SquareRoot(const Element &a) const
{
	Element r = a;
	for (unsigned int i=1; i<m; i++)
		r = Square(r);
	return r;
}

GF2NP::Element GF2NP::HalfTrace(const Element &a) const
{
	assert(m%2 == 1);
	Element h = a;
	for (unsigned int i=1; i<=(m-1)/2; i++)
		h = Add(Square(Square(h)), a);
	return h;
}

GF2NP::Element GF2NP::SolveQuadraticEquation(const Element &a) const
{
	if (m%2 == 0)
	{
		Element z, w;
		RandomPool rng;
		do
		{
			Element p((RandomNumberGenerator &)rng, m);
			z = PolynomialMod2::Zero();
			w = p;
			for (unsigned int i=1; i<=m-1; i++)
			{
				w = Square(w);
				z = Square(z);
				Accumulate(z, Multiply(w, a));
				Accumulate(w, p);
			}
		} while (w.IsZero());
		return z;
	}
	else
		return HalfTrace(a);
}

// ********************************************************

GF2NT::GF2NT(unsigned int t0, unsigned int t1, unsigned int t2)
	: GF2NP(PolynomialMod2::Trinomial(t0, t1, t2))
	, t0(t0), t1(t1)
	, result((word)0, m)
{
	assert(t0 > t1 && t1 > t2 && t2==0);
}

const GF2NT::Element& GF2NT::MultiplicativeInverse(const Element &a) const
{
	if (t0-t1 < WORD_BITS)
		return GF2NP::MultiplicativeInverse(a);

	SecWordBlock T(m_modulus.reg.size() * 4);
	word *b = T;
	word *c = T+m_modulus.reg.size();
	word *f = T+2*m_modulus.reg.size();
	word *g = T+3*m_modulus.reg.size();
	unsigned int bcLen=1, fgLen=m_modulus.reg.size();
	unsigned int k=0;

	SetWords(T, 0, 3*m_modulus.reg.size());
	b[0]=1;
	assert(a.reg.size() <= m_modulus.reg.size());
	CopyWords(f, a.reg, a.reg.size());
	CopyWords(g, m_modulus.reg, m_modulus.reg.size());

	while (1)
	{
		word t=f[0];
		while (!t)
		{
			ShiftWordsRightByWords(f, fgLen, 1);
			if (c[bcLen-1])
				bcLen++;
			assert(bcLen <= m_modulus.reg.size());
			ShiftWordsLeftByWords(c, bcLen, 1);
			k+=WORD_BITS;
			t=f[0];
		}

		unsigned int i=0;
		while (t%2 == 0)
		{
			t>>=1;
			i++;
		}
		k+=i;

		if (t==1 && CountWords(f, fgLen)==1)
			break;

		if (i==1)
		{
			ShiftWordsRightByBits(f, fgLen, 1);
			t=ShiftWordsLeftByBits(c, bcLen, 1);
		}
		else
		{
			ShiftWordsRightByBits(f, fgLen, i);
			t=ShiftWordsLeftByBits(c, bcLen, i);
		}
		if (t)
		{
			c[bcLen] = t;
			bcLen++;
			assert(bcLen <= m_modulus.reg.size());
		}

		if (f[fgLen-1]==0 && g[fgLen-1]==0)
			fgLen--;

		if (f[fgLen-1] < g[fgLen-1])
		{
			std::swap(f, g);
			std::swap(b, c);
		}

		XorWords(f, g, fgLen);
		XorWords(b, c, bcLen);
	}

	while (k >= WORD_BITS)
	{
		word temp = b[0];
		// right shift b
		for (unsigned i=0; i+1<BitsToWords(m); i++)
			b[i] = b[i+1];
		b[BitsToWords(m)-1] = 0;

		if (t1 < WORD_BITS)
			for (unsigned int j=0; j<WORD_BITS-t1; j++)
				temp ^= ((temp >> j) & 1) << (t1 + j);
		else
			b[t1/WORD_BITS-1] ^= temp << t1%WORD_BITS;

		if (t1 % WORD_BITS)
			b[t1/WORD_BITS] ^= temp >> (WORD_BITS - t1%WORD_BITS);

		if (t0%WORD_BITS)
		{
			b[t0/WORD_BITS-1] ^= temp << t0%WORD_BITS;
			b[t0/WORD_BITS] ^= temp >> (WORD_BITS - t0%WORD_BITS);
		}
		else
			b[t0/WORD_BITS-1] ^= temp;

		k -= WORD_BITS;
	}

	if (k)
	{
		word temp = b[0] << (WORD_BITS - k);
		ShiftWordsRightByBits(b, BitsToWords(m), k);

		if (t1 < WORD_BITS)
			for (unsigned int j=0; j<WORD_BITS-t1; j++)
				temp ^= ((temp >> j) & 1) << (t1 + j);
		else
			b[t1/WORD_BITS-1] ^= temp << t1%WORD_BITS;

		if (t1 % WORD_BITS)
			b[t1/WORD_BITS] ^= temp >> (WORD_BITS - t1%WORD_BITS);

		if (t0%WORD_BITS)
		{
			b[t0/WORD_BITS-1] ^= temp << t0%WORD_BITS;
			b[t0/WORD_BITS] ^= temp >> (WORD_BITS - t0%WORD_BITS);
		}
		else
			b[t0/WORD_BITS-1] ^= temp;
	}

	CopyWords(result.reg.begin(), b, result.reg.size());
	return result;
}

const GF2NT::Element& GF2NT::Multiply(const Element &a, const Element &b) const
{
	unsigned int aSize = STDMIN(a.reg.size(), result.reg.size());
	Element r((word)0, m);

	for (int i=m-1; i>=0; i--)
	{
		if (r[m-1])
		{
			ShiftWordsLeftByBits(r.reg.begin(), r.reg.size(), 1);
			XorWords(r.reg.begin(), m_modulus.reg, r.reg.size());
		}
		else
			ShiftWordsLeftByBits(r.reg.begin(), r.reg.size(), 1);

		if (b[i])
			XorWords(r.reg.begin(), a.reg, aSize);
	}

	if (m%WORD_BITS)
		r.reg.begin()[r.reg.size()-1] = (word)Crop(r.reg[r.reg.size()-1], m%WORD_BITS);

	CopyWords(result.reg.begin(), r.reg.begin(), result.reg.size());
	return result;
}

const GF2NT::Element& GF2NT::Reduced(const Element &a) const
{
	if (t0-t1 < WORD_BITS)
		return m_domain.Mod(a, m_modulus);

	SecWordBlock b(a.reg);

	unsigned i;
	for (i=b.size()-1; i>=BitsToWords(t0); i--)
	{
		word temp = b[i];

		if (t0%WORD_BITS)
		{
			b[i-t0/WORD_BITS] ^= temp >> t0%WORD_BITS;
			b[i-t0/WORD_BITS-1] ^= temp << (WORD_BITS - t0%WORD_BITS);
		}
		else
			b[i-t0/WORD_BITS] ^= temp;

		if ((t0-t1)%WORD_BITS)
		{
			b[i-(t0-t1)/WORD_BITS] ^= temp >> (t0-t1)%WORD_BITS;
			b[i-(t0-t1)/WORD_BITS-1] ^= temp << (WORD_BITS - (t0-t1)%WORD_BITS);
		}
		else
			b[i-(t0-t1)/WORD_BITS] ^= temp;
	}

	if (i==BitsToWords(t0)-1 && t0%WORD_BITS)
	{
		word mask = ((word)1<<(t0%WORD_BITS))-1;
		word temp = b[i] & ~mask;
		b[i] &= mask;

		b[i-t0/WORD_BITS] ^= temp >> t0%WORD_BITS;

		if ((t0-t1)%WORD_BITS)
		{
			b[i-(t0-t1)/WORD_BITS] ^= temp >> (t0-t1)%WORD_BITS;
			if ((t0-t1)%WORD_BITS > t0%WORD_BITS)
				b[i-(t0-t1)/WORD_BITS-1] ^= temp << (WORD_BITS - (t0-t1)%WORD_BITS);
			else
				assert(temp << (WORD_BITS - (t0-t1)%WORD_BITS) == 0);
		}
		else
			b[i-(t0-t1)/WORD_BITS] ^= temp;
	}

	SetWords(result.reg.begin(), 0, result.reg.size());
	CopyWords(result.reg.begin(), b, STDMIN(b.size(), result.reg.size()));
	return result;
}

void GF2NP::DEREncodeElement(BufferedTransformation &out, const Element &a) const
{
	a.DEREncodeAsOctetString(out, MaxElementByteLength());
}

void GF2NP::BERDecodeElement(BufferedTransformation &in, Element &a) const
{
	a.BERDecodeAsOctetString(in, MaxElementByteLength());
}

void GF2NT::DEREncode(BufferedTransformation &bt) const
{
	DERSequenceEncoder seq(bt);
		ASN1::characteristic_two_field().DEREncode(seq);
		DERSequenceEncoder parameters(seq);
			DEREncodeUnsigned(parameters, m);
			ASN1::tpBasis().DEREncode(parameters);
			DEREncodeUnsigned(parameters, t1);
		parameters.MessageEnd();
	seq.MessageEnd();
}

void GF2NPP::DEREncode(BufferedTransformation &bt) const
{
	DERSequenceEncoder seq(bt);
		ASN1::characteristic_two_field().DEREncode(seq);
		DERSequenceEncoder parameters(seq);
			DEREncodeUnsigned(parameters, m);
			ASN1::ppBasis().DEREncode(parameters);
			DERSequenceEncoder pentanomial(parameters);
				DEREncodeUnsigned(pentanomial, t3);
				DEREncodeUnsigned(pentanomial, t2);
				DEREncodeUnsigned(pentanomial, t1);
			pentanomial.MessageEnd();
		parameters.MessageEnd();
	seq.MessageEnd();
}

GF2NP * BERDecodeGF2NP(BufferedTransformation &bt)
{
	// VC60 workaround: auto_ptr lacks reset()
	member_ptr<GF2NP> result;

	BERSequenceDecoder seq(bt);
		if (OID(seq) != ASN1::characteristic_two_field())
			BERDecodeError();
		BERSequenceDecoder parameters(seq);
			unsigned int m;
			BERDecodeUnsigned(parameters, m);
			OID oid(parameters);
			if (oid == ASN1::tpBasis())
			{
				unsigned int t1;
				BERDecodeUnsigned(parameters, t1);
				result.reset(new GF2NT(m, t1, 0));
			}
			else if (oid == ASN1::ppBasis())
			{
				unsigned int t1, t2, t3;
				BERSequenceDecoder pentanomial(parameters);
				BERDecodeUnsigned(pentanomial, t3);
				BERDecodeUnsigned(pentanomial, t2);
				BERDecodeUnsigned(pentanomial, t1);
				pentanomial.MessageEnd();
				result.reset(new GF2NPP(m, t3, t2, t1, 0));
			}
			else
			{
				BERDecodeError();
				return NULL;
			}
		parameters.MessageEnd();
	seq.MessageEnd();

	return result.release();
}

NAMESPACE_END

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩亚洲综合在线 欧美亚洲特黄一级| 秋霞电影一区二区| 亚洲va韩国va欧美va精品| 老司机精品视频线观看86| 一本大道综合伊人精品热热| 精品国产污污免费网站入口| 一区二区三区中文在线观看| 国产在线精品免费| 91麻豆精品91久久久久同性| 一区免费观看视频| 国产美女久久久久| 3d成人h动漫网站入口| 亚洲乱码国产乱码精品精可以看 | 蜜桃av一区二区| 欧美在线免费视屏| 亚洲另类色综合网站| 国产成人a级片| 久久久久久久久久美女| 蜜桃视频第一区免费观看| 欧美日韩成人一区| 一区二区三区四区不卡视频 | 亚洲欧美综合色| 国产一区91精品张津瑜| 欧美区在线观看| 亚洲女与黑人做爰| 91浏览器在线视频| 亚洲区小说区图片区qvod| 99久久国产综合精品女不卡| 欧美极品xxx| 国产成人鲁色资源国产91色综| 日韩欧美国产高清| 日本欧洲一区二区| 欧美成人a视频| 久久99精品国产91久久来源| 日韩欧美在线一区二区三区| 日韩高清欧美激情| 日韩视频123| 韩国女主播成人在线观看| 欧美精品一区二区三区一线天视频| 日本成人中文字幕在线视频 | 久久er精品视频| 日韩天堂在线观看| 狠狠色狠狠色综合系列| 久久蜜桃av一区精品变态类天堂| 国产福利不卡视频| 自拍视频在线观看一区二区| 在线观看日韩国产| 亚洲6080在线| 精品日本一线二线三线不卡| 国产成人精品免费一区二区| 日韩一区在线播放| 欧美日韩一区二区三区在线看| 日韩精品一级二级| 精品国产乱码久久久久久久| 成人精品一区二区三区中文字幕 | 在线一区二区三区做爰视频网站| 亚洲伊人色欲综合网| 欧美一级精品在线| 国产成人在线免费观看| 亚洲欧美日韩国产一区二区三区| 欧美日韩视频专区在线播放| a美女胸又www黄视频久久| 亚洲成a人在线观看| 日韩一区二区三区视频| 国产电影一区二区三区| 亚洲伦理在线精品| 欧美刺激午夜性久久久久久久 | 亚洲人成网站影音先锋播放| 欧美日韩久久一区| 丁香一区二区三区| 亚洲国产三级在线| 国产三级一区二区| 欧美怡红院视频| 国产一区二区调教| 亚洲一二三四区不卡| 久久久国产精华| 欧美在线免费播放| 成人黄色电影在线 | 久久久影视传媒| 91成人网在线| 成人免费视频一区二区| 日韩成人免费在线| 亚洲综合成人在线| 国产精品视频免费| 精品久久久久久久人人人人传媒| 色综合中文字幕国产 | 7777精品伊人久久久大香线蕉的 | 成人免费av网站| 毛片av一区二区| 亚洲一区二区3| 中文字幕成人在线观看| 日韩精品一区二区三区视频| 欧美亚洲愉拍一区二区| 国产+成+人+亚洲欧洲自线| 蜜臀av一区二区在线免费观看| 亚洲欧美日韩国产一区二区三区| 久久久青草青青国产亚洲免观| 欧美老肥妇做.爰bbww视频| 色悠悠久久综合| yourporn久久国产精品| 精品一区二区三区在线观看| 亚洲国产日韩一级| 亚洲自拍偷拍麻豆| 亚洲美女在线一区| 日韩毛片高清在线播放| 欧美国产精品专区| 国产欧美一区二区三区在线看蜜臀| 91精品国产色综合久久ai换脸| 91成人国产精品| 日本久久电影网| 91香蕉视频mp4| 91免费在线播放| 91免费版pro下载短视频| 成人午夜视频网站| www.99精品| 中文字幕成人av| 欧美激情在线看| 自拍偷拍国产亚洲| 一区二区三区精品久久久| 亚洲精品视频在线观看网站| 亚洲精品欧美激情| 一区二区三区日本| 亚洲制服丝袜在线| 亚洲va天堂va国产va久| 日韩精品每日更新| 精品一区二区精品| 国产河南妇女毛片精品久久久| 九九精品视频在线看| 国产裸体歌舞团一区二区| 国产成人综合网站| 色激情天天射综合网| 欧美日韩视频在线观看一区二区三区 | 136国产福利精品导航| 亚洲三级免费电影| 亚洲超碰精品一区二区| 日本麻豆一区二区三区视频| 国内成人免费视频| a4yy欧美一区二区三区| 欧美又粗又大又爽| 日韩一区二区三区三四区视频在线观看| 欧美成人福利视频| 国产精品免费免费| 亚洲国产你懂的| 久久99热99| 成人av第一页| 欧美精品日韩综合在线| 久久免费精品国产久精品久久久久| 日本一区二区免费在线| 亚洲一区免费在线观看| 激情综合色综合久久综合| 99久久久国产精品| 欧美一级午夜免费电影| 亚洲国产精品精华液ab| 性做久久久久久免费观看| 国产精品一区二区黑丝| 日本韩国欧美国产| 久久精品视频在线免费观看| 一区二区三区精品视频在线| 狠狠狠色丁香婷婷综合激情| 91啪九色porn原创视频在线观看| 欧美一区二区视频观看视频| 综合在线观看色| 经典一区二区三区| 欧美猛男超大videosgay| 国产精品欧美极品| 蜜桃视频免费观看一区| 欧洲一区在线电影| 欧美激情艳妇裸体舞| 美女在线一区二区| 欧美视频第二页| 中文字幕一区二区三区蜜月| 久久精品国内一区二区三区| 欧美少妇bbb| 亚洲日本在线天堂| 国产99久久久久| 久久久久青草大香线综合精品| 亚洲国产精品久久人人爱| 99re这里只有精品6| 国产亚洲成aⅴ人片在线观看 | 国产日韩精品一区| 青青草国产成人av片免费 | 麻豆精品在线视频| 99久精品国产| 国产精品美女久久久久久2018| 亚洲成a人在线观看| 顶级嫩模精品视频在线看| 精品电影一区二区| 亚洲国产精品久久一线不卡| 粗大黑人巨茎大战欧美成人| 国产精品18久久久久| 日韩美女主播在线视频一区二区三区| 中文字幕制服丝袜成人av| 蜜桃免费网站一区二区三区 | 成人午夜在线免费| 日韩欧美国产成人一区二区| 亚洲午夜免费视频| 欧美系列日韩一区| 中文字幕一区二区三区四区| 国产成人免费视频网站 | 欧美日韩精品欧美日韩精品一综合|