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