Skip to content

Commit

Permalink
Update sm4_ctrtest.c
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed Apr 28, 2024
1 parent 6e8a36c commit 33c546f
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions tests/sm4_ctrtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,46 +358,13 @@ static int test_sm4_ctr_ctx_multi_updates(void)
return 1;
}

extern void sm4_ctr32_encrypt_4blocks(const SM4_KEY *key, uint8_t iv[16], const uint8_t *in, size_t num_4blocks, uint8_t *out);


static int test_sm4_ctr32_encrypt_blocks_speed(void)
{
SM4_KEY sm4_key;
uint8_t key[16];
uint8_t ctr[16];
uint8_t buf[4096];
clock_t begin, end;
double seconds;
int i;

memset(key, 0, sizeof(key));
memset(ctr, 0, sizeof(ctr));
memset(buf, 0, sizeof(buf));

sm4_set_encrypt_key(&sm4_key, key);

begin = clock();
for (i = 0; i < 4096; i++) {
sm4_ctr32_encrypt_4blocks(&sm4_key, ctr, buf, sizeof(buf)/64, buf);
}
end = clock();

seconds = (double)(end - begin)/CLOCKS_PER_SEC;
printf("%s: %f MiB per second\n", __FUNCTION__, 16/seconds);

return 1;
}

int main(void)
{
if (test_sm4_ctr() != 1) goto err;
if (test_sm4_ctr_test_vectors() != 1) goto err;
if (test_sm4_ctr_with_carray() != 1) goto err;
if (test_sm4_ctr_ctx() != 1) goto err;
if (test_sm4_ctr_ctx_multi_updates() != 1) goto err;

if (test_sm4_ctr32_encrypt_blocks_speed() != 1) goto err;
printf("%s all tests passed\n", __FILE__);
return 0;
err:
Expand Down

0 comments on commit 33c546f

Please sign in to comment.