Remove cl building warnings

This commit is contained in:
Zhi Guan
2024-05-13 15:52:59 +08:00
parent 623fe136b3
commit e17df320be
16 changed files with 20 additions and 42 deletions

View File

@@ -59,7 +59,7 @@ int format_print(FILE *fp, int format, int indent, const char *str, ...)
int format_bytes(FILE *fp, int format, int indent, const char *str, const uint8_t *data, size_t datalen)
{
int i;
size_t i;
if (datalen > (1<<24)) {
error_print();

View File

@@ -142,6 +142,11 @@ int sm2_do_encrypt_ex(const SM2_KEY *key, const SM2_ENC_PRE_COMP *pre_comp,
uint8_t x2y2[64];
SM3_CTX sm3_ctx;
if (inlen < 1 || inlen > SM2_MAX_PLAINTEXT_SIZE) {
error_print();
return -1;
}
// output C1
out->point = pre_comp->C1;
@@ -159,7 +164,7 @@ int sm2_do_encrypt_ex(const SM2_KEY *key, const SM2_ENC_PRE_COMP *pre_comp,
// output C2 = M xor t
gmssl_memxor(out->ciphertext, out->ciphertext, in, inlen);
out->ciphertext_size = (uint32_t)inlen;
out->ciphertext_size = (uint8_t)inlen;
// output C3 = Hash(x2 || m || y2)
sm3_init(&sm3_ctx);
@@ -182,7 +187,7 @@ int sm2_do_encrypt(const SM2_KEY *key, const uint8_t *in, size_t inlen, SM2_CIPH
uint8_t x2y2[64];
SM3_CTX sm3_ctx;
if (!(SM2_MIN_PLAINTEXT_SIZE <= inlen && inlen <= SM2_MAX_PLAINTEXT_SIZE)) {
if (inlen < 1 || inlen > SM2_MAX_PLAINTEXT_SIZE) {
error_print();
return -1;
}
@@ -214,7 +219,7 @@ retry:
// output C2 = M xor t
gmssl_memxor(out->ciphertext, out->ciphertext, in, inlen);
out->ciphertext_size = (uint32_t)inlen;
out->ciphertext_size = (uint8_t)inlen;
// output C3 = Hash(x2 || m || y2)
sm3_init(&sm3_ctx);
@@ -238,7 +243,7 @@ int sm2_do_encrypt_fixlen(const SM2_KEY *key, const uint8_t *in, size_t inlen, i
uint8_t x2y2[64];
SM3_CTX sm3_ctx;
if (!(SM2_MIN_PLAINTEXT_SIZE <= inlen && inlen <= SM2_MAX_PLAINTEXT_SIZE)) {
if (inlen < 1 || inlen > SM2_MAX_PLAINTEXT_SIZE) {
error_print();
return -1;
}
@@ -295,7 +300,7 @@ retry:
// output C2 = M xor t
gmssl_memxor(out->ciphertext, out->ciphertext, in, inlen);
out->ciphertext_size = (uint32_t)inlen;
out->ciphertext_size = (uint8_t)inlen;
// output C3 = Hash(x2 || m || y2)
sm3_init(&sm3_ctx);

View File

@@ -178,7 +178,6 @@ int sm2_fast_sign_pre_compute(SM2_SIGN_PRE_COMP pre_comp[32])
int sm2_fast_sign(const sm2_z256_t fast_private, SM2_SIGN_PRE_COMP *pre_comp,
const uint8_t dgst[32], SM2_SIGNATURE *sig)
{
SM2_Z256_POINT R;
sm2_z256_t e;
sm2_z256_t r;
sm2_z256_t s;
@@ -504,8 +503,6 @@ int sm2_compute_z(uint8_t z[32], const SM2_Z256_POINT *pub, const char *id, size
int sm2_sign_init(SM2_SIGN_CTX *ctx, const SM2_KEY *key, const char *id, size_t idlen)
{
size_t i;
if (!ctx || !key) {
error_print();
return -1;

View File

@@ -74,7 +74,7 @@ int sm4_ccm_encrypt(const SM4_KEY *sm4_key, const uint8_t *iv, size_t ivlen,
}
inlen_size = 15 - ivlen;
if (inlen_size < 8 && inlen >= (1 << (inlen_size * 8))) {
if (inlen_size < 8 && inlen >= ((size_t)1 << (inlen_size * 8))) {
error_print();
return -1;
}

View File

@@ -165,10 +165,7 @@ int sm4_xts_encrypt_update(SM4_XTS_CTX *ctx,
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen)
{
size_t DATA_UNIT_SIZE = ctx->data_unit_size;
size_t left;
size_t nblocks;
size_t len;
if (ctx->block_nbytes >= DATA_UNIT_SIZE) {
error_print();
@@ -253,10 +250,7 @@ int sm4_xts_decrypt_update(SM4_XTS_CTX *ctx,
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen)
{
size_t DATA_UNIT_SIZE = ctx->data_unit_size;
size_t left;
size_t nblocks;
size_t len;
if (ctx->block_nbytes >= DATA_UNIT_SIZE) {
error_print();

View File

@@ -42,7 +42,7 @@ static const size_t x509_crl_reason_names_count =
const char *x509_crl_reason_name(int reason)
{
if (reason < 0 || reason >= x509_crl_reason_names_count) {
if (reason < 0 || reason >= (int)x509_crl_reason_names_count) {
error_print();
return NULL;
}
@@ -51,7 +51,7 @@ const char *x509_crl_reason_name(int reason)
int x509_crl_reason_from_name(int *reason, const char *name)
{
int i;
size_t i;
for (i = 0; i < x509_crl_reason_names_count; i++) {
if (strcmp(name, x509_crl_reason_names[i]) == 0) {
*reason = i;

View File

@@ -1216,7 +1216,7 @@ static size_t x509_key_usages_count =
const char *x509_key_usage_name(int flag)
{
int i;
size_t i;
for (i = 0; i < x509_key_usages_count; i++) {
if (flag & 1) {
if (flag >> 1) {
@@ -1233,7 +1233,7 @@ const char *x509_key_usage_name(int flag)
int x509_key_usage_from_name(int *flag, const char *name)
{
int i;
size_t i;
for (i = 0; i < x509_key_usages_count; i++) {
if (strcmp(name, x509_key_usages[i]) == 0) {
*flag = 1 << i;
@@ -2527,7 +2527,7 @@ static size_t x509_revoke_reason_flags_count =
const char *x509_revoke_reason_flag_name(int flag)
{
int i;
size_t i;
for (i = 0; i < x509_revoke_reason_flags_count; i++) {
if (flag & 1) {
if (flag >> 1) {
@@ -2543,7 +2543,7 @@ const char *x509_revoke_reason_flag_name(int flag)
int x509_revoke_reason_flag_from_name(int *flag, const char *name)
{
int i;
size_t i;
for (i = 0; i < x509_revoke_reason_flags_count; i++) {
if (strcmp(name, x509_revoke_reason_flags[i]) == 0) {
*flag = 1 << i;

View File

@@ -49,7 +49,7 @@ static int test_sm2_ciphertext(void)
}
sm2_z256_point_to_bytes(&sm2_key.public_key, (uint8_t *)&(C.point));
C.ciphertext_size = tests[i].ciphertext_size;
C.ciphertext_size = (uint8_t)tests[i].ciphertext_size;
if (sm2_ciphertext_to_der(&C, &p, &len) != 1) {
error_print();
@@ -176,7 +176,6 @@ static int test_sm2_encrypt_fixlen(void)
};
SM2_KEY sm2_key;
size_t point_size;
uint8_t plaintext[SM2_MAX_PLAINTEXT_SIZE];
uint8_t encrypted[SM2_MAX_CIPHERTEXT_SIZE];
uint8_t decrypted[SM2_MAX_PLAINTEXT_SIZE];

View File

@@ -103,9 +103,7 @@ static int test_sm4_ccm_test_vectors(void)
SM4_KEY sm4_key;
uint8_t *encrypted;
size_t encrypted_len;
uint8_t *decrypted;
size_t decrypted_len;
uint8_t mac[16];
size_t i;

View File

@@ -107,9 +107,7 @@ static int test_sm4_cfb_test_vectors(void)
SM4_KEY sm4_key;
uint8_t *encrypted;
size_t encrypted_len;
uint8_t *decrypted;
size_t decrypted_len;
size_t i;
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {

View File

@@ -98,9 +98,7 @@ static int test_sm4_ofb_test_vectors(void)
SM4_KEY sm4_key;
uint8_t *encrypted;
size_t encrypted_len;
uint8_t *decrypted;
size_t decrypted_len;
size_t i;
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {

View File

@@ -93,19 +93,13 @@ static int test_sm4_xts_test_vectors(void)
size_t key_len;
uint8_t iv[16];
size_t iv_len;
uint8_t *aad;
size_t aad_len;
uint8_t tag[16];
size_t tag_len;
uint8_t *plaintext;
size_t plaintext_len;
uint8_t *ciphertext;
size_t ciphertext_len;
uint8_t *encrypted;
size_t encrypted_len;
uint8_t *decrypted;
size_t decrypted_len;
size_t i;
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {

View File

@@ -799,7 +799,7 @@ int test_sm9_z256_exchange()
SM9_Z256_TWIST_POINT de;
SM9_Z256_POINT RA, RB;
sm9_z256_t rA;
int i, j = 1;
size_t i, j = 1;
uint8_t idA[5] = {0x41, 0x6C, 0x69, 0x63, 0x65};
uint8_t idB[3] = {0x42, 0x6F, 0x62};

View File

@@ -45,8 +45,6 @@ int sm4_ecb_main(int argc, char **argv)
char *outfile = NULL;
uint8_t key[16];
size_t keylen;
uint8_t iv[16];
size_t ivlen;
FILE *infp = stdin;
FILE *outfp = stdout;
SM4_ECB_CTX ctx;
@@ -182,7 +180,6 @@ bad:
end:
gmssl_secure_clear(key, sizeof(key));
gmssl_secure_clear(iv, sizeof(iv));
gmssl_secure_clear(&ctx, sizeof(ctx));
gmssl_secure_clear(buf, sizeof(buf));
if (infile && infp) fclose(infp);

View File

@@ -40,7 +40,6 @@ int tls12_server_main(int argc , char **argv)
tls_socket_t conn_sock;
struct sockaddr_in server_addr;
struct sockaddr_in client_addr;
tls_socklen_t client_addrlen;
argc--;
argv++;

View File

@@ -38,7 +38,6 @@ int tls13_server_main(int argc , char **argv)
tls_socket_t conn_sock;
struct sockaddr_in server_addr;
struct sockaddr_in client_addr;
tls_socklen_t client_addrlen;
argc--;
argv++;