Skip to content

Commit

Permalink
Use correct return type
Browse files Browse the repository at this point in the history
Fix #1147.

Signed-off-by: Steven Bellock <[email protected]>
  • Loading branch information
steven-bellock authored and jyao1 committed Jul 19, 2023
1 parent 8ac807b commit 62b3905
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions os_stub/cryptlib_mbedtls/cipher/aead_aes_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool libspdm_aead_aes_gcm_encrypt(const uint8_t *key, size_t key_size,
uint8_t *data_out, size_t *data_out_size)
{
mbedtls_gcm_context ctx;
int32_t ret;
int ret;

if (data_in_size > INT_MAX) {
return false;
Expand Down Expand Up @@ -133,7 +133,7 @@ bool libspdm_aead_aes_gcm_decrypt(const uint8_t *key, size_t key_size,
uint8_t *data_out, size_t *data_out_size)
{
mbedtls_gcm_context ctx;
int32_t ret;
int ret;

if (data_in_size > INT_MAX) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions os_stub/cryptlib_mbedtls/cipher/aead_chacha20_poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool libspdm_aead_chacha20_poly1305_encrypt(
size_t tag_size, uint8_t *data_out, size_t *data_out_size)
{
mbedtls_chachapoly_context ctx;
int32_t ret;
int ret;

if (data_in_size > INT_MAX) {
return false;
Expand Down Expand Up @@ -122,7 +122,7 @@ bool libspdm_aead_chacha20_poly1305_decrypt(
size_t tag_size, uint8_t *data_out, size_t *data_out_size)
{
mbedtls_chachapoly_context ctx;
int32_t ret;
int ret;

if (data_in_size > INT_MAX) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions os_stub/cryptlib_mbedtls/der/der.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool libspdm_rsa_get_public_key_from_der(const uint8_t *der_data,
size_t der_size,
void **rsa_context)
{
int32_t ret;
int ret;
mbedtls_pk_context pk;
mbedtls_rsa_context *rsa;

Expand Down Expand Up @@ -101,7 +101,7 @@ bool libspdm_ec_get_public_key_from_der(const uint8_t *der_data,
size_t der_size,
void **ec_context)
{
int32_t ret;
int ret;
mbedtls_pk_context pk;
mbedtls_ecdh_context *ecdh;

Expand Down
24 changes: 12 additions & 12 deletions os_stub/cryptlib_mbedtls/hash/sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void libspdm_sha256_free(void *sha256_ctx)
**/
bool libspdm_sha256_init(void *sha256_context)
{
int32_t ret;
int ret;

if (sha256_context == NULL) {
return false;
Expand Down Expand Up @@ -118,7 +118,7 @@ bool libspdm_sha256_duplicate(const void *sha256_context,
bool libspdm_sha256_update(void *sha256_context, const void *data,
size_t data_size)
{
int32_t ret;
int ret;

if (sha256_context == NULL) {
return false;
Expand Down Expand Up @@ -160,7 +160,7 @@ bool libspdm_sha256_update(void *sha256_context, const void *data,
**/
bool libspdm_sha256_final(void *sha256_context, uint8_t *hash_value)
{
int32_t ret;
int ret;

if (sha256_context == NULL || hash_value == NULL) {
return false;
Expand Down Expand Up @@ -195,7 +195,7 @@ bool libspdm_sha256_final(void *sha256_context, uint8_t *hash_value)
bool libspdm_sha256_hash_all(const void *data, size_t data_size,
uint8_t *hash_value)
{
int32_t ret;
int ret;

if (hash_value == NULL) {
return false;
Expand Down Expand Up @@ -259,7 +259,7 @@ void libspdm_sha384_free(void *sha384_ctx)
**/
bool libspdm_sha384_init(void *sha384_context)
{
int32_t ret;
int ret;

if (sha384_context == NULL) {
return false;
Expand Down Expand Up @@ -322,7 +322,7 @@ bool libspdm_sha384_duplicate(const void *sha384_context,
bool libspdm_sha384_update(void *sha384_context, const void *data,
size_t data_size)
{
int32_t ret;
int ret;

if (sha384_context == NULL) {
return false;
Expand Down Expand Up @@ -364,7 +364,7 @@ bool libspdm_sha384_update(void *sha384_context, const void *data,
**/
bool libspdm_sha384_final(void *sha384_context, uint8_t *hash_value)
{
int32_t ret;
int ret;

if (sha384_context == NULL || hash_value == NULL) {
return false;
Expand Down Expand Up @@ -399,7 +399,7 @@ bool libspdm_sha384_final(void *sha384_context, uint8_t *hash_value)
bool libspdm_sha384_hash_all(const void *data, size_t data_size,
uint8_t *hash_value)
{
int32_t ret;
int ret;

if (hash_value == NULL) {
return false;
Expand Down Expand Up @@ -463,7 +463,7 @@ void libspdm_sha512_free(void *sha512_ctx)
**/
bool libspdm_sha512_init(void *sha512_context)
{
int32_t ret;
int ret;

if (sha512_context == NULL) {
return false;
Expand Down Expand Up @@ -526,7 +526,7 @@ bool libspdm_sha512_duplicate(const void *sha512_context,
bool libspdm_sha512_update(void *sha512_context, const void *data,
size_t data_size)
{
int32_t ret;
int ret;

if (sha512_context == NULL) {
return false;
Expand Down Expand Up @@ -568,7 +568,7 @@ bool libspdm_sha512_update(void *sha512_context, const void *data,
**/
bool libspdm_sha512_final(void *sha512_context, uint8_t *hash_value)
{
int32_t ret;
int ret;

if (sha512_context == NULL || hash_value == NULL) {
return false;
Expand Down Expand Up @@ -603,7 +603,7 @@ bool libspdm_sha512_final(void *sha512_context, uint8_t *hash_value)
bool libspdm_sha512_hash_all(const void *data, size_t data_size,
uint8_t *hash_value)
{
int32_t ret;
int ret;

if (hash_value == NULL) {
return false;
Expand Down
10 changes: 5 additions & 5 deletions os_stub/cryptlib_mbedtls/hmac/hmac_sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool hmac_md_set_key(const mbedtls_md_type_t md_type, void *hmac_md_ctx,
const uint8_t *key, size_t key_size)
{
const mbedtls_md_info_t *md_info;
int32_t ret;
int ret;

if (hmac_md_ctx == NULL || key_size > INT_MAX) {
return false;
Expand Down Expand Up @@ -126,7 +126,7 @@ int hmac_md_get_blocksize( mbedtls_md_type_t md_type )
bool hmac_md_duplicate(const mbedtls_md_type_t md_type, const void *hmac_md_ctx,
void *new_hmac_md_ctx)
{
int32_t ret;
int ret;
const mbedtls_md_info_t *md_info;

if (hmac_md_ctx == NULL || new_hmac_md_ctx == NULL) {
Expand Down Expand Up @@ -177,7 +177,7 @@ bool hmac_md_duplicate(const mbedtls_md_type_t md_type, const void *hmac_md_ctx,
bool hmac_md_update(void *hmac_md_ctx, const void *data,
size_t data_size)
{
int32_t ret;
int ret;

if (hmac_md_ctx == NULL) {
return false;
Expand Down Expand Up @@ -219,7 +219,7 @@ bool hmac_md_update(void *hmac_md_ctx, const void *data,
**/
bool hmac_md_final(void *hmac_md_ctx, uint8_t *hmac_value)
{
int32_t ret;
int ret;

if (hmac_md_ctx == NULL || hmac_value == NULL) {
return false;
Expand Down Expand Up @@ -259,7 +259,7 @@ bool hmac_md_all(const mbedtls_md_type_t md_type, const void *data,
uint8_t *hmac_value)
{
const mbedtls_md_info_t *md_info;
int32_t ret;
int ret;

md_info = mbedtls_md_info_from_type(md_type);
LIBSPDM_ASSERT(md_info != NULL);
Expand Down
6 changes: 3 additions & 3 deletions os_stub/cryptlib_mbedtls/kdf/hkdf_sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool hkdf_md_extract_and_expand(const mbedtls_md_type_t md_type,
uint8_t *out, size_t out_size)
{
const mbedtls_md_info_t *md;
int32_t ret;
int ret;

if (key == NULL || salt == NULL || info == NULL || out == NULL ||
key_size > INT_MAX || salt_size > INT_MAX || info_size > INT_MAX ||
Expand Down Expand Up @@ -78,7 +78,7 @@ bool hkdf_md_extract(const mbedtls_md_type_t md_type, const uint8_t *key,
size_t prk_out_size)
{
const mbedtls_md_info_t *md;
int32_t ret;
int ret;
size_t md_size;

if (key == NULL || salt == NULL || prk_out == NULL ||
Expand Down Expand Up @@ -137,7 +137,7 @@ bool hkdf_md_expand(const mbedtls_md_type_t md_type, const uint8_t *prk,
size_t info_size, uint8_t *out, size_t out_size)
{
const mbedtls_md_info_t *md;
int32_t ret;
int ret;
size_t md_size;

if (prk == NULL || info == NULL || out == NULL || prk_size > INT_MAX ||
Expand Down
4 changes: 2 additions & 2 deletions os_stub/cryptlib_mbedtls/pem/pem.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool libspdm_rsa_get_private_key_from_pem(const uint8_t *pem_data,
const char *password,
void **rsa_context)
{
int32_t ret;
int ret;
mbedtls_pk_context pk;
mbedtls_rsa_context *rsa;
uint8_t *new_pem_data;
Expand Down Expand Up @@ -140,7 +140,7 @@ bool libspdm_ec_get_private_key_from_pem(const uint8_t *pem_data, size_t pem_siz
const char *password,
void **ec_context)
{
int32_t ret;
int ret;
mbedtls_pk_context pk;
mbedtls_ecdh_context *ecdh;
uint8_t *new_pem_data;
Expand Down
6 changes: 3 additions & 3 deletions os_stub/cryptlib_mbedtls/pk/dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static const unsigned char m_ffehde4096_g[] =
void *libspdm_dh_new_by_nid(size_t nid)
{
mbedtls_dhm_context *ctx;
int32_t ret;
int ret;

ctx = allocate_zero_pool(sizeof(mbedtls_dhm_context));
if (ctx == NULL) {
Expand Down Expand Up @@ -194,7 +194,7 @@ bool libspdm_dh_set_parameter(void *dh_context, size_t generator,
bool libspdm_dh_generate_key(void *dh_context, uint8_t *public_key,
size_t *public_key_size)
{
int32_t ret;
int ret;
mbedtls_dhm_context *ctx;
size_t final_pub_key_size;

Expand Down Expand Up @@ -272,7 +272,7 @@ bool libspdm_dh_compute_key(void *dh_context, const uint8_t *peer_public_key,
size_t peer_public_key_size, uint8_t *key,
size_t *key_size)
{
int32_t ret;
int ret;
mbedtls_dhm_context *ctx;
size_t return_size;
size_t dh_key_size;
Expand Down
18 changes: 9 additions & 9 deletions os_stub/cryptlib_mbedtls/pk/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void *libspdm_ec_new_by_nid(size_t nid)
{
mbedtls_ecdh_context *ctx;
mbedtls_ecp_group_id grp_id;
int32_t ret;
int ret;

ctx = allocate_zero_pool(sizeof(mbedtls_ecdh_context));
if (ctx == NULL) {
Expand Down Expand Up @@ -96,7 +96,7 @@ bool libspdm_ec_set_pub_key(void *ec_context, const uint8_t *public_key,
size_t public_key_size)
{
mbedtls_ecdh_context *ctx;
int32_t ret;
int ret;
size_t half_size;

if (ec_context == NULL || public_key == NULL) {
Expand Down Expand Up @@ -157,7 +157,7 @@ bool libspdm_ec_set_priv_key(void *ec_context, const uint8_t *private_key,
size_t private_key_size)
{
mbedtls_ecdh_context *ctx;
int32_t ret;
int ret;
size_t half_size;

if (ec_context == NULL || private_key == NULL) {
Expand Down Expand Up @@ -210,7 +210,7 @@ bool libspdm_ec_get_pub_key(void *ec_context, uint8_t *public_key,
size_t *public_key_size)
{
mbedtls_ecdh_context *ctx;
int32_t ret;
int ret;
size_t half_size;
size_t x_size;
size_t y_size;
Expand Down Expand Up @@ -314,7 +314,7 @@ bool libspdm_ec_generate_key(void *ec_context, uint8_t *public_data,
size_t *public_size)
{
mbedtls_ecdh_context *ctx;
int32_t ret;
int ret;
size_t half_size;
size_t x_size;
size_t y_size;
Expand Down Expand Up @@ -408,7 +408,7 @@ bool libspdm_ec_compute_key(void *ec_context, const uint8_t *peer_public,
{
mbedtls_ecdh_context *ctx;
size_t half_size;
int32_t ret;
int ret;

if (ec_context == NULL || peer_public == NULL || key_size == NULL ||
key == NULL) {
Expand Down Expand Up @@ -503,7 +503,7 @@ bool libspdm_ecdsa_sign(void *ec_context, size_t hash_nid,
const uint8_t *message_hash, size_t hash_size,
uint8_t *signature, size_t *sig_size)
{
int32_t ret;
int ret;
mbedtls_ecdh_context *ctx;
mbedtls_mpi bn_r;
mbedtls_mpi bn_s;
Expand Down Expand Up @@ -624,7 +624,7 @@ bool libspdm_ecdsa_verify(void *ec_context, size_t hash_nid,
const uint8_t *message_hash, size_t hash_size,
const uint8_t *signature, size_t sig_size)
{
int32_t ret;
int ret;
mbedtls_ecdh_context *ctx;
mbedtls_mpi bn_r;
mbedtls_mpi bn_s;
Expand Down Expand Up @@ -729,7 +729,7 @@ bool libspdm_ecdsa_sign_ex(void *ec_context, size_t hash_nid,
uint8_t *signature, size_t *sig_size,
int (*random_func)(void *, unsigned char *, size_t))
{
int32_t ret;
int ret;
mbedtls_ecdh_context *ctx;
mbedtls_mpi bn_r;
mbedtls_mpi bn_s;
Expand Down
6 changes: 3 additions & 3 deletions os_stub/cryptlib_mbedtls/pk/rsa_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool libspdm_rsa_set_key(void *rsa_context, const libspdm_rsa_key_tag_t key_tag,
const uint8_t *big_number, size_t bn_size)
{
mbedtls_rsa_context *rsa_key;
int32_t ret;
int ret;
mbedtls_mpi value;


Expand Down Expand Up @@ -162,7 +162,7 @@ bool libspdm_rsa_pkcs1_verify_with_nid(void *rsa_context, size_t hash_nid,
size_t hash_size, const uint8_t *signature,
size_t sig_size)
{
int32_t ret;
int ret;
mbedtls_md_type_t md_alg;
mbedtls_rsa_context *rsa_key;

Expand Down Expand Up @@ -249,7 +249,7 @@ bool libspdm_rsa_pss_verify(void *rsa_context, size_t hash_nid,
const uint8_t *message_hash, size_t hash_size,
const uint8_t *signature, size_t sig_size)
{
int32_t ret;
int ret;
mbedtls_md_type_t md_alg;
mbedtls_rsa_context *rsa_key;

Expand Down
Loading

0 comments on commit 62b3905

Please sign in to comment.