Skip to content

Commit

Permalink
Fix some straggler compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Lundblade committed Jun 13, 2023
1 parent c822140 commit dfc8002
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
16 changes: 12 additions & 4 deletions crypto_adapters/t_cose_openssl_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1965,10 +1965,10 @@ t_cose_crypto_kw_unwrap(int32_t algorithm_id,
*/
enum t_cose_err_t
t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
struct q_useful_buf_c salt,
struct q_useful_buf_c ikm,
struct q_useful_buf_c info,
struct q_useful_buf okm_buffer)
const struct q_useful_buf_c salt,
const struct q_useful_buf_c ikm,
const struct q_useful_buf_c info,
const struct q_useful_buf okm_buffer)
{
int ossl_result;
EVP_PKEY_CTX *ctx;
Expand Down Expand Up @@ -2012,6 +2012,12 @@ t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
goto Done1;
}

/* See comment above in configure_pkey_context(). The following
* OpenSSL APIs should have the argments declared as const, but
* they are not so this pragma is necessary t_cose can compile
* with "-Wcast-qual". */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-qual"
ossl_result = EVP_PKEY_CTX_set_hkdf_md(ctx, message_digest);
if(ossl_result != 1) {
return_value = T_COSE_ERR_HKDF_FAIL;
Expand All @@ -2038,6 +2044,8 @@ t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
return_value = T_COSE_ERR_HKDF_FAIL;
goto Done1;
}
#pragma GCC diagnostic pop


ossl_result = EVP_PKEY_derive(ctx,
okm_buffer.ptr,
Expand Down
11 changes: 5 additions & 6 deletions crypto_adapters/t_cose_psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,15 +1278,14 @@ t_cose_crypto_aead_decrypt(const int32_t cose_algorithm_id,
* See documentation in t_cose_crypto.h
*/
enum t_cose_err_t
t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
struct q_useful_buf_c salt,
struct q_useful_buf_c ikm,
struct q_useful_buf_c info,
struct q_useful_buf okm_buffer)
t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
const struct q_useful_buf_c salt,
const struct q_useful_buf_c ikm,
const struct q_useful_buf_c info,
const struct q_useful_buf okm_buffer)
{
int psa_result;
const mbedtls_md_info_t *md_info;
size_t okm_in_out_len;
mbedtls_md_type_t hash_type;

switch(cose_hash_algorithm_id) {
Expand Down
14 changes: 9 additions & 5 deletions crypto_adapters/t_cose_test_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,16 @@ t_cose_crypto_kw_unwrap(int32_t cose_algorithm_id,


enum t_cose_err_t
t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
struct q_useful_buf_c salt,
struct q_useful_buf_c ikm,
struct q_useful_buf_c info,
struct q_useful_buf okm_buffer)
t_cose_crypto_hkdf(const int32_t cose_hash_algorithm_id,
const struct q_useful_buf_c salt,
const struct q_useful_buf_c ikm,
const struct q_useful_buf_c info,
const struct q_useful_buf okm_buffer)
{
(void)cose_hash_algorithm_id;
(void)salt;
(void)ikm;
(void)info;
/* This makes a fixed fake output of all x's */
(void)UsefulBuf_Set(okm_buffer, 'x');
return T_COSE_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion examples/signing_examples.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ int32_t one_step_multi_sign_detached_example(void)
Done_free1:
free_fixed_signing_key(ecdsa_key_pair);

Done:
printf("---- %s EXAMPLE one_step_multi_sign_detached (%d) ----\n\n",
return_value ? "FAILED" : "COMPLETED", return_value);

Expand Down
10 changes: 5 additions & 5 deletions src/t_cose_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,11 @@ t_cose_crypto_free_symmetric_key(struct t_cose_key key);
* See RFC 5869 for a detailed description.
*/
enum t_cose_err_t
t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
struct q_useful_buf_c salt,
struct q_useful_buf_c ikm,
struct q_useful_buf_c info,
struct q_useful_buf okm_buffer);
t_cose_crypto_hkdf(int32_t cose_hash_algorithm_id,
const struct q_useful_buf_c salt,
const struct q_useful_buf_c ikm,
const struct q_useful_buf_c info,
const struct q_useful_buf okm_buffer);



Expand Down
1 change: 0 additions & 1 deletion test/t_cose_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ int_fast32_t short_circuit_signing_error_conditions_test()
enum t_cose_err_t result;
Q_USEFUL_BUF_MAKE_STACK_UB( signed_cose_buffer, 300);
Q_USEFUL_BUF_MAKE_STACK_UB( small_signed_cose_buffer, 15);
struct q_useful_buf_c payload;
struct q_useful_buf_c signed_cose;

/* -- Test bad algorithm ID 0 -- */
Expand Down

0 comments on commit dfc8002

Please sign in to comment.