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(); }
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); }