Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libkae: fix build warning on aarch64 #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions alg/pkey/hpre_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ static int hpre_rsa_public_encrypt(int flen, const unsigned char *from,
BIGNUM *ret_bn = NULL;
hpre_engine_ctx_t *eng_ctx = NULL;
unsigned char *in_buf = NULL;
BN_CTX *bn_ctx = NULL;
int num_bytes = 0;

if (hpre_rsa_check_para(flen, from, to, rsa) != HPRE_CRYPTO_SUCC) {
return HPRE_CRYPTO_FAIL;
Expand All @@ -285,13 +287,13 @@ static int hpre_rsa_public_encrypt(int flen, const unsigned char *from,
GOTOEND_IF(ret != HPRE_CRYPTO_SUCC, "check public key fail",
KAE_F_HPRE_RSA_PUBENC, KAE_R_PUBLIC_KEY_INVALID);

BN_CTX *bn_ctx = BN_CTX_new();
bn_ctx = BN_CTX_new();
GOTOEND_IF(bn_ctx == NULL, "bn_ctx MALLOC FAILED!",
KAE_F_HPRE_RSA_PUBENC, KAE_R_MALLOC_FAILURE);

BN_CTX_start(bn_ctx);
ret_bn = BN_CTX_get(bn_ctx);
int num_bytes = BN_num_bytes(n);
num_bytes = BN_num_bytes(n);
in_buf = (unsigned char *)OPENSSL_malloc(num_bytes);
GOTOEND_IF(ret_bn == NULL || in_buf == NULL, "PUBLIC_ENCRYPT RSA MALLOC FAILED!",
KAE_F_HPRE_RSA_PUBENC, KAE_R_MALLOC_FAILURE);
Expand Down Expand Up @@ -349,6 +351,8 @@ static int hpre_rsa_private_encrypt(int flen, const unsigned char *from,
const BIGNUM *dmq1 = (const BIGNUM *)NULL;
const BIGNUM *iqmp = (const BIGNUM *)NULL;
unsigned char *in_buf = (unsigned char *)NULL;
BN_CTX *bn_ctx = NULL;
int num_bytes = 0;

if (hpre_rsa_check_para(flen, from, to, rsa) != HPRE_CRYPTO_SUCC) {
return HPRE_CRYPTO_FAIL;
Expand All @@ -367,7 +371,7 @@ static int hpre_rsa_private_encrypt(int flen, const unsigned char *from,
goto end_soft;
}

BN_CTX *bn_ctx = BN_CTX_new();
bn_ctx = BN_CTX_new();
GOTOEND_IF(bn_ctx == NULL, "PRI_ENC MALLOC_FAILURE ",
KAE_F_HPRE_RSA_PRIENC, KAE_R_MALLOC_FAILURE);

Expand All @@ -378,7 +382,7 @@ static int hpre_rsa_private_encrypt(int flen, const unsigned char *from,
RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
int version = RSA_get_version(rsa);
RSA_get0_key(rsa, &n, &e, &d);
int num_bytes = BN_num_bytes(n);
num_bytes = BN_num_bytes(n);
in_buf = (unsigned char *)OPENSSL_malloc(num_bytes);
GOTOEND_IF(bn_ret == NULL || in_buf == NULL, "OpenSSL malloc failure",
KAE_F_HPRE_RSA_PRIENC, KAE_R_MALLOC_FAILURE);
Expand Down
5 changes: 3 additions & 2 deletions utils/engine_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ void ENGINE_LOG_LIMIT(int level, int times, int limit, const char *fmt, ...)
fprintf(g_kae_debug_log_file, "\n");
if (ftell(g_kae_debug_log_file) > KAE_LOG_MAX_SIZE) {
kae_save_log(g_kae_debug_log_file);
ftruncate(g_kae_debug_log_file->_fileno, 0);
fseek(g_kae_debug_log_file, 0, SEEK_SET);
if (ftruncate(g_kae_debug_log_file->_fileno, 0) == 0) {
fseek(g_kae_debug_log_file, 0, SEEK_SET);
}
}
pthread_mutex_unlock(&g_debug_file_mutex);
flock(g_kae_debug_log_file->_fileno, LOCK_UN);
Expand Down
5 changes: 3 additions & 2 deletions utils/engine_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ void ENGINE_LOG_LIMIT(int level, int times, int limit, const char *fmt, ...);
} \
if (ftell(g_kae_debug_log_file) > KAE_LOG_MAX_SIZE) { \
kae_save_log(g_kae_debug_log_file); \
ftruncate(g_kae_debug_log_file->_fileno, 0); \
fseek(g_kae_debug_log_file, 0, SEEK_SET); \
if (ftruncate(g_kae_debug_log_file->_fileno, 0) == 0) { \
fseek(g_kae_debug_log_file, 0, SEEK_SET); \
} \
} \
pthread_mutex_unlock(&g_debug_file_mutex); \
flock(g_kae_debug_log_file->_fileno, LOCK_UN); \
Expand Down