예제 #1
0
파일: RSATest.cpp 프로젝트: rayfill/cpplib
	void keyCreateTest()
	{
		const unsigned int bitLength = 256;
		KeyPair pair = RSA::makeKeyPair(bitLength);
		
		CPPUNIT_ASSERT(
			pair.getPublicKey().getEncryptExponent().getBitLength() == 17);
		CPPUNIT_ASSERT(
			pair.getPublicKey().getModulus() ==
			pair.getPrivateKey().getModulus());
		
		PublicKey pubKey = pair.getPublicKey();
		PrivateKey privKey = pair.getPrivateKey();
	}
예제 #2
0
파일: RSATest.cpp 프로젝트: rayfill/cpplib
	void endecryptTest()
	{
		const unsigned int bitLength = 128;
		KeyPair pair = RSA::makeKeyPair(bitLength);
		
		PublicKey pubKey = pair.getPublicKey();
		PrivateKey privKey = pair.getPrivateKey();

		RSA cipher(pubKey, privKey);
		MPInteger plaintext("12fbff45836b");
		MPInteger ciphertext = cipher.encrypt(plaintext);
		MPInteger decrypttext = cipher.decrypt(ciphertext);

		CPPUNIT_ASSERT(plaintext == decrypttext);
	}