3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2013-2017 Nest Labs, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 * This file defines constants for the CHIP ASN1 subsystem.
24 * Error types, ranges, and mappings overrides may be made by
25 * defining the appropriate ASN1_CONFIG_* or _ASN1_CONFIG_*
32 #include "ASN1Config.h"
43 * This defines the InetLayer error code for success or no
44 * error. This value may be configured via #ASN1_CONFIG_NO_ERROR.
47 #define ASN1_NO_ERROR ASN1_CONFIG_NO_ERROR
53 * This defines the base or minimum ASN1 error number range.
54 * This value may be configured via #ASN1_CONFIG_ERROR_MIN.
57 #define ASN1_ERROR_MIN ASN1_CONFIG_ERROR_MIN
63 * This defines the top or maximum ASN1 error number range.
64 * This value may be configured via #ASN1_CONFIG_ERROR_MAX.
67 #define ASN1_ERROR_MAX ASN1_CONFIG_ERROR_MAX
73 * This defines a mapping function for ASN1 errors that allows
74 * mapping such errors into a platform- or system-specific
75 * range. This function may be configured via
76 * #_ASN1_CONFIG_ERROR(e).
78 * @param[in] e The ASN1 error to map.
80 * @return The mapped ASN1 error.
83 #define _ASN1_ERROR(e) _ASN1_CONFIG_ERROR(e)
86 * The basic type for all ASN1 subsystem errors.
88 * This is defined to a platform- or system-specific type.
91 typedef ASN1_CONFIG_ERROR_TYPE ASN1_ERROR;
95 * @name Error Definitions
104 * An end of ASN1 container or stream condition occurred.
107 #define ASN1_END _ASN1_ERROR(0)
110 * @def ASN1_ERROR_UNDERRUN
113 * The ASN.1 encoding ended prematurely.
116 #define ASN1_ERROR_UNDERRUN _ASN1_ERROR(1)
119 * @def ASN1_ERROR_OVERFLOW
122 * The encoding exceeds the available space required to write it.
125 #define ASN1_ERROR_OVERFLOW _ASN1_ERROR(2)
128 * @def ASN1_ERROR_INVALID_STATE
131 * An unexpected or invalid state was encountered.
134 #define ASN1_ERROR_INVALID_STATE _ASN1_ERROR(3)
137 * @def ASN1_ERROR_MAX_DEPTH_EXCEEDED
140 * The maximum number of container reading contexts was exceeded.
143 #define ASN1_ERROR_MAX_DEPTH_EXCEEDED _ASN1_ERROR(4)
146 * @def ASN1_ERROR_INVALID_ENCODING
149 * The ASN.1 encoding is invalid.
152 #define ASN1_ERROR_INVALID_ENCODING _ASN1_ERROR(5)
155 * @def ASN1_ERROR_UNSUPPORTED_ENCODING
158 * An unsupported encoding was requested or encountered.
161 #define ASN1_ERROR_UNSUPPORTED_ENCODING _ASN1_ERROR(6)
164 * @def ASN1_ERROR_TAG_OVERFLOW
167 * An encoded tag exceeds the available or allowed space required
171 #define ASN1_ERROR_TAG_OVERFLOW _ASN1_ERROR(7)
174 * @def ASN1_ERROR_LENGTH_OVERFLOW
177 * An encoded length exceeds the available or allowed space
181 #define ASN1_ERROR_LENGTH_OVERFLOW _ASN1_ERROR(8)
184 * @def ASN1_ERROR_VALUE_OVERFLOW
187 * An encoded value exceeds the available or allowed space
191 #define ASN1_ERROR_VALUE_OVERFLOW _ASN1_ERROR(9)
194 * @def ASN1_ERROR_UNKNOWN_OBJECT_ID
197 * A requested object identifier does not match the list of
198 * supported object identifiers.
201 #define ASN1_ERROR_UNKNOWN_OBJECT_ID _ASN1_ERROR(10)
203 // !!!!! IMPORTANT !!!!!
205 // If you add new ASN1 errors, please update the translation of error
206 // codes to strings in ASN1Error.cpp, and add them to unittest
207 // in test-apps/TestErrorStr.cpp
215 bool FormatASN1Error(char * buf, uint16_t bufSize, int32_t err);