您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GlobalRNG函数代码示例

51自学网 2021-06-01 21:18:57
  C++
这篇教程C++ GlobalRNG函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GlobalRNG函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalRNG函数的具体用法?C++ GlobalRNG怎么用?C++ GlobalRNG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GlobalRNG函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ProfileSignatureValidate

bool ProfileSignatureValidate(PK_Signer &priv, PK_Verifier &pub, const byte *input, 	const size_t inputLength, string description, bool thorough = false){	bool pass = true, fail;	fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2);	assert(pass && !fail);	SecByteBlock signature(priv.MaxSignatureLength());	std::chrono::steady_clock::time_point signStartTime = std::chrono::steady_clock::now();	size_t signatureLength = priv.SignMessage(GlobalRNG(), input, inputLength, signature);	std::chrono::steady_clock::time_point signEndTime = std::chrono::steady_clock::now();	size_t signNanoSeconds = std::chrono::duration_cast<std::chrono::nanoseconds>(signEndTime - signStartTime).count();	cout << generateCSVString(description, "sign", signNanoSeconds) << endl;	std::chrono::steady_clock::time_point verifyStartTime = std::chrono::steady_clock::now();	fail = !pub.VerifyMessage(input, inputLength, signature, signatureLength);	std::chrono::steady_clock::time_point verifyEndTime = std::chrono::steady_clock::now();	size_t verifyNanoSeconds = std::chrono::duration_cast<std::chrono::nanoseconds>(verifyEndTime - verifyStartTime).count();	cout << generateCSVString(description, "verify", verifyNanoSeconds) << endl;	assert(pass && !fail);	return pass;}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:27,


示例2: SimpleKeyAgreementValidate

bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d){	if (d.GetCryptoParameters().Validate(GlobalRNG(), 3))		cout << "passed    simple key agreement domain parameters validation" << endl;	else	{		cout << "FAILED    simple key agreement domain parameters invalid" << endl;		return false;	}	SecByteBlock priv1(d.PrivateKeyLength()), priv2(d.PrivateKeyLength());	SecByteBlock pub1(d.PublicKeyLength()), pub2(d.PublicKeyLength());	SecByteBlock val1(d.AgreedValueLength()), val2(d.AgreedValueLength());	d.GenerateKeyPair(GlobalRNG(), priv1, pub1);	d.GenerateKeyPair(GlobalRNG(), priv2, pub2);	memset(val1.begin(), 0x10, val1.size());	memset(val2.begin(), 0x11, val2.size());	if (!(d.Agree(val1, priv1, pub2) && d.Agree(val2, priv2, pub1)))	{		cout << "FAILED    simple key agreement failed" << endl;		return false;	}	if (!VerifyBufsEqual(val1.begin(), val2.begin(), d.AgreedValueLength()))	{		cout << "FAILED    simple agreed values not equal" << endl;		return false;	}	cout << "passed    simple key agreement" << endl;	return true;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:35,


示例3: BenchMarkVerification

void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier &pub, double timeTotal, bool pc=false){	unsigned int len = 16;	AlignedSecByteBlock message(len), signature(pub.SignatureLength());	GlobalRNG().GenerateBlock(message, len);	priv.SignMessage(GlobalRNG(), message, len, signature);	const clock_t start = clock();	unsigned int i;	double timeTaken;	for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++)	{		// The return value is ignored because we are interested in throughput		bool unused = pub.VerifyMessage(message, len, signature, signature.size());		CRYPTOPP_UNUSED(unused);	}	OutputResultOperations(name, "Verification", pc, i, timeTaken);	if (!pc && pub.GetMaterial().SupportsPrecomputation())	{		pub.AccessMaterial().Precompute(16);		BenchMarkVerification(name, priv, pub, timeTotal, true);	}}
开发者ID:Andy-Amoy,项目名称:cryptopp,代码行数:25,


示例4: TestModeIV

bool TestModeIV(SymmetricCipher &e, SymmetricCipher &d){	SecByteBlock lastIV, iv(e.IVSize());	StreamTransformationFilter filter(e, new StreamTransformationFilter(d));	byte plaintext[20480];	for (unsigned int i=1; i<sizeof(plaintext); i*=2)	{		e.GetNextIV(GlobalRNG(), iv);		if (iv == lastIV)			return false;		else			lastIV = iv;		e.Resynchronize(iv);		d.Resynchronize(iv);		unsigned int length = STDMAX(GlobalRNG().GenerateWord32(0, i), (word32)e.MinLastBlockSize());		GlobalRNG().GenerateBlock(plaintext, length);		if (!TestFilter(filter, plaintext, length, plaintext, length))			return false;	}	return true;}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:26,


示例5: CryptoSystemValidate

bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough = false){	bool pass = true, fail;	fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2);	pass = pass && !fail;	cout << (fail ? "FAILED    " : "passed    ");	cout << "cryptosystem key validation/n";	static const byte message[] = "test message";	const int messageLen = COUNTOF(message);	SecByteBlock ciphertext(priv.CiphertextLength(messageLen));	SecByteBlock plaintext(priv.MaxPlaintextLength(ciphertext.size()));	pub.Encrypt(GlobalRNG(), message, messageLen, ciphertext);	fail = priv.Decrypt(GlobalRNG(), ciphertext, priv.CiphertextLength(messageLen), plaintext) != DecodingResult(messageLen);	fail = fail || !VerifyBufsEqual(message, plaintext, messageLen);	pass = pass && !fail;	cout << (fail ? "FAILED    " : "passed    ");	cout << "encryption and decryption/n";	return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:26,


