void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc=false) { unsigned int len = 16; LC_RNG rng(time(NULL)); SecByteBlock plaintext(len), ciphertext(key.CipherTextLength(len)); rng.GetBlock(plaintext, len); 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(rng, plaintext, len, ciphertext); OutputResultOperations(name, "Encryption", pc, i, timeTaken); }
void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub, double timeTotal) { unsigned int len = 16; LC_RNG rng(time(NULL)); SecByteBlock ciphertext(pub.CipherTextLength(len)); SecByteBlock plaintext(pub.MaxPlainTextLength(ciphertext.size)); rng.GetBlock(plaintext, len); pub.Encrypt(rng, plaintext, len, ciphertext); 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(ciphertext, ciphertext.size, plaintext); OutputResultOperations(name, "Decryption", false, i, timeTaken); }