Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
cose-error.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024, RISE Research Institutes of Sweden AB
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the copyright holder nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
/**
31
* \file
32
* COSE error implementation
33
* \author
34
* Niclas Finne <niclas.finne@ri.se>, Nicolas Tsiftes <nicolas.tsiftes@ri.se>
35
*/
36
37
#include "
cose-error.h
"
38
39
/*---------------------------------------------------------------------------*/
40
const
char
*
41
cose_error_string
(
cose_error_t
error)
42
{
43
switch
(error) {
44
case
COSE_SUCCESS:
45
return
"Success"
;
46
47
/* Parameter and input errors */
48
case
COSE_ERR_INVALID_PARAMETER
:
49
return
"Invalid parameter"
;
50
case
COSE_ERR_NULL_POINTER
:
51
return
"Null pointer"
;
52
case
COSE_ERR_BUFFER_TOO_SMALL
:
53
return
"Buffer too small"
;
54
case
COSE_ERR_INVALID_LENGTH
:
55
return
"Invalid length"
;
56
case
COSE_ERR_UNSUPPORTED_ALGORITHM
:
57
return
"Algorithm not supported"
;
58
59
/* Memory and buffer errors */
60
case
COSE_ERR_MEMORY_ALLOCATION
:
61
return
"Memory allocation failed"
;
62
case
COSE_ERR_BUFFER_OVERFLOW
:
63
return
"Buffer overflow"
;
64
65
/* Cryptographic operation errors */
66
case
COSE_ERR_CRYPTO_KEYGEN
:
67
return
"Key generation failed"
;
68
case
COSE_ERR_CRYPTO_SIGN
:
69
return
"Digital signature failed"
;
70
case
COSE_ERR_CRYPTO_VERIFY
:
71
return
"Signature verification failed"
;
72
case
COSE_ERR_CRYPTO_ENCRYPT
:
73
return
"Encryption failed"
;
74
case
COSE_ERR_CRYPTO_DECRYPT
:
75
return
"Decryption failed"
;
76
case
COSE_ERR_CRYPTO_AUTHENTICATION
:
77
return
"Authentication tag verification failed"
;
78
case
COSE_ERR_CRYPTO_INVALID_KEY
:
79
return
"Invalid cryptographic key"
;
80
81
/* CBOR structure errors */
82
case
COSE_ERR_CBOR_ENCODING
:
83
return
"CBOR encoding failed"
;
84
case
COSE_ERR_CBOR_DECODING
:
85
return
"CBOR decoding failed"
;
86
case
COSE_ERR_CBOR_INVALID_TYPE
:
87
return
"Invalid CBOR type"
;
88
case
COSE_ERR_CBOR_MALFORMED
:
89
return
"Malformed CBOR data"
;
90
91
/* COSE structure errors */
92
case
COSE_ERR_INVALID_STRUCTURE
:
93
return
"Invalid COSE structure"
;
94
case
COSE_ERR_MISSING_HEADER
:
95
return
"Required header missing"
;
96
case
COSE_ERR_INVALID_HEADER
:
97
return
"Invalid header content"
;
98
case
COSE_ERR_MISSING_PAYLOAD
:
99
return
"Required payload missing"
;
100
101
/* General errors */
102
case
COSE_ERR_NOT_IMPLEMENTED
:
103
return
"Not implemented"
;
104
case
COSE_ERR_INTERNAL_ERROR
:
105
return
"Internal error"
;
106
case
COSE_ERR_UNKNOWN
:
107
return
"Unknown error"
;
108
109
default
:
110
return
"Unrecognized COSE error code"
;
111
}
112
}
113
/*---------------------------------------------------------------------------*/
cose_error_string
const char * cose_error_string(cose_error_t error)
Get a human-readable error message for a COSE error.
Definition
cose-error.c:41
cose-error.h
COSE library error definitions.
cose_error_t
cose_error_t
COSE operation error codes.
Definition
cose-error.h:53
COSE_ERR_CRYPTO_ENCRYPT
@ COSE_ERR_CRYPTO_ENCRYPT
Encryption operation failed.
Definition
cose-error.h:72
COSE_ERR_BUFFER_TOO_SMALL
@ COSE_ERR_BUFFER_TOO_SMALL
Buffer too small for operation.
Definition
cose-error.h:60
COSE_ERR_CRYPTO_KEYGEN
@ COSE_ERR_CRYPTO_KEYGEN
Key generation failed.
Definition
cose-error.h:69
COSE_ERR_INVALID_LENGTH
@ COSE_ERR_INVALID_LENGTH
Invalid length parameter.
Definition
cose-error.h:61
COSE_ERR_MISSING_HEADER
@ COSE_ERR_MISSING_HEADER
Required header missing.
Definition
cose-error.h:85
COSE_ERR_UNSUPPORTED_ALGORITHM
@ COSE_ERR_UNSUPPORTED_ALGORITHM
Algorithm not supported.
Definition
cose-error.h:62
COSE_ERR_CBOR_MALFORMED
@ COSE_ERR_CBOR_MALFORMED
Malformed CBOR data.
Definition
cose-error.h:81
COSE_ERR_UNKNOWN
@ COSE_ERR_UNKNOWN
Unknown error condition.
Definition
cose-error.h:92
COSE_ERR_CRYPTO_SIGN
@ COSE_ERR_CRYPTO_SIGN
Digital signature failed.
Definition
cose-error.h:70
COSE_ERR_CRYPTO_AUTHENTICATION
@ COSE_ERR_CRYPTO_AUTHENTICATION
Authentication tag verification failed.
Definition
cose-error.h:74
COSE_ERR_CRYPTO_VERIFY
@ COSE_ERR_CRYPTO_VERIFY
Signature verification failed.
Definition
cose-error.h:71
COSE_ERR_CBOR_DECODING
@ COSE_ERR_CBOR_DECODING
CBOR decoding failed.
Definition
cose-error.h:79
COSE_ERR_BUFFER_OVERFLOW
@ COSE_ERR_BUFFER_OVERFLOW
Buffer overflow detected.
Definition
cose-error.h:66
COSE_ERR_MISSING_PAYLOAD
@ COSE_ERR_MISSING_PAYLOAD
Required payload missing.
Definition
cose-error.h:87
COSE_ERR_INVALID_PARAMETER
@ COSE_ERR_INVALID_PARAMETER
Invalid parameter provided.
Definition
cose-error.h:58
COSE_ERR_CBOR_ENCODING
@ COSE_ERR_CBOR_ENCODING
CBOR encoding failed.
Definition
cose-error.h:78
COSE_ERR_NOT_IMPLEMENTED
@ COSE_ERR_NOT_IMPLEMENTED
Feature not implemented.
Definition
cose-error.h:90
COSE_ERR_INVALID_STRUCTURE
@ COSE_ERR_INVALID_STRUCTURE
Invalid COSE structure.
Definition
cose-error.h:84
COSE_ERR_CRYPTO_DECRYPT
@ COSE_ERR_CRYPTO_DECRYPT
Decryption operation failed.
Definition
cose-error.h:73
COSE_ERR_NULL_POINTER
@ COSE_ERR_NULL_POINTER
Null pointer provided.
Definition
cose-error.h:59
COSE_ERR_INVALID_HEADER
@ COSE_ERR_INVALID_HEADER
Invalid header content.
Definition
cose-error.h:86
COSE_ERR_INTERNAL_ERROR
@ COSE_ERR_INTERNAL_ERROR
Internal implementation error.
Definition
cose-error.h:91
COSE_ERR_MEMORY_ALLOCATION
@ COSE_ERR_MEMORY_ALLOCATION
Memory allocation failed.
Definition
cose-error.h:65
COSE_ERR_CBOR_INVALID_TYPE
@ COSE_ERR_CBOR_INVALID_TYPE
Invalid CBOR data type.
Definition
cose-error.h:80
COSE_ERR_CRYPTO_INVALID_KEY
@ COSE_ERR_CRYPTO_INVALID_KEY
Invalid cryptographic key.
Definition
cose-error.h:75
os
net
security
cose
cose-error.c
Generated on
for Contiki-NG by
1.17.0