示例6: RandomizedTransfer

void RandomizedTransfer(BufferedTransformation &source, BufferedTransformation &target, bool finish, const std::string &channel=DEFAULT_CHANNEL){	while (source.MaxRetrievable() > (finish ? 0 : 4096))	{		byte buf[4096+64];		size_t start = GlobalRNG().GenerateWord32(0, 63);		size_t len = GlobalRNG().GenerateWord32(1, UnsignedMin(4096U, 3*source.MaxRetrievable()/2));		len = source.Get(buf+start, len);		target.ChannelPut(channel, buf+start, len);	}}
开发者ID:Kthulhu,项目名称:cryptopp,代码行数:11,


示例7: SignatureValidate

bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough = false){	bool pass = true, fail;	fail = !pub.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2) || !priv.GetMaterial().Validate(GlobalRNG(), thorough ? 3 : 2);	pass = pass && !fail;	cout << (fail ? "FAILED    " : "passed    ");	cout << "signature key validation/n";	static const byte message[] = "test message";	const unsigned int messageLen = COUNTOF(message);	SecByteBlock signature(priv.MaxSignatureLength());	size_t signatureLength = priv.SignMessage(GlobalRNG(), message, messageLen, signature);	fail = !pub.VerifyMessage(message, messageLen, signature, signatureLength);	pass = pass && !fail;	cout << (fail ? "FAILED    " : "passed    ");	cout << "signature and verification/n";	++signature[0];	fail = pub.VerifyMessage(message, messageLen, signature, signatureLength);	pass = pass && !fail;	cout << (fail ? "FAILED    " : "passed    ");	cout << "checking invalid signature" << endl;	if (priv.MaxRecoverableLength() > 0)	{		signatureLength = priv.SignMessageWithRecovery(GlobalRNG(), message, messageLen, NULL, 0, signature);		SecByteBlock recovered(priv.MaxRecoverableLengthFromSignatureLength(signatureLength));		DecodingResult result = pub.RecoverMessage(recovered, NULL, 0, signature, signatureLength);		fail = !(result.isValidCoding && result.messageLength == messageLen && VerifyBufsEqual(recovered, message, messageLen));		pass = pass && !fail;		cout << (fail ? "FAILED    " : "passed    ");		cout << "signature and verification with recovery" << endl;		++signature[0];		result = pub.RecoverMessage(recovered, NULL, 0, signature, signatureLength);		fail = result.isValidCoding;		pass = pass && !fail;		cout << (fail ? "FAILED    " : "passed    ");		cout << "recovery with invalid signature" << endl;	}	return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:50,


