remove warnings

This commit is contained in:
Zhi Guan
2020-06-19 15:56:33 +08:00
parent ec29454f1d
commit 5a000d0998
42 changed files with 6607 additions and 5928 deletions

View File

@@ -248,7 +248,7 @@ int SM2_encrypt(int type, const unsigned char *in, size_t inlen,
if (!out) {
*outlen = clen;
return 1;
} else if (*outlen < clen) {
} else if (*outlen < (size_t)clen) {
SM2err(SM2_F_SM2_ENCRYPT, SM2_R_BUFFER_TOO_SMALL);
return 0;
}

View File

@@ -563,7 +563,7 @@ int SM2_KAP_final_check(SM2_KAP_CTX *ctx, const unsigned char *checksum,
size_t checksumlen)
{
if (ctx->do_checksum) {
if (checksumlen != EVP_MD_size(ctx->checksum_md)) {
if (checksumlen != (size_t)EVP_MD_size(ctx->checksum_md)) {
ECerr(EC_F_SM2_KAP_FINAL_CHECK, EC_R_INVALID_SM2_KAP_CHECKSUM_LENGTH);
return 0;
}
@@ -581,6 +581,18 @@ int SM2_compute_share_key(unsigned char *out, size_t *outlen,
const EC_POINT *peer_pk, const unsigned char *peer_z, size_t peer_zlen,
const unsigned char *z, size_t zlen, EC_KEY *sk, int initiator)
{
memset(out, 1, *outlen);
return 1;
(void)out;
(void)outlen;
(void)peer_ephem;
(void)ephem;
(void)peer_pk;
(void)peer_z;
(void)peer_zlen;
(void)z;
(void)zlen;
(void)sk;
(void)initiator;
ECerr(EC_F_SM2_COMPUTE_SHARE_KEY, EC_R_NOT_IMPLEMENTED);
return 0;
}

View File

@@ -231,7 +231,7 @@ int SM2_compute_id_digest(const EVP_MD *md, const char *id, size_t idlen,
*outlen = EVP_MD_size(md);
return 1;
}
if (*outlen < EVP_MD_size(md)) {
if (*outlen < (size_t)EVP_MD_size(md)) {
ECerr(EC_F_SM2_COMPUTE_ID_DIGEST, EC_R_BUFFER_TOO_SMALL);
return 0;
}

View File

@@ -96,26 +96,3 @@ struct sm2_kap_ctx_st {
};
int SM2_ciphertext_size(const EC_KEY *ec_key, size_t inlen);
struct SM2_COSIGNER1_SHARE_st {
BIGNUM *a;
BIGNUM *b;
};
struct SM2_COSIGNER2_SHARE_st {
BIGNUM *a;
BIGNUM *b;
};
struct SM2_COSIGNER1_PROOF_st {
BIGNUM *a;
BIGNUM *b;
};
struct SM2_COSIGNER2_PROOF_st {
BIGNUM *a;
BIGNUM *b;
};

View File

@@ -67,6 +67,12 @@ static void sm2_sign_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
BN_clear_free(bn);
CRYPTO_set_ex_data(ad, sm2_sign_idx, NULL);
}
(void)parent;
(void)ptr;
(void)idx;
(void)argl;
(void)argp;
}
static int sm2_sign_setup(EC_KEY *ec_key, BN_CTX *ctx_in, BIGNUM **kp, BIGNUM **xp)
@@ -542,6 +548,10 @@ int SM2_sign_ex(int type, const unsigned char *dgst, int dgstlen,
{
ECDSA_SIG *s;
if (type != NID_undef) {
return 0;
}
RAND_seed(dgst, dgstlen);
if (!(s = SM2_do_sign_ex(dgst, dgstlen, k, x, ec_key))) {
@@ -570,6 +580,10 @@ int SM2_verify(int type, const unsigned char *dgst, int dgstlen,
int derlen = -1;
int ret = -1;
if (type != NID_undef) {
return ret;
}
if (!(s = ECDSA_SIG_new())) {
return ret;
}