mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-12 19:40:39 +03:00
oscore: Handle encrypt error return
Check return from cose_encrypt0_encrypt() and correct spelling error.
This commit is contained in:
1 parent
583c52c567
commit
c7cda63092
4 files changed
+12
-6
No files matched your search
@@ -734,7 +734,7 @@ get_oscore_conf(void) {
|
||||
/* Need a rw var to free off later and file_mem.s is a const */
|
||||
buf = read_file_mem(oscore_conf_file, &length);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "OSCORE configuraton file error: %s\n", oscore_conf_file);
|
||||
fprintf(stderr, "OSCORE configuration file error: %s\n", oscore_conf_file);
|
||||
return NULL;
|
||||
}
|
||||
file_mem.s = buf;
|
||||
@@ -760,7 +760,7 @@ get_oscore_conf(void) {
|
||||
NULL, start_seq_num);
|
||||
coap_free(buf);
|
||||
if (oscore_conf == NULL) {
|
||||
fprintf(stderr, "OSCORE configuraton file error: %s\n", oscore_conf_file);
|
||||
fprintf(stderr, "OSCORE configuration file error: %s\n", oscore_conf_file);
|
||||
return NULL;
|
||||
}
|
||||
return oscore_conf;
|
||||
|
||||
@@ -2406,7 +2406,7 @@ get_oscore_conf(coap_context_t *context) {
|
||||
/* Need a rw var to free off later and file_mem.s is a const */
|
||||
buf = read_file_mem(oscore_conf_file, &length);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "OSCORE configuraton file error: %s\n", oscore_conf_file);
|
||||
fprintf(stderr, "OSCORE configuration file error: %s\n", oscore_conf_file);
|
||||
return NULL;
|
||||
}
|
||||
file_mem.s = buf;
|
||||
@@ -2432,7 +2432,7 @@ get_oscore_conf(coap_context_t *context) {
|
||||
NULL, start_seq_num);
|
||||
coap_free(buf);
|
||||
if (oscore_conf == NULL) {
|
||||
fprintf(stderr, "OSCORE configuraton file error: %s\n", oscore_conf_file);
|
||||
fprintf(stderr, "OSCORE configuration file error: %s\n", oscore_conf_file);
|
||||
return NULL;
|
||||
}
|
||||
coap_context_oscore_server(context, oscore_conf);
|
||||
|
||||
@@ -512,7 +512,7 @@ get_oscore_conf(coap_context_t *context) {
|
||||
|
||||
buf = read_file_mem(oscore_conf_file, &length);
|
||||
if (buf == NULL) {
|
||||
fprintf(stderr, "OSCORE configuraton file error: %s\n", oscore_conf_file);
|
||||
fprintf(stderr, "OSCORE configuration file error: %s\n", oscore_conf_file);
|
||||
return NULL;
|
||||
}
|
||||
file_mem.s = buf;
|
||||
@@ -538,7 +538,7 @@ get_oscore_conf(coap_context_t *context) {
|
||||
NULL, start_seq_num);
|
||||
coap_free(buf);
|
||||
if (oscore_conf == NULL) {
|
||||
fprintf(stderr, "OSCORE configuraton file error: %s\n", oscore_conf_file);
|
||||
fprintf(stderr, "OSCORE configuration file error: %s\n", oscore_conf_file);
|
||||
return NULL;
|
||||
}
|
||||
coap_context_oscore_server(context, oscore_conf);
|
||||
|
||||
@@ -591,6 +591,12 @@ coap_oscore_new_pdu_encrypted(coap_session_t *session,
|
||||
ciphertext_len = cose_encrypt0_encrypt(cose,
|
||||
ciphertext_buffer,
|
||||
plain_pdu->used_size + AES_CCM_TAG);
|
||||
if ((int)ciphertext_len <= 0) {
|
||||
coap_log_warn(
|
||||
"OSCORE: Encryption Failure, result code: %d \n",
|
||||
(int)ciphertext_len);
|
||||
goto error;
|
||||
}
|
||||
assert(ciphertext_len < OSCORE_CRYPTO_BUFFER_SIZE);
|
||||
|
||||
/* Add in OSCORE option (previously computed) */
|
||||
|
||||
Reference in new issue
Block a user