示例8: TestKeyPairValidAndConsistent

void TestKeyPairValidAndConsistent(CryptoMaterial &pub, const CryptoMaterial &priv){	if (!pub.Validate(GlobalRNG(), 3))		SignalTestFailure();	if (!priv.Validate(GlobalRNG(), 3))		SignalTestFailure();/*	EqualityComparisonFilter comparison;	pub.Save(ChannelSwitch(comparison, "0"));	pub.AssignFrom(priv);	pub.Save(ChannelSwitch(comparison, "1"));	comparison.ChannelMessageSeriesEnd("0");	comparison.ChannelMessageSeriesEnd("1");*/}
开发者ID:gogo40,项目名称:GoGo40-keygen,代码行数:15,


示例9: TestKeyPairValidAndConsistent

void TestKeyPairValidAndConsistent(CryptoMaterial &pub, const CryptoMaterial &priv){	// "!!" converts between bool <-> integral.	if (!pub.Validate(GlobalRNG(), 2U+!!s_thorough))		SignalTestFailure();	if (!priv.Validate(GlobalRNG(), 2U+!!s_thorough))		SignalTestFailure();	ByteQueue bq1, bq2;	pub.Save(bq1);	pub.AssignFrom(priv);	pub.Save(bq2);	if (bq1 != bq2)		SignalTestFailure();}
开发者ID:Kthulhu,项目名称:cryptopp,代码行数:15,


示例10: ValidateECP

bool ValidateECP(){	std::cout << "/nECP validation suite running.../n/n";	ECIES<ECP>::Decryptor cpriv(GlobalRNG(), ASN1::secp192r1());	ECIES<ECP>::Encryptor cpub(cpriv);	ByteQueue bq;	cpriv.GetKey().DEREncode(bq);	cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true);	cpub.GetKey().DEREncode(bq);	ECDSA<ECP, SHA>::Signer spriv(bq);	ECDSA<ECP, SHA>::Verifier spub(bq);	ECDH<ECP>::Domain ecdhc(ASN1::secp192r1());	ECMQV<ECP>::Domain ecmqvc(ASN1::secp192r1());	spriv.AccessKey().Precompute();	ByteQueue queue;	spriv.AccessKey().SavePrecomputation(queue);	spriv.AccessKey().LoadPrecomputation(queue);	bool pass = SignatureValidate(spriv, spub);	cpub.AccessKey().Precompute();	cpriv.AccessKey().Precompute();	pass = CryptoSystemValidate(cpriv, cpub) && pass;	pass = SimpleKeyAgreementValidate(ecdhc) && pass;	pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;	std::cout << "Turning on point compression..." << std::endl;	cpriv.AccessKey().AccessGroupParameters().SetPointCompression(true);	cpub.AccessKey().AccessGroupParameters().SetPointCompression(true);	ecdhc.AccessGroupParameters().SetPointCompression(true);	ecmqvc.AccessGroupParameters().SetPointCompression(true);	pass = CryptoSystemValidate(cpriv, cpub) && pass;	pass = SimpleKeyAgreementValidate(ecdhc) && pass;	pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;	std::cout << "Testing SEC 2, NIST, and Brainpool recommended curves..." << std::endl;	OID oid;	while (!(oid = DL_GroupParameters_EC<ECP>::GetNextRecommendedParametersOID(oid)).m_values.empty())	{		DL_GroupParameters_EC<ECP> params(oid);		bool fail = !params.Validate(GlobalRNG(), 2);		std::cout << (fail ? "FAILED" : "passed") << "    " << std::dec << params.GetCurve().GetField().MaxElementBitLength() << " bits" << std::endl;		pass = pass && !fail;	}	return pass;}
开发者ID:ChunHungLiu,项目名称:Qt-SESAM,代码行数:48,


示例11: ValidateEC2N

bool ValidateEC2N(){	cout << "/nEC2N validation suite running.../n/n";	ECIES<EC2N>::Decryptor cpriv(GlobalRNG(), ASN1::sect193r1());	ECIES<EC2N>::Encryptor cpub(cpriv);	ByteQueue bq;	cpriv.DEREncode(bq);	cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true);	cpub.DEREncode(bq);	ECDSA<EC2N, SHA>::Signer spriv(bq);	ECDSA<EC2N, SHA>::Verifier spub(bq);	ECDH<EC2N>::Domain ecdhc(ASN1::sect193r1());	ECMQV<EC2N>::Domain ecmqvc(ASN1::sect193r1());	spriv.AccessKey().Precompute();	ByteQueue queue;	spriv.AccessKey().SavePrecomputation(queue);	spriv.AccessKey().LoadPrecomputation(queue);	bool pass = SignatureValidate(spriv, spub);	pass = CryptoSystemValidate(cpriv, cpub) && pass;	pass = SimpleKeyAgreementValidate(ecdhc) && pass;	pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;	cout << "Turning on point compression..." << endl;	cpriv.AccessKey().AccessGroupParameters().SetPointCompression(true);	cpub.AccessKey().AccessGroupParameters().SetPointCompression(true);	ecdhc.AccessGroupParameters().SetPointCompression(true);	ecmqvc.AccessGroupParameters().SetPointCompression(true);	pass = CryptoSystemValidate(cpriv, cpub) && pass;	pass = SimpleKeyAgreementValidate(ecdhc) && pass;	pass = AuthenticatedKeyAgreementValidate(ecmqvc) && pass;#if 0	// TODO: turn this back on when I make EC2N faster for pentanomial basis	cout << "Testing SEC 2 recommended curves..." << endl;	OID oid;	while (!(oid = DL_GroupParameters_EC<EC2N>::GetNextRecommendedParametersOID(oid)).m_values.empty())	{		DL_GroupParameters_EC<EC2N> params(oid);		bool fail = !params.Validate(GlobalRNG(), 2);		cout << (fail ? "FAILED" : "passed") << "    " << params.GetCurve().GetField().MaxElementBitLength() << " bits" << endl;		pass = pass && !fail;	}#endif	return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:48,


示例12: RSASignFile

void RSASignFile(const char *privFilename, const char *messageFilename, const char *signatureFilename){	FileSource privFile(privFilename, true);	RSASSA_PKCS1v15_SHA_Signer priv(privFile);	// RSASSA_PKCS1v15_SHA_Signer ignores the rng. Use a real RNG for other signature schemes!	FileSource f(messageFilename, true, new SignerFilter(GlobalRNG(), priv, new FileSink(signatureFilename)));}
开发者ID:geekmaster,项目名称:stepmania-3.9,代码行数:7,


示例13: BenchMarkDecryption

void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub, double timeTotal){	unsigned int len = 16;	SecByteBlock ciphertext(pub.CiphertextLength(len));	SecByteBlock plaintext(pub.MaxPlaintextLength(ciphertext.size()));	GlobalRNG().GenerateBlock(plaintext, len);	pub.Encrypt(GlobalRNG(), plaintext, len, ciphertext);	const clock_t start = clock();	unsigned int i;	double timeTaken;	for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++)		priv.Decrypt(GlobalRNG(), ciphertext, ciphertext.size(), plaintext);	OutputResultOperations(name, "Decryption", false, i, timeTaken);}
开发者ID:Andy-Amoy,项目名称:cryptopp,代码行数:16,


示例14: RSADecryptString

string RSADecryptString(const char *privFilename, const char *ciphertext){	FileSource privFile(privFilename, true, new HexDecoder);	RSAES_OAEP_SHA_Decryptor priv(privFile);	string result;	StringSource(ciphertext, true, new HexDecoder(new PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))));	return result;}
开发者ID:acat,项目名称:emule,代码行数:9,


示例15: BenchMarkAgreement

void BenchMarkAgreement(const char *name, SimpleKeyAgreementDomain &d, double timeTotal, bool pc=false){	SecByteBlock priv1(d.PrivateKeyLength()), priv2(d.PrivateKeyLength());	SecByteBlock pub1(d.PublicKeyLength()), pub2(d.PublicKeyLength());	d.GenerateKeyPair(GlobalRNG(), priv1, pub1);	d.GenerateKeyPair(GlobalRNG(), priv2, pub2);	SecByteBlock val(d.AgreedValueLength());	const clock_t start = clock();	unsigned int i;	double timeTaken;	for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i+=2)	{		d.Agree(val, priv1, pub2);		d.Agree(val, priv2, pub1);	}	OutputResultOperations(name, "Key Agreement", pc, i, timeTaken);}
开发者ID:Andy-Amoy,项目名称:cryptopp,代码行数:19,


示例16: BenchMarkEncryption

void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc=false){	unsigned int len = 16;	SecByteBlock plaintext(len), ciphertext(key.CiphertextLength(len));	GlobalRNG().GenerateBlock(plaintext, len);	const clock_t start = clock();	unsigned int i;	double timeTaken;	for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++)		key.Encrypt(GlobalRNG(), plaintext, len, ciphertext);	OutputResultOperations(name, "Encryption", pc, i, timeTaken);	if (!pc && key.GetMaterial().SupportsPrecomputation())	{		key.AccessMaterial().Precompute(16);		BenchMarkEncryption(name, key, timeTotal, true);	}}
开发者ID:Andy-Amoy,项目名称:cryptopp,代码行数:20,


示例17: BenchMarkSigning

void BenchMarkSigning(const char *name, PK_Signer &key, double timeTotal, bool pc=false){	unsigned int len = 16;	AlignedSecByteBlock message(len), signature(key.SignatureLength());	GlobalRNG().GenerateBlock(message, len);	const clock_t start = clock();	unsigned int i;	double timeTaken;	for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++)		key.SignMessage(GlobalRNG(), message, len, signature);	OutputResultOperations(name, "Signature", pc, i, timeTaken);	if (!pc && key.GetMaterial().SupportsPrecomputation())	{		key.AccessMaterial().Precompute(16);		BenchMarkSigning(name, key, timeTotal, true);	}}
开发者ID:Andy-Amoy,项目名称:cryptopp,代码行数:20,


示例18: ValidateRW

bool ValidateRW(const byte *input, const size_t inputLength, const int secLevelIndex){	string description = generateDetailedDescription("RW", securityLevels[secLevelIndex], 		factorizationGroupSizes[secLevelIndex], inputLength);	RWSS<PSSR, SHA>::Signer priv(GlobalRNG(), factorizationGroupSizes[secLevelIndex]);	RWSS<PSSR, SHA>::Verifier pub(priv);	bool pass = ProfileSignatureValidate(priv, pub, input, inputLength, description);	assert(pass);	return pass;}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:12,


示例19: ValidateLUC_DL

bool ValidateLUC_DL(const byte *input, const size_t inputLength, const int secLevelIndex){	string description = generateDetailedDescription("LUC-DL", securityLevels[secLevelIndex], 		finiteFieldSizes[secLevelIndex], inputLength);	LUC_HMP<SHA>::Signer privS(GlobalRNG(), finiteFieldSizes[secLevelIndex]);	LUC_HMP<SHA>::Verifier pubS(privS);	bool pass = ProfileSignatureValidate(privS, pubS, input, inputLength, description);	assert(pass);	return pass;}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:12,


示例20: ValidateLUC

bool ValidateLUC(const byte *input, const size_t inputLength, const int secLevelIndex){	string description = generateDetailedDescription("LUC", securityLevels[secLevelIndex],		factorizationGroupSizes[secLevelIndex], inputLength);	LUCSSA_PKCS1v15_SHA_Signer priv(GlobalRNG(), factorizationGroupSizes[secLevelIndex]);	LUCSSA_PKCS1v15_SHA_Verifier pub(priv);	bool pass = ProfileSignatureValidate(priv, pub, input, inputLength, description);	assert(pass);	return pass;}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:12,


示例21: ValidateDLIES

bool ValidateDLIES(){	cout << "/nDLIES validation suite running.../n/n";	bool pass = true;	{		FileSource fc("TestData/dlie1024.dat", true, new HexDecoder);		DLIES<>::Decryptor privC(fc);		DLIES<>::Encryptor pubC(privC);		pass = CryptoSystemValidate(privC, pubC) && pass;	}	{		cout << "Generating new encryption key..." << endl;		DLIES<>::GroupParameters gp;		gp.GenerateRandomWithKeySize(GlobalRNG(), 128);		DLIES<>::Decryptor decryptor;		decryptor.AccessKey().GenerateRandom(GlobalRNG(), gp);		DLIES<>::Encryptor encryptor(decryptor);		pass = CryptoSystemValidate(decryptor, encryptor) && pass;	}	return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:22,


示例22: AuthenticatedKeyAgreementValidate

bool AuthenticatedKeyAgreementValidate(AuthenticatedKeyAgreementDomain &d){	if (d.GetCryptoParameters().Validate(GlobalRNG(), 3))		cout << "passed    authenticated key agreement domain parameters validation" << endl;	else	{		cout << "FAILED    authenticated key agreement domain parameters invalid" << endl;		return false;	}	SecByteBlock spriv1(d.StaticPrivateKeyLength()), spriv2(d.StaticPrivateKeyLength());	SecByteBlock epriv1(d.EphemeralPrivateKeyLength()), epriv2(d.EphemeralPrivateKeyLength());	SecByteBlock spub1(d.StaticPublicKeyLength()), spub2(d.StaticPublicKeyLength());	SecByteBlock epub1(d.EphemeralPublicKeyLength()), epub2(d.EphemeralPublicKeyLength());	SecByteBlock val1(d.AgreedValueLength()), val2(d.AgreedValueLength());	d.GenerateStaticKeyPair(GlobalRNG(), spriv1, spub1);	d.GenerateStaticKeyPair(GlobalRNG(), spriv2, spub2);	d.GenerateEphemeralKeyPair(GlobalRNG(), epriv1, epub1);	d.GenerateEphemeralKeyPair(GlobalRNG(), epriv2, epub2);	memset(val1.begin(), 0x10, val1.size());	memset(val2.begin(), 0x11, val2.size());	if (!(d.Agree(val1, spriv1, epriv1, spub2, epub2) && d.Agree(val2, spriv2, epriv2, spub1, epub1)))	{		cout << "FAILED    authenticated key agreement failed" << endl;		return false;	}	if (!VerifyBufsEqual(val1.begin(), val2.begin(), d.AgreedValueLength()))	{		cout << "FAILED    authenticated agreed values not equal" << endl;		return false;	}	cout << "passed    authenticated key agreement" << endl;	return true;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:39,


示例23: ValidateNR

bool ValidateNR(const byte *input, const size_t inputLength, const int secLevelIndex){	string description = generateDetailedDescription("NR", securityLevels[secLevelIndex], 		factorizationGroupSizes[secLevelIndex], inputLength);	NR<SHA>::Signer privS(GlobalRNG(), finiteFieldSubgroupSizes[secLevelIndex]);	privS.AccessKey().Precompute();	NR<SHA>::Verifier pubS(privS);	bool pass = ProfileSignatureValidate(privS, pubS, input, inputLength, description);	assert(pass);	return pass;}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:13,


示例24: TestFilter

bool TestFilter(BufferedTransformation &bt, const byte *in, size_t inLen, const byte *out, size_t outLen){	FilterTester *ft;	bt.Attach(ft = new FilterTester(out, outLen));	while (inLen)	{		size_t randomLen = GlobalRNG().GenerateWord32(0, (word32)inLen);		bt.Put(in, randomLen);		in += randomLen;		inLen -= randomLen;	}	bt.MessageEnd();	return ft->GetResult();}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:15,


示例25: BenchMarkKeyGen

void BenchMarkKeyGen(const char *name, AuthenticatedKeyAgreementDomain &d, double timeTotal, bool pc=false){	SecByteBlock priv(d.EphemeralPrivateKeyLength()), pub(d.EphemeralPublicKeyLength());	const clock_t start = clock();	unsigned int i;	double timeTaken;	for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++)		d.GenerateEphemeralKeyPair(GlobalRNG(), priv, pub);	OutputResultOperations(name, "Key-Pair Generation", pc, i, timeTaken);	if (!pc && d.GetMaterial().SupportsPrecomputation())	{		d.AccessMaterial().Precompute(16);		BenchMarkKeyGen(name, d, timeTotal, true);	}}
开发者ID:Andy-Amoy,项目名称:cryptopp,代码行数:18,


示例26: ValidateRSA

bool ValidateRSA(const byte *input, const size_t inputLength, const int secLevelIndex){	string description = generateDetailedDescription("RSA", securityLevels[secLevelIndex], 		factorizationGroupSizes[secLevelIndex], inputLength);	// FileSource keys("TestData/rsa512a.dat", true, new HexDecoder);	// FileSource keys("mykey.pem", true, new HexDecoder);	// Weak::RSASSA_PKCS1v15_MD2_Signer rsaPriv(keys);	Weak::RSASSA_PKCS1v15_MD2_Signer rsaPriv(GlobalRNG(), factorizationGroupSizes[secLevelIndex]);	Weak::RSASSA_PKCS1v15_MD2_Verifier rsaPub(rsaPriv);	bool pass = ProfileSignatureValidate(rsaPriv, rsaPub, input, inputLength, description);	assert(pass);	return pass;}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:18,


示例27: ValidateRabin

bool ValidateRabin(){	cout << "/nRabin validation suite running.../n/n";	bool pass=true;	{		FileSource f("TestData/rabi1024.dat", true, new HexDecoder);		RabinSS<PSSR, SHA>::Signer priv(f);		RabinSS<PSSR, SHA>::Verifier pub(priv);		pass = SignatureValidate(priv, pub) && pass;	}	{		RabinES<OAEP<SHA> >::Decryptor priv(GlobalRNG(), 512);		RabinES<OAEP<SHA> >::Encryptor pub(priv);		pass = CryptoSystemValidate(priv, pub) && pass;	}	return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:18,


示例28: ValidateLUC

bool ValidateLUC(){	cout << "/nLUC validation suite running.../n/n";	bool pass=true;	{		FileSource f("TestData/luc1024.dat", true, new HexDecoder);		LUCSSA_PKCS1v15_SHA_Signer priv(f);		LUCSSA_PKCS1v15_SHA_Verifier pub(priv);		pass = SignatureValidate(priv, pub) && pass;	}	{		LUCES_OAEP_SHA_Decryptor priv(GlobalRNG(), 512);		LUCES_OAEP_SHA_Encryptor pub(priv);		pass = CryptoSystemValidate(priv, pub) && pass;	}	return pass;}
开发者ID:hovatterz,项目名称:cryptopp,代码行数:18,


示例29: BenchMark

void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal){	const int BUF_SIZE=RoundUpToMultipleOf(2048U, cipher.OptimalBlockSize());	AlignedSecByteBlock buf(BUF_SIZE);	GlobalRNG().GenerateBlock(buf, BUF_SIZE);	clock_t start = clock();	unsigned long i=0, blocks=1;	double timeTaken;	do	{		blocks *= 2;		for (; i<blocks; i++)			cipher.ProcessString(buf, BUF_SIZE);		timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;	}	while (timeTaken < 2.0/3*timeTotal);	OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);}
开发者ID:CryptoDJ,项目名称:DarkSilk-Release-Candidate,代码行数:20,



注:本文中的GlobalRNG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GlobalReAlloc函数代码示例
C++ GlobalMemoryStatusEx函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。