Clean code

This commit is contained in:
Zhi Guan
2024-06-13 12:18:40 +08:00
parent ed6b7f926e
commit 18ac39ebe3
3 changed files with 3 additions and 10 deletions

View File

@@ -117,7 +117,6 @@ int sm4_cbc_encrypt_update(SM4_CBC_CTX *ctx,
}
memcpy(ctx->block + ctx->block_nbytes, in, left);
sm4_cbc_encrypt_blocks(&ctx->sm4_key, ctx->iv, ctx->block, 1, out);
//memcpy(ctx->iv, out, SM4_BLOCK_SIZE);
in += left;
inlen -= left;
out += SM4_BLOCK_SIZE;
@@ -127,10 +126,8 @@ int sm4_cbc_encrypt_update(SM4_CBC_CTX *ctx,
nblocks = inlen / SM4_BLOCK_SIZE;
len = nblocks * SM4_BLOCK_SIZE;
sm4_cbc_encrypt_blocks(&ctx->sm4_key, ctx->iv, in, nblocks, out);
//memcpy(ctx->iv, out + len - SM4_BLOCK_SIZE, SM4_BLOCK_SIZE);
in += len;
inlen -= len;
out += len;
*outlen += len;
}
if (inlen) {
@@ -214,7 +211,6 @@ int sm4_cbc_decrypt_update(SM4_CBC_CTX *ctx,
sm4_cbc_decrypt_blocks(&ctx->sm4_key, ctx->iv, in, nblocks, out);
in += len;
inlen -= len;
out += len;
*outlen += len;
}
memcpy(ctx->block, in, inlen);

View File

@@ -103,7 +103,6 @@ int sm4_ctr_encrypt_update(SM4_CTR_CTX *ctx,
sm4_ctr_encrypt_blocks(&ctx->sm4_key, ctx->ctr, in, nblocks, out);
in += len;
inlen -= len;
out += len;
*outlen += len;
}
if (inlen) {
@@ -187,7 +186,6 @@ int sm4_ctr32_encrypt_update(SM4_CTR_CTX *ctx,
sm4_ctr32_encrypt_blocks(&ctx->sm4_key, ctx->ctr, in, nblocks, out);
in += len;
inlen -= len;
out += len;
*outlen += len;
}
if (inlen) {

View File

@@ -342,13 +342,12 @@ static int speed_sm4_gcm_encrypt(void)
return 1;
}
int main(void)
{
// if (test_sm4_gcm() != 1) goto err;
// if (test_sm4_gcm_gbt36624_1() != 1) goto err;
if (test_sm4_gcm() != 1) goto err;
if (test_sm4_gcm_gbt36624_1() != 1) goto err;
if (test_sm4_gcm_gbt36624_2() != 1) goto err;
// if (test_sm4_gcm_ctx() != 1) goto err;
if (test_sm4_gcm_ctx() != 1) goto err;
#if ENABLE_TEST_SPEED
if (speed_sm4_gcm_encrypt() != 1) goto err;
#endif