Skip to content

Commit

Permalink
[code] fix size_t to int cast to comply to openssl signature EVP_Decr…
Browse files Browse the repository at this point in the history
…yptUpdate EVP_CIPHER_CTX_ctrl EVP_EncryptUpdate
  • Loading branch information
Pierre Bodilis committed Jan 21, 2025
1 parent f0108f7 commit a06b7ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions crypto/cipher/aes_gcm_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ static srtp_err_status_t srtp_aes_gcm_openssl_set_aad(void *cv,
srtp_octet_string_hex_string(aad, aad_len));

if (c->dir == srtp_direction_encrypt) {
if (EVP_EncryptUpdate(c->ctx, NULL, &len, aad, aad_len) != 1) {
if (EVP_EncryptUpdate(c->ctx, NULL, &len, aad, (int)aad_len) != 1) {
return srtp_err_status_algo_fail;
}
} else {
if (EVP_DecryptUpdate(c->ctx, NULL, &len, aad, aad_len) != 1) {
if (EVP_DecryptUpdate(c->ctx, NULL, &len, aad, (int)aad_len) != 1) {
return srtp_err_status_algo_fail;
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ static srtp_err_status_t srtp_aes_gcm_openssl_encrypt(void *cv,
/*
* Encrypt the data
*/
if (EVP_EncryptUpdate(c->ctx, dst, &len, src, src_len) != 1) {
if (EVP_EncryptUpdate(c->ctx, dst, &len, src, (int)src_len) != 1) {
return srtp_err_status_algo_fail;
}
*dst_len = len;
Expand All @@ -319,7 +319,7 @@ static srtp_err_status_t srtp_aes_gcm_openssl_encrypt(void *cv,
/*
* Retrieve the tag
*/
if (EVP_CIPHER_CTX_ctrl(c->ctx, EVP_CTRL_GCM_GET_TAG, c->tag_len,
if (EVP_CIPHER_CTX_ctrl(c->ctx, EVP_CTRL_GCM_GET_TAG, (int)c->tag_len,
dst + *dst_len) != 1) {
return srtp_err_status_algo_fail;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ static srtp_err_status_t srtp_aes_gcm_openssl_decrypt(void *cv,
/*
* Decrypt the data
*/
if (EVP_DecryptUpdate(c->ctx, dst, &len, src, src_len - c->tag_len) != 1) {
if (EVP_DecryptUpdate(c->ctx, dst, &len, src, (int)(src_len - c->tag_len)) != 1) {
return srtp_err_status_algo_fail;
}
*dst_len = len;
Expand All @@ -371,7 +371,7 @@ static srtp_err_status_t srtp_aes_gcm_openssl_decrypt(void *cv,
* explicitly cast away const of src
*/
if (EVP_CIPHER_CTX_ctrl(
c->ctx, EVP_CTRL_GCM_SET_TAG, c->tag_len,
c->ctx, EVP_CTRL_GCM_SET_TAG, (int)c->tag_len,
(void *)(uintptr_t)(src + (src_len - c->tag_len))) != 1) {
return srtp_err_status_algo_fail;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/cipher/aes_icm_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static srtp_err_status_t srtp_aes_icm_openssl_encrypt(void *cv,
return srtp_err_status_buffer_small;
}

if (!EVP_EncryptUpdate(c->ctx, dst, &len, src, src_len)) {
if (!EVP_EncryptUpdate(c->ctx, dst, &len, src, (int)src_len)) {
return srtp_err_status_cipher_fail;
}
*dst_len = len;
Expand Down

0 comments on commit a06b7ed

Please sign in to comment.