
From: Hao Fang <fanghao11@huawei.com> Some tiny fixes for add a blank line before return. Signed-off-by: Hao Fang <fanghao11@huawei.com> Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com> --- src/uadk_cipher.c | 1 + src/uadk_digest.c | 4 ++++ src/uadk_ec.c | 4 ++++ src/uadk_engine_init.c | 1 + src/uadk_prov_aead.c | 1 + src/uadk_prov_cipher.c | 6 ++++++ src/uadk_prov_dh.c | 2 ++ src/uadk_prov_digest.c | 1 + src/uadk_prov_ec_kmgmt.c | 1 + src/uadk_prov_ecdh_exch.c | 2 ++ src/uadk_prov_ffc.c | 9 +++++++++ src/uadk_prov_hmac.c | 2 ++ src/uadk_prov_packet.c | 1 + src/uadk_prov_packet.h | 4 ++++ src/uadk_prov_rsa.c | 2 ++ src/uadk_prov_sm2.c | 1 + src/uadk_sm2.c | 7 +++++++ 17 files changed, 49 insertions(+) diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index b0e9dbe..441bef2 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -576,6 +576,7 @@ static int do_cipher_sync(struct cipher_priv_ctx *priv) ret = wd_do_cipher_sync(priv->sess, &priv->req); if (ret) return 0; + return 1; } diff --git a/src/uadk_digest.c b/src/uadk_digest.c index 48b6e4b..60691a6 100644 --- a/src/uadk_digest.c +++ b/src/uadk_digest.c @@ -254,6 +254,7 @@ static int uadk_e_digests_soft_md(struct digest_priv_ctx *priv) priv->soft_ctx = ctx; priv->app_datasize = app_datasize; } + return 1; } @@ -268,6 +269,7 @@ static uint32_t sec_digest_get_sw_threshold(int n_id) } while (++i < threshold_table_size); fprintf(stderr, "nid %d not found in digest threshold table.\n", n_id); + return 0; } @@ -568,6 +570,7 @@ static int uadk_e_digest_ctrl(EVP_MD_CTX *ctx, int cmd, int numa_node, void *p2) } priv->sched_param.numa_id = numa_node; priv->setup.sched_param = (void *)&(priv->sched_param); + return 1; } @@ -821,6 +824,7 @@ static int do_digest_sync(struct digest_priv_ctx *priv) fprintf(stderr, "do sec digest sync failed, switch to soft digest.\n"); return 0; } + return 1; } diff --git a/src/uadk_ec.c b/src/uadk_ec.c index d15e742..f9ca847 100644 --- a/src/uadk_ec.c +++ b/src/uadk_ec.c @@ -313,6 +313,7 @@ static int ecdsa_do_sign_check(EC_KEY *eckey, fprintf(stderr, "priv_key is NULL\n"); return -1; } + return 0; } @@ -394,6 +395,7 @@ static int ecdsa_sign_init_iot(handle_t sess, struct wd_ecc_req *req, } uadk_ecc_fill_req(req, WD_ECDSA_SIGN, ecc_in, ecc_out); + return 0; err: wd_ecc_del_out(sess, ecc_out); @@ -898,6 +900,7 @@ static int eckey_create_key(EC_KEY *eckey) fprintf(stderr, "failed to set private key\n"); BN_free(priv_key); + return ret; } @@ -1466,6 +1469,7 @@ int uadk_ec_create_pmeth(struct uadk_pkey_meth *pkey_meth) EVP_PKEY_meth_copy(meth, openssl_meth); pkey_meth->ec = meth; + return 1; } diff --git a/src/uadk_engine_init.c b/src/uadk_engine_init.c index 1a2b1d4..6fad2d9 100644 --- a/src/uadk_engine_init.c +++ b/src/uadk_engine_init.c @@ -167,6 +167,7 @@ int uadk_e_set_env(const char *var_name, int numa_id) if (ret < 0) return ret; } + return 0; } diff --git a/src/uadk_prov_aead.c b/src/uadk_prov_aead.c index 4709e52..88cf927 100644 --- a/src/uadk_prov_aead.c +++ b/src/uadk_prov_aead.c @@ -1052,6 +1052,7 @@ static int uadk_prov_aead_get_ctx_params(void *vctx, OSSL_PARAM params[]) return UADK_OSSL_FAIL; } } + return UADK_AEAD_SUCCESS; } diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c index aa2d0b6..94ce518 100644 --- a/src/uadk_prov_cipher.c +++ b/src/uadk_prov_cipher.c @@ -188,6 +188,7 @@ static const char *ossl_cipher_cbc_cts_mode_id2name(unsigned int id) if (cts_modes[i].id == id) return cts_modes[i].ossl_mode_name; } + return NULL; } @@ -199,6 +200,7 @@ static int ossl_cipher_cbc_cts_mode_name2id(const char *name) if (OPENSSL_strcasecmp(name, cts_modes[i].ossl_mode_name) == 0) return (int)cts_modes[i].id; } + return -1; } @@ -408,6 +410,7 @@ static int uadk_get_cipher_info(struct cipher_priv_ctx *priv) } fprintf(stderr, "failed to get cipher info.\n"); + return UADK_P_FAIL; } @@ -720,6 +723,7 @@ static int ossl_cipher_unpadblock(unsigned char *buf, size_t *buflen, size_t blo } } *buflen = len; + return UADK_P_SUCCESS; } @@ -1062,6 +1066,7 @@ do_soft: } fprintf(stderr, "do soft ciphers failed.\n"); + return UADK_P_FAIL; } @@ -1077,6 +1082,7 @@ static int uadk_prov_cipher_stream_final(void *vctx, unsigned char *out, return uadk_prov_cipher_soft_final(priv, out, outl); *outl = 0; + return UADK_P_SUCCESS; } diff --git a/src/uadk_prov_dh.c b/src/uadk_prov_dh.c index 9e9ed1a..e6984be 100644 --- a/src/uadk_prov_dh.c +++ b/src/uadk_prov_dh.c @@ -484,6 +484,7 @@ static int uadk_dh_gen_prikey_undef(const DH *dh, BIGNUM *new_prikey) fprintf(stderr, "failed to BN_priv_rand\n"); return UADK_P_FAIL; } + return UADK_P_SUCCESS; } @@ -538,6 +539,7 @@ static int dh_gen_rand_prikey(const DH *dh, BIGNUM *new_prikey) } while (1); BN_free(two_powN); + return UADK_P_SUCCESS; err: BN_free(two_powN); diff --git a/src/uadk_prov_digest.c b/src/uadk_prov_digest.c index dbecdc2..a40dfe4 100644 --- a/src/uadk_prov_digest.c +++ b/src/uadk_prov_digest.c @@ -515,6 +515,7 @@ do_soft_digest: } fprintf(stderr, "do soft digest failed during updating!\n"); + return UADK_DIGEST_FAIL; out: diff --git a/src/uadk_prov_ec_kmgmt.c b/src/uadk_prov_ec_kmgmt.c index 01bcc50..01cf644 100644 --- a/src/uadk_prov_ec_kmgmt.c +++ b/src/uadk_prov_ec_kmgmt.c @@ -328,6 +328,7 @@ static void *uadk_ec_sw_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg) return NULL; fprintf(stderr, "switch to openssl software calculation in ecx generation.\n"); + return get_default_ec_keymgmt().gen(genctx, osslcb, cbarg); } diff --git a/src/uadk_prov_ecdh_exch.c b/src/uadk_prov_ecdh_exch.c index a59316c..4102ac1 100644 --- a/src/uadk_prov_ecdh_exch.c +++ b/src/uadk_prov_ecdh_exch.c @@ -455,6 +455,7 @@ static int uadk_ecdh_sw_derive(void *vpecdhctx, unsigned char *secret, return UADK_P_FAIL; fprintf(stderr, "switch to openssl software calculation in ecdh derivation.\n"); + return get_default_ecdh_keyexch().derive(vpecdhctx, secret, psecretlen, outlen); } @@ -484,6 +485,7 @@ static int uadk_keyexch_ecdh_derive(void *vpecdhctx, unsigned char *secret, return UADK_P_SUCCESS; if (ret == UADK_DO_SOFT) return uadk_ecdh_sw_derive(vpecdhctx, secret, psecretlen, outlen); + return UADK_P_FAIL; } diff --git a/src/uadk_prov_ffc.c b/src/uadk_prov_ffc.c index f617c92..0b23186 100644 --- a/src/uadk_prov_ffc.c +++ b/src/uadk_prov_ffc.c @@ -809,6 +809,7 @@ static int generate_unverifiable_g(BN_CTX *ctx, BN_MONT_CTX *mont, BIGNUM *g, ++h; } *hret = h; + return 1; } @@ -941,6 +942,7 @@ static OSSL_LIB_CTX *ossl_bn_get_libctx(BN_CTX *ctx) { if (ctx == NULL) return NULL; + return ctx->libctx; } @@ -1071,6 +1073,7 @@ static int ossl_ffc_params_set_validate_params(FFC_PARAMS *params, if (!ossl_ffc_params_set_seed(params, seed, seedlen)) return 0; params->pcounter = counter; + return 1; } @@ -1082,6 +1085,7 @@ static const char *default_mdname(size_t N) return "SHA-224"; else if (N == N_Q_256BITS) return "SHA-256"; + return NULL; } @@ -1112,6 +1116,7 @@ static int ossl_ffc_params_validate_unverifiable_g(BN_CTX *ctx, BN_MONT_CTX *mon *ret |= FFC_ERROR_NOT_SUITABLE_GENERATOR; return 0; } + return 1; } @@ -1514,6 +1519,7 @@ static int generate_canonical_g(BN_CTX *ctx, BN_MONT_CTX *mont, } EVP_MD_CTX_free(mctx); + return ret; } @@ -1924,6 +1930,7 @@ static uint32_t ilog_e(uint64_t v) } } r = (r * (uint64_t)DH_C1_923) / DH_LOG_E; + return r; } @@ -1948,6 +1955,7 @@ static uint64_t icbrt64(uint64_t x) r++; } } + return r * DH_CBRT_SCALE; } @@ -2009,5 +2017,6 @@ uint16_t ossl_ifc_ffc_compute_security_bits(int n) y = (y + DH_CAI_NUM4) & ~DH_CAI_NUM7; if (y > cap) y = cap; + return y; } diff --git a/src/uadk_prov_hmac.c b/src/uadk_prov_hmac.c index e15592c..b764582 100644 --- a/src/uadk_prov_hmac.c +++ b/src/uadk_prov_hmac.c @@ -362,6 +362,7 @@ static int uadk_get_hmac_info(struct hmac_priv_ctx *priv) } fprintf(stderr, "failed to get hmac info, algname = %s.\n", priv->alg_name); + return UADK_HMAC_FAIL; } @@ -391,6 +392,7 @@ static const char *get_uadk_alg_name(__u32 alg_id) } fprintf(stderr, "failed to find alg, nid = %u.\n", alg_id); + return NULL; } diff --git a/src/uadk_prov_packet.c b/src/uadk_prov_packet.c index 19099db..d944442 100644 --- a/src/uadk_prov_packet.c +++ b/src/uadk_prov_packet.c @@ -24,6 +24,7 @@ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes) pkt->written += len; pkt->curr += len; + return 1; } diff --git a/src/uadk_prov_packet.h b/src/uadk_prov_packet.h index 0f798cd..03d678b 100644 --- a/src/uadk_prov_packet.h +++ b/src/uadk_prov_packet.h @@ -94,6 +94,7 @@ __owur static ossl_inline int PACKET_buf_init(PACKET *pkt, pkt->curr = buf; pkt->remaining = len; + return 1; } @@ -114,6 +115,7 @@ __owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, { if (PACKET_remaining(pkt) != num) return 0; + return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; } @@ -485,6 +487,7 @@ __owur static ossl_inline int PACKET_memdup(const PACKET *pkt, return 0; *len = length; + return 1; } @@ -504,6 +507,7 @@ __owur static ossl_inline int PACKET_strndup(const PACKET *pkt, char **data) /* This will succeed on an empty packet, unless pkt->curr == NULL. */ *data = OPENSSL_strndup((const char *)pkt->curr, PACKET_remaining(pkt)); + return (*data != NULL); } diff --git a/src/uadk_prov_rsa.c b/src/uadk_prov_rsa.c index f8342bc..4376c85 100644 --- a/src/uadk_prov_rsa.c +++ b/src/uadk_prov_rsa.c @@ -2016,6 +2016,7 @@ static int uadk_rsa_sw_verify(void *vprsactx, const unsigned char *sig, return UADK_E_FAIL; fprintf(stderr, "switch to openssl software calculation in verifaction.\n"); + return get_default_rsa_signature().verify(vprsactx, sig, siglen, tbs, tbslen); } @@ -2735,6 +2736,7 @@ static int uadk_rsa_sw_encrypt(void *vprsactx, unsigned char *out, return UADK_E_FAIL; fprintf(stderr, "switch to openssl software calculation in rsa encryption.\n"); + return get_default_rsa_asym_cipher().encrypt(vprsactx, out, outlen, outsize, in, inlen); } diff --git a/src/uadk_prov_sm2.c b/src/uadk_prov_sm2.c index 414b2b8..b0fc42b 100644 --- a/src/uadk_prov_sm2.c +++ b/src/uadk_prov_sm2.c @@ -720,6 +720,7 @@ static UADK_PKEY_SIGNATURE get_default_sm2_signature(void) } } pthread_mutex_unlock(&sign_mutex); + return s_signature; } diff --git a/src/uadk_sm2.c b/src/uadk_sm2.c index 3eb5252..761038a 100644 --- a/src/uadk_sm2.c +++ b/src/uadk_sm2.c @@ -250,6 +250,7 @@ static int update_public_key(EVP_PKEY_CTX *ctx) return ret; smctx->pubkey = point; + return 0; } @@ -275,6 +276,7 @@ static int update_private_key(EVP_PKEY_CTX *ctx) return ret; smctx->prikey = d; + return 0; } @@ -413,6 +415,7 @@ static int sign_bin_to_ber(EC_KEY *ec, struct wd_dtb *r, struct wd_dtb *s, *siglen = (size_t)sltmp; ECDSA_SIG_free(e_sig); + return 0; free_s: @@ -776,6 +779,7 @@ do_soft: if (ret != UADK_DO_SOFT) return ret; fprintf(stderr, "switch to execute openssl software calculation.\n"); + return openssl_sign(ctx, sig, siglen, tbs, tbslen); } @@ -907,6 +911,7 @@ static int sm2_encrypt_init_iot(handle_t sess, struct wd_ecc_req *req, } uadk_ecc_fill_req(req, WD_SM2_ENCRYPT, ecc_in, ecc_out); + return 0; } @@ -1176,6 +1181,7 @@ do_soft: return ret; fprintf(stderr, "switch to execute openssl software calculation.\n"); + return openssl_decrypt(ctx, out, outlen, in_soft, inlen); } @@ -1324,6 +1330,7 @@ set_data: return 0; EVP_PKEY_CTX_set_data(ctx, smctx); + return 1; } -- 2.33.0