Skip to content

Commit

Permalink
Update for primary commit obgm#9 (to be squashed later)
Browse files Browse the repository at this point in the history
Use new coap_log_debug() etc. in OSCORE specific code.
  • Loading branch information
mrdeep1 committed Jan 2, 2023
1 parent 41a3e69 commit 0cf793f
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 93 deletions.
10 changes: 5 additions & 5 deletions src/coap_gnutls.c
Original file line number Diff line number Diff line change
Expand Up @@ -3008,7 +3008,7 @@ get_cipher_alg(cose_alg_t alg) {
if (ciphers[idx].alg == alg)
return ciphers[idx].cipher_type;
}
coap_log(LOG_DEBUG, "get_cipher_alg: COSE cipher %d not supported\n", alg);
coap_log_debug("get_cipher_alg: COSE cipher %d not supported\n", alg);
return 0;
}

Expand All @@ -3033,7 +3033,7 @@ get_hmac_alg(cose_hmac_alg_t hmac_alg) {
if (hmacs[idx].hmac_alg == hmac_alg)
return hmacs[idx].hmac_type;
}
coap_log(LOG_DEBUG, "get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
coap_log_debug("get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
return 0;
}

Expand Down Expand Up @@ -3075,7 +3075,7 @@ coap_crypto_aead_encrypt(const coap_crypto_param_t *params,
return 0;
}
if ((algo = get_cipher_alg(params->alg)) == 0) {
coap_log(LOG_DEBUG,
coap_log_debug(
"coap_crypto_encrypt: algorithm %d not supported\n",
params->alg);
return 0;
Expand Down Expand Up @@ -3140,7 +3140,7 @@ coap_crypto_aead_decrypt(const coap_crypto_param_t *params,
return 0;
}
if ((algo = get_cipher_alg(params->alg)) == 0) {
coap_log(LOG_DEBUG,
coap_log_debug(
"coap_crypto_decrypt: algorithm %d not supported\n",
params->alg);
return 0;
Expand Down Expand Up @@ -3195,7 +3195,7 @@ coap_crypto_hmac(cose_hmac_alg_t hmac_alg,
return 0;

if ((mac_algo = get_hmac_alg(hmac_alg)) == 0) {
coap_log(LOG_DEBUG, "coap_crypto_hmac: algorithm %d not supported\n", hmac_alg);
coap_log_debug("coap_crypto_hmac: algorithm %d not supported\n", hmac_alg);
return 0;
}
len = gnutls_hmac_get_len(mac_algo);
Expand Down
20 changes: 10 additions & 10 deletions src/coap_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@ get_cipher_alg(cose_alg_t alg) {
if (ciphers[idx].alg == alg)
return ciphers[idx].cipher_type;
}
coap_log(LOG_DEBUG, "get_cipher_alg: COSE cipher %d not supported\n", alg);
coap_log_debug("get_cipher_alg: COSE cipher %d not supported\n", alg);
return 0;
}

Expand All @@ -2660,7 +2660,7 @@ get_hmac_alg(cose_hmac_alg_t hmac_alg) {
if (hmacs[idx].hmac_alg == hmac_alg)
return hmacs[idx].hmac_type;
}
coap_log(LOG_DEBUG, "get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
coap_log_debug("get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
return 0;
}

Expand All @@ -2685,7 +2685,7 @@ coap_crypto_check_hkdf_alg(cose_hkdf_alg_t hkdf_alg) {
if (c_tmp != 0) { \
char error_buf[64]; \
mbedtls_strerror(c_tmp, error_buf, sizeof(error_buf)); \
coap_log(LOG_ERR, "mbedtls: -0x%04x: %s\n", -c_tmp, error_buf); \
coap_log_err("mbedtls: -0x%04x: %s\n", -c_tmp, error_buf); \
goto error; \
} \
} while (0);
Expand All @@ -2694,7 +2694,7 @@ coap_crypto_check_hkdf_alg(cose_hkdf_alg_t hkdf_alg) {
do { \
int c_tmp = (int)(Func); \
if (c_tmp != 0) { \
coap_log(LOG_ERR, "mbedtls: %d\n", tmp); \
coap_log_err("mbedtls: %d\n", tmp); \
goto error; \
} \
} while (0);
Expand All @@ -2718,14 +2718,14 @@ setup_cipher_context(mbedtls_cipher_context_t *ctx,
memset(key, 0, sizeof(key));

if ((cipher_type = get_cipher_alg(coap_alg)) == 0) {
coap_log(LOG_DEBUG,
coap_log_debug(
"coap_crypto_encrypt: algorithm %d not supported\n",
coap_alg);
return 0;
}
cipher_info = mbedtls_cipher_info_from_type(cipher_type);
if (!cipher_info) {
coap_log(LOG_CRIT, "coap_crypto_encrypt: cannot get cipher info\n");
coap_log_crit("coap_crypto_encrypt: cannot get cipher info\n");
return 0;
}

Expand All @@ -2734,7 +2734,7 @@ setup_cipher_context(mbedtls_cipher_context_t *ctx,
C(mbedtls_cipher_setup(ctx, cipher_info));
klen = mbedtls_cipher_get_key_bitlen(ctx);
if ((klen > (int)(sizeof(key) * 8)) || (key_length > sizeof(key))) {
coap_log(LOG_CRIT, "coap_crypto: cannot set key\n");
coap_log_crit("coap_crypto: cannot set key\n");
goto error;
}
memcpy(key, key_data, key_length);
Expand Down Expand Up @@ -2802,7 +2802,7 @@ coap_crypto_aead_encrypt(const coap_crypto_param_t *params,
));
/* check if buffer is sufficient to hold tag */
if ((result_len + ccm->tag_len) > *max_result_len) {
coap_log(LOG_ERR, "coap_encrypt: buffer too small\n");
coap_log_err("coap_encrypt: buffer too small\n");
goto error;
}
/* append tag to result */
Expand Down Expand Up @@ -2866,7 +2866,7 @@ coap_crypto_aead_decrypt(const coap_crypto_param_t *params,
}

if (data->length < ccm->tag_len) {
coap_log(LOG_ERR, "coap_decrypt: invalid tag length\n");
coap_log_err("coap_decrypt: invalid tag length\n");
goto error;
}

Expand Down Expand Up @@ -2932,7 +2932,7 @@ coap_crypto_hmac(cose_hmac_alg_t hmac_alg,
assert(hmac);

if ((mac_algo = get_hmac_alg(hmac_alg)) == 0) {
coap_log(LOG_DEBUG, "coap_crypto_hmac: algorithm %d not supported\n", hmac_alg);
coap_log_debug("coap_crypto_hmac: algorithm %d not supported\n", hmac_alg);
return 0;
}
md_info = mbedtls_md_info_from_type(mac_algo);
Expand Down
4 changes: 2 additions & 2 deletions src/coap_notls.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ get_cipher_alg(cose_alg_t alg) {
if (ciphers[idx].alg == alg)
return ciphers[idx].cipher_type;
}
coap_log(LOG_DEBUG, "get_cipher_alg: COSE cipher %d not supported\n", alg);
coap_log_debug("get_cipher_alg: COSE cipher %d not supported\n", alg);
return 0;
}

Expand All @@ -350,7 +350,7 @@ get_hmac_alg(cose_hmac_alg_t hmac_alg) {
if (hmacs[idx].hmac_alg == hmac_alg)
return hmacs[idx].hmac_type;
}
coap_log(LOG_DEBUG, "get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
coap_log_debug("get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions src/coap_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3609,7 +3609,7 @@ get_cipher_alg(cose_alg_t alg) {
if (ciphers[idx].alg == alg)
return ciphers[idx].get_cipher();
}
coap_log(LOG_DEBUG, "get_cipher_alg: COSE cipher %d not supported\n", alg);
coap_log_debug("get_cipher_alg: COSE cipher %d not supported\n", alg);
return NULL;
}

Expand All @@ -3635,7 +3635,7 @@ get_hmac_alg(cose_hmac_alg_t hmac_alg) {
if (hmacs[idx].hmac_alg == hmac_alg)
return hmacs[idx].get_hmac();
}
coap_log(LOG_DEBUG, "get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
coap_log_debug("get_hmac_alg: COSE HMAC %d not supported\n", hmac_alg);
return NULL;
}

Expand Down Expand Up @@ -3663,7 +3663,7 @@ coap_crypto_output_errors(const char *prefix) {
unsigned long e;

while ((e = ERR_get_error()))
coap_log(LOG_WARNING,
coap_log_warn(
"%s: %s%s\n",
prefix,
ERR_reason_error_string(e),
Expand Down Expand Up @@ -3806,7 +3806,7 @@ coap_crypto_hmac(cose_hmac_alg_t hmac_alg,
assert(hmac);

if ((evp_md = get_hmac_alg(hmac_alg)) == 0) {
coap_log(LOG_DEBUG, "coap_crypto_hmac: algorithm %d not supported\n", hmac_alg);
coap_log_debug("coap_crypto_hmac: algorithm %d not supported\n", hmac_alg);
return 0;
}
dummy = coap_new_binary(EVP_MAX_MD_SIZE);
Expand Down
Loading

0 comments on commit 0cf793f

Please sign in to comment.