int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key,
- unsigned char *iv, unsigned char *ciphertext, int ctr)
+ unsigned char *iv, unsigned char *ciphertext, int ctr, int index)
{
EVP_CIPHER_CTX *ctx;
* EVP_EncryptUpdate can be called multiple times if necessary
*/
- if(1 != EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len))
- handleErrors();
- ciphertext_len = len;
-
-
+ static double time=0;
+ double t=0;
+ t=TimeStart();
+// for(int i=0;i<nb_test;i++)
+ {
+
+
+ if(1 != EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len))
+ handleErrors();
+ ciphertext_len = len;
+
+ }
+ time+=TimeStop(t);
+ if(index==nb_test-1)
+ printf("Time encrypt %f\n",time);
+
}
int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key,
- unsigned char *iv, unsigned char *plaintext, int ctr)
+ unsigned char *iv, unsigned char *plaintext, int ctr, int index)
{
EVP_CIPHER_CTX *ctx;
* EVP_DecryptUpdate can be called multiple times if necessary
*/
-
- if(1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
- handleErrors();
- plaintext_len = len;
+ static double time=0;
+ double t=0;
+ t=TimeStart();
+
+// for(int i=0;i<nb_test;i++)
+ {
+ if(1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
+ handleErrors();
+ plaintext_len = len;
+ }
+ time+=TimeStop(t);
+ if(index==nb_test-1)
+ printf("Time decrypt %f\n",time);
+
/* Finalise the decryption. Further plaintext bytes may be written at
* this stage.
*/
if(strncmp(argv[i],"lena",4)==0) lena = atoi(&(argv[i][4])); //Use Lena or buffer
}
- printf("nb times %d\n",nb_test);
+/* printf("nb times %d\n",nb_test);
printf("ctr %d\n",ctr);
printf("lena %d\n",lena);
printf("size_buf %d\n",size_buf);
-
+*/
OpenSSL_add_all_algorithms();
OPENSSL_config(NULL);
*/
- double time=0;
+
+
+ double time=0;
double t=TimeStart();
for(i=0;i<nb_test;i++)
{
ciphertext_len = encrypt (plaintext, imsize, key, iv,
- ciphertext, ctr);
+ ciphertext, ctr, i );
}
time+=TimeStop(t);
{
/* Decrypt the ciphertext */
decryptedtext_len = decrypt(ciphertext, ciphertext_len, key, iv,
- decryptedtext,ctr);
+ decryptedtext,ctr, i);
}
time+=TimeStop(t);