1 | /* Copyright (c) (2017-2022) Apple Inc. All rights reserved. |
2 | * |
3 | * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which |
4 | * is contained in the License.txt file distributed with corecrypto) and only to |
5 | * people who accept that license. IMPORTANT: Any license rights granted to you by |
6 | * Apple Inc. (if any) are limited to internal use within your organization only on |
7 | * devices and computers you own or control, for the sole purpose of verifying the |
8 | * security characteristics and correct functioning of the Apple Software. You may |
9 | * not, directly or indirectly, redistribute the Apple Software or any portions thereof. |
10 | */ |
11 | |
12 | #ifndef _CORECRYPTO_CC_ERROR_H_ |
13 | #define _CORECRYPTO_CC_ERROR_H_ |
14 | |
15 | enum { |
16 | CCERR_OK = 0, |
17 | |
18 | /* the default error code */ |
19 | CCERR_INTERNAL = -1, |
20 | |
21 | CCERR_INTEGRITY = -2, |
22 | |
23 | CCERR_DEVICE = -3, |
24 | CCERR_INTERRUPTS = -4, |
25 | CCERR_CRYPTO_CONFIG = -5, |
26 | CCERR_PERMS = -6, |
27 | CCERR_PARAMETER = -7, |
28 | CCERR_MEMORY = -8, |
29 | CCERR_FILEDESC = -9, |
30 | CCERR_OUT_OF_ENTROPY = -10, |
31 | CCERR_ATFORK = -11, |
32 | CCERR_OVERFLOW = -12, |
33 | |
34 | CCERR_MEMORY_ALLOC_FAIL = -13, |
35 | |
36 | CCEC_GENERATE_KEY_DEFAULT_ERR = -14, |
37 | CCEC_GENERATE_KEY_TOO_MANY_TRIES = -15, |
38 | CCEC_GENERATE_KEY_MULT_FAIL = -16, |
39 | CCEC_GENERATE_KEY_AFF_FAIL = -17, |
40 | CCEC_GENERATE_KEY_CONSISTENCY = -18, |
41 | CCEC_GENERATE_NOT_ON_CURVE = -19, |
42 | CCEC_GENERATE_NOT_ENOUGH_ENTROPY = -20, |
43 | CCEC_GENERATE_NOT_SUPPORTED = -21, |
44 | CCEC_GENERATE_INVALID_INPUT = -22, |
45 | |
46 | // Program error: buffer too small or encrypted message is too small |
47 | CCRSA_INVALID_INPUT = -23, |
48 | // Invalid crypto configuration: Hash length versus RSA key size |
49 | CCRSA_INVALID_CONFIG = -24, |
50 | CCRSA_ENCODING_ERROR = -25, |
51 | CCRSA_DECODING_ERROR = -26, |
52 | |
53 | // The data is invalid (we won't say more for security) |
54 | CCRSA_PRIVATE_OP_ERROR = -27, |
55 | CCRSA_KEY_ERROR = -28, |
56 | |
57 | // Key generation specific |
58 | CCRSA_KEYGEN_PRIME_NOT_FOUND = -29, |
59 | CCRSA_KEYGEN_PRIME_NEED_NEW_SEED = -30, |
60 | CCRSA_KEYGEN_PRIME_TOO_MANY_ITERATIONS = -31, |
61 | CCRSA_KEYGEN_PRIME_SEED_GENERATION_ERROR = -32, |
62 | CCRSA_KEYGEN_MODULUS_CRT_INV_ERROR = -33, |
63 | CCRSA_KEYGEN_NEXT_PRIME_ERROR = -34, |
64 | CCRSA_KEYGEN_SEED_X_ERROR = -35, |
65 | CCRSA_KEYGEN_SEED_r_ERROR = -36, |
66 | CCRSA_KEYGEN_KEYGEN_CONSISTENCY_FAIL = -37, |
67 | CCRSA_KEYGEN_R1R2_SIZE_ERROR = -38, |
68 | CCRSA_KEYGEN_PQ_DELTA_ERROR = -39, |
69 | |
70 | CCRSA_FIPS_KEYGEN_DISABLED = -40, |
71 | |
72 | CCZP_INV_ERROR = -41, |
73 | CCZP_INV_NO_INVERSE = -42, |
74 | CCZP_INV_INVALID_INPUT = -43, |
75 | |
76 | CCZ_INVALID_INPUT_ERROR = -44, |
77 | CCZ_INVALID_RADIX_ERROR = -45, |
78 | |
79 | CCDH_ERROR_DEFAULT = -46, |
80 | CCDH_GENERATE_KEY_TOO_MANY_TRIES = -47, |
81 | CCDH_NOT_SUPPORTED_CONFIGURATION = -48, |
82 | CCDH_SAFETY_CHECK = -49, |
83 | CCDH_PUBLIC_KEY_MISSING = -50, |
84 | CCDH_INVALID_DOMAIN_PARAMETER = -51, |
85 | CCDH_INVALID_INPUT = -52, |
86 | CCDH_DOMAIN_PARAMETER_MISMATCH = -53, |
87 | CCDH_GENERATE_KEY_CONSISTENCY = -54, |
88 | |
89 | CCSRP_ERROR_DEFAULT = -55, |
90 | CCSRP_GENERATE_KEY_TOO_MANY_TRIES = -56, |
91 | CCSRP_NOT_SUPPORTED_CONFIGURATION = -57, |
92 | CCSRP_SAFETY_CHECK = -58, |
93 | CCSRP_PUBLIC_KEY_MISSING = -59, |
94 | CCSRP_INVALID_DOMAIN_PARAMETER = -60, |
95 | |
96 | CCDRBG_STATUS_ERROR = -61, |
97 | CCDRBG_STATUS_NEED_RESEED = -62, |
98 | CCDRBG_STATUS_PARAM_ERROR = -63, |
99 | // If this value is returned, the caller must abort or panic the process for |
100 | // security reasons. For example in the case of catastrophic error in |
101 | // http://csrc.nist.gov/publications/drafts/800-90/sp800_90a_r1_draft.pdf |
102 | // ccdrbg calls abort() or panic(), if they are available in the system. |
103 | CCDRBG_STATUS_ABORT = -64, |
104 | |
105 | CCKPRNG_NEED_ENTROPY = -65, |
106 | CCKPRNG_ABORT = -66, |
107 | |
108 | CCMODE_INVALID_INPUT = -67, |
109 | CCMODE_INVALID_CALL_SEQUENCE = -68, |
110 | CCMODE_INTEGRITY_FAILURE = -69, |
111 | CCMODE_NOT_SUPPORTED = -70, |
112 | CCMODE_INTERNAL_ERROR = -71, |
113 | |
114 | // Configuration or unexpected issue |
115 | CCPOST_GENERIC_FAILURE = -72, |
116 | CCPOST_LIBRARY_ERROR = -73, |
117 | CCPOST_INTEGRITY_ERROR = -74, |
118 | // Output of the algo is not as expected |
119 | CCPOST_KAT_FAILURE = -75, |
120 | |
121 | CCKPRNG_SEEDFILE_OPEN = -76, |
122 | CCKPRNG_SEEDFILE_READ = -78, |
123 | CCKPRNG_SEEDFILE_WRITE = -79, |
124 | CCKPRNG_SEEDFILE_CHMOD = -80, |
125 | CCKPRNG_SEEDFILE_CHOWN = -81, |
126 | CCKPRNG_RANDOMDEV_OPEN = -82, |
127 | CCKPRNG_RANDOMDEV_WRITE = -83, |
128 | CCKPRNG_GETENTROPY = -84, |
129 | |
130 | CCSAE_HUNTPECK_EXCEEDED_MAX_TRIALS = -85, |
131 | |
132 | CCERR_CALL_SEQUENCE = -86, |
133 | |
134 | CCVRF_POINT_DECODE_FAILURE = -87, |
135 | CCVRF_POINT_INVALID_PUBLIC_KEY = -88, |
136 | CCVRF_VERIFY_FAILURE = -89, |
137 | |
138 | // Error codes for Authenticated Encryption Modes |
139 | CCMODE_TAG_LENGTH_REQUEST_TOO_LONG = -100, |
140 | CCMODE_TAG_LENGTH_TOO_SHORT = -101, |
141 | CCMODE_NONCE_EMPTY = -102, |
142 | CCMODE_AD_EMPTY = -103, |
143 | CCMODE_DECRYPTION_OR_VERIFICATION_ERR=-104, |
144 | CCMODE_BUFFER_OUT_IN_OVERLAP = -105, |
145 | |
146 | // Error codes for Secret Sharing |
147 | CCSS_ELEMENT_TOO_LARGE_FOR_FIELD = -120, |
148 | CCSS_NOT_ENOUGH_SHARES = -121, |
149 | CCSS_TOO_MANY_SHARES = -122, |
150 | CCSS_IMPROPER_DEGREE = -123, |
151 | CCSS_TWO_SHARES_FOR_SAME_X = -124, |
152 | CCSS_THRESHOLD_NOT_LARGE_ENOUGH = -125, |
153 | CCSS_SHARE_BAG_FULL = -126, |
154 | CCSS_SHARE_ALREADY_PRESENT_IN_SHARE_BAG = -127, |
155 | CCSS_THRESHOLD_LARGER_OR_EQUAL_TO_FIELD = -128, |
156 | CCSS_TOO_MANY_SHARES_REQUESTED = -129, |
157 | CCSS_FIELD_MISMATCH = -130, |
158 | CCSS_INDEX_OUT_OF_RANGE = -131, |
159 | |
160 | CCSAE_NOT_ENOUGH_COMMIT_PARTIAL_CALLS = -132, |
161 | CCSAE_GENERATE_COMMIT_CALL_AGAIN = -133, |
162 | |
163 | CCERR_VALID_SIGNATURE = CCERR_OK, |
164 | CCERR_INVALID_SIGNATURE = -146, |
165 | |
166 | CCERR_IOSERVICE_GETMATCHING = -147, |
167 | CCERR_IOSERVICE_OPEN = -148, |
168 | CCERR_IOCONNECT_CALL = -149, |
169 | |
170 | CCEC_KEY_CANNOT_BE_UNIT = -160, |
171 | CCEC_COMPRESSED_POINT_ENCODING_ERROR = -161, |
172 | |
173 | CCERR_RNG_NOT_SEEDED = -162, |
174 | |
175 | CCERR_BUFFER_TOO_SMALL = -163, |
176 | |
177 | CCERR_XTS_KEYS_EQUAL = -164, |
178 | |
179 | CCERR_RETRY = -165, |
180 | |
181 | CCDH_GP_P_NOTPRIME = -166, |
182 | CCDH_GP_Q_NOTPRIME = -167, |
183 | CCDH_GP_NONSAFE_PRIME = -168, |
184 | |
185 | // -169, // deprecated |
186 | |
187 | CCEC_POINT_CANNOT_BE_UNIT = CCEC_KEY_CANNOT_BE_UNIT, |
188 | CCEC_UNCOMPRESSED_POINT_ENCODING_ERROR = -170, |
189 | CCEC_HYBRID_POINT_ENCODING_ERROR = -171, |
190 | CCEC_COMPACT_POINT_ENCODING_ERROR = -172, |
191 | |
192 | CCERR_NOT_SUPPORTED = -173, |
193 | |
194 | // Always add error codes above this line, and always keep |
195 | // their value greater than the value of CCERR_MIN. |
196 | CCERR_MIN = -255, |
197 | }; |
198 | |
199 | #define CCDRBG_STATUS_OK CCERR_OK |
200 | #define CCKPRNG_OK CCERR_OK |
201 | |
202 | #endif /* _CORECRYPTO_CC_ERROR_H_ */ |
203 | |