Ejemplo n.º 1
0
	void CreateRandomDHKeysPair (DHKeysPair * keys)
	{
		if (!keys) return;
		CryptoPP::AutoSeededRandomPool rnd;
		CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
		dh.GenerateKeyPair(rnd, keys->privateKey, keys->publicKey);
	}
Ejemplo n.º 2
0
	RouterContext::RouterContext ()
	{
		if (!Load ())
			CreateNewRouter ();
		Save ();

		// we generate LeaseSet at every start-up
		CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
		dh.GenerateKeyPair(m_Rnd, m_LeaseSetPrivateKey, m_LeaseSetPublicKey);
	}	
Ejemplo n.º 3
0
	Keys CreateRandomKeys ()
	{
		Keys keys;		
		auto& rnd = i2p::context.GetRandomNumberGenerator ();
		// encryption
		CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
		dh.GenerateKeyPair(rnd, keys.privateKey, keys.publicKey);
		// signing
		i2p::crypto::CreateDSARandomKeys (rnd, keys.signingPrivateKey, keys.signingKey);	
		return keys;
	}	
Ejemplo n.º 4
0
	PrivateKeys PrivateKeys::CreateRandomKeys (SigningKeyType type)
	{
		if (type == SIGNING_KEY_TYPE_ECDSA_SHA256_P256)
		{
			PrivateKeys keys;
			auto& rnd = i2p::context.GetRandomNumberGenerator ();
			// encryption
			uint8_t publicKey[256];
			CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
			dh.GenerateKeyPair(rnd, keys.m_PrivateKey, publicKey);
			// signature
			uint8_t signingPublicKey[64];
			i2p::crypto::CreateECDSAP256RandomKeys (rnd, keys.m_SigningPrivateKey, signingPublicKey);
			keys.m_Public = IdentityEx (publicKey, signingPublicKey, SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
			keys.CreateSigner ();
			return keys;
		}	
		return PrivateKeys (i2p::data::CreateRandomKeys ()); // DSA-SHA1
	}	
Ejemplo n.º 5
0
	Keys CreateRandomKeys ()
	{
		Keys keys;		
		CryptoPP::AutoSeededRandomPool rnd;

		// encryption
		CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg);
		dh.GenerateKeyPair(rnd, keys.privateKey, keys.publicKey);

		// signing
		CryptoPP::DSA::PrivateKey privateKey;
		CryptoPP::DSA::PublicKey publicKey;
		privateKey.Initialize (rnd, i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag);
		privateKey.MakePublicKey (publicKey);
		privateKey.GetPrivateExponent ().Encode (keys.signingPrivateKey, 20);	
		publicKey.GetPublicElement ().Encode (keys.signingKey, 128);
		
		return keys;
	}