2 * Copyright (c) 2003-2006,2008,2010 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 * secErrorStr.c - ASCII string version of NSS Sec layer error codes
31 } SecErrorNameValuePair
;
33 /* one entry in an array of SecErrorNameValuePairs */
34 #define SNVP(err) {err, #err}
36 /* the NULL entry which terminates the SecErrorNameValuePair list */
37 #define SNVP_END {0, NULL}
39 static const SecErrorNameValuePair errValues
[] =
41 /* FIXME: we really don't need all of these, but they're not
42 * compiled for NDEBUG builds. */
45 SNVP(SEC_ERROR_LIBRARY_FAILURE
),
46 SNVP(SEC_ERROR_BAD_DATA
),
47 SNVP(SEC_ERROR_OUTPUT_LEN
),
48 SNVP(SEC_ERROR_INPUT_LEN
),
49 SNVP(SEC_ERROR_INVALID_ARGS
),
50 SNVP(SEC_ERROR_INVALID_ALGORITHM
),
51 SNVP(SEC_ERROR_INVALID_AVA
),
52 SNVP(SEC_ERROR_INVALID_TIME
),
53 SNVP(SEC_ERROR_BAD_DER
),
54 SNVP(SEC_ERROR_BAD_SIGNATURE
),
55 SNVP(SEC_ERROR_EXPIRED_CERTIFICATE
),
56 SNVP(SEC_ERROR_REVOKED_CERTIFICATE
),
57 SNVP(SEC_ERROR_UNKNOWN_ISSUER
),
58 SNVP(SEC_ERROR_BAD_KEY
),
59 SNVP(SEC_ERROR_BAD_PASSWORD
),
60 SNVP(SEC_ERROR_RETRY_PASSWORD
),
61 SNVP(SEC_ERROR_NO_NODELOCK
),
62 SNVP(SEC_ERROR_BAD_DATABASE
),
63 SNVP(SEC_ERROR_NO_MEMORY
),
64 SNVP(SEC_ERROR_UNTRUSTED_ISSUER
),
65 SNVP(SEC_ERROR_UNTRUSTED_CERT
),
66 SNVP(SEC_ERROR_DUPLICATE_CERT
),
67 SNVP(SEC_ERROR_DUPLICATE_CERT_NAME
),
68 SNVP(SEC_ERROR_ADDING_CERT
),
69 SNVP(SEC_ERROR_FILING_KEY
),
70 SNVP(SEC_ERROR_NO_KEY
),
71 SNVP(SEC_ERROR_CERT_VALID
),
72 SNVP(SEC_ERROR_CERT_NOT_VALID
),
73 SNVP(SEC_ERROR_CERT_NO_RESPONSE
),
74 SNVP(SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE
),
75 SNVP(SEC_ERROR_CRL_EXPIRED
),
76 SNVP(SEC_ERROR_CRL_BAD_SIGNATURE
),
77 SNVP(SEC_ERROR_CRL_INVALID
),
78 SNVP(SEC_ERROR_EXTENSION_VALUE_INVALID
),
79 SNVP(SEC_ERROR_EXTENSION_NOT_FOUND
),
80 SNVP(SEC_ERROR_CA_CERT_INVALID
),
81 SNVP(SEC_ERROR_PATH_LEN_CONSTRAINT_INVALID
),
82 SNVP(SEC_ERROR_CERT_USAGES_INVALID
),
83 SNVP(SEC_INTERNAL_ONLY
),
84 SNVP(SEC_ERROR_INVALID_KEY
),
85 SNVP(SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION
),
86 SNVP(SEC_ERROR_OLD_CRL
),
87 SNVP(SEC_ERROR_NO_EMAIL_CERT
),
88 SNVP(SEC_ERROR_NO_RECIPIENT_CERTS_QUERY
),
89 SNVP(SEC_ERROR_NOT_A_RECIPIENT
),
90 SNVP(SEC_ERROR_PKCS7_KEYALG_MISMATCH
),
91 SNVP(SEC_ERROR_PKCS7_BAD_SIGNATURE
),
92 SNVP(SEC_ERROR_UNSUPPORTED_KEYALG
),
93 SNVP(SEC_ERROR_DECRYPTION_DISALLOWED
),
94 SNVP(XP_SEC_FORTEZZA_BAD_CARD
),
95 SNVP(XP_SEC_FORTEZZA_NO_CARD
),
96 SNVP(XP_SEC_FORTEZZA_NONE_SELECTED
),
97 SNVP(XP_SEC_FORTEZZA_MORE_INFO
),
98 SNVP(XP_SEC_FORTEZZA_PERSON_NOT_FOUND
),
99 SNVP(XP_SEC_FORTEZZA_NO_MORE_INFO
),
100 SNVP(XP_SEC_FORTEZZA_BAD_PIN
),
101 SNVP(XP_SEC_FORTEZZA_PERSON_ERROR
),
102 SNVP(SEC_ERROR_NO_KRL
),
103 SNVP(SEC_ERROR_KRL_EXPIRED
),
104 SNVP(SEC_ERROR_KRL_BAD_SIGNATURE
),
105 SNVP(SEC_ERROR_REVOKED_KEY
),
106 SNVP(SEC_ERROR_KRL_INVALID
),
107 SNVP(SEC_ERROR_NEED_RANDOM
),
108 SNVP(SEC_ERROR_NO_MODULE
),
109 SNVP(SEC_ERROR_NO_TOKEN
),
110 SNVP(SEC_ERROR_READ_ONLY
),
111 SNVP(SEC_ERROR_NO_SLOT_SELECTED
),
112 SNVP(SEC_ERROR_CERT_NICKNAME_COLLISION
),
113 SNVP(SEC_ERROR_KEY_NICKNAME_COLLISION
),
114 SNVP(SEC_ERROR_SAFE_NOT_CREATED
),
115 SNVP(SEC_ERROR_BAGGAGE_NOT_CREATED
),
116 SNVP(XP_JAVA_REMOVE_PRINCIPAL_ERROR
),
117 SNVP(XP_JAVA_DELETE_PRIVILEGE_ERROR
),
118 SNVP(XP_JAVA_CERT_NOT_EXISTS_ERROR
),
119 SNVP(SEC_ERROR_BAD_EXPORT_ALGORITHM
),
120 SNVP(SEC_ERROR_EXPORTING_CERTIFICATES
),
121 SNVP(SEC_ERROR_IMPORTING_CERTIFICATES
),
122 SNVP(SEC_ERROR_PKCS12_DECODING_PFX
),
123 SNVP(SEC_ERROR_PKCS12_INVALID_MAC
),
124 SNVP(SEC_ERROR_PKCS12_UNSUPPORTED_MAC_ALGORITHM
),
125 SNVP(SEC_ERROR_PKCS12_UNSUPPORTED_TRANSPORT_MODE
),
126 SNVP(SEC_ERROR_PKCS12_CORRUPT_PFX_STRUCTURE
),
127 SNVP(SEC_ERROR_PKCS12_UNSUPPORTED_PBE_ALGORITHM
),
128 SNVP(SEC_ERROR_PKCS12_UNSUPPORTED_VERSION
),
129 SNVP(SEC_ERROR_PKCS12_PRIVACY_PASSWORD_INCORRECT
),
130 SNVP(SEC_ERROR_PKCS12_CERT_COLLISION
),
131 SNVP(SEC_ERROR_USER_CANCELLED
),
132 SNVP(SEC_ERROR_PKCS12_DUPLICATE_DATA
),
133 SNVP(SEC_ERROR_MESSAGE_SEND_ABORTED
),
134 SNVP(SEC_ERROR_INADEQUATE_KEY_USAGE
),
135 SNVP(SEC_ERROR_INADEQUATE_CERT_TYPE
),
136 SNVP(SEC_ERROR_CERT_ADDR_MISMATCH
),
137 SNVP(SEC_ERROR_PKCS12_UNABLE_TO_IMPORT_KEY
),
138 SNVP(SEC_ERROR_PKCS12_IMPORTING_CERT_CHAIN
),
139 SNVP(SEC_ERROR_PKCS12_UNABLE_TO_LOCATE_OBJECT_BY_NAME
),
140 SNVP(SEC_ERROR_PKCS12_UNABLE_TO_EXPORT_KEY
),
141 SNVP(SEC_ERROR_PKCS12_UNABLE_TO_WRITE
),
142 SNVP(SEC_ERROR_PKCS12_UNABLE_TO_READ
),
143 SNVP(SEC_ERROR_PKCS12_KEY_DATABASE_NOT_INITIALIZED
),
144 SNVP(SEC_ERROR_KEYGEN_FAIL
),
145 SNVP(SEC_ERROR_INVALID_PASSWORD
),
146 SNVP(SEC_ERROR_RETRY_OLD_PASSWORD
),
147 SNVP(SEC_ERROR_BAD_NICKNAME
),
148 SNVP(SEC_ERROR_NOT_FORTEZZA_ISSUER
),
149 SNVP(SEC_ERROR_CANNOT_MOVE_SENSITIVE_KEY
),
150 SNVP(SEC_ERROR_JS_INVALID_MODULE_NAME
),
151 SNVP(SEC_ERROR_JS_INVALID_DLL
),
152 SNVP(SEC_ERROR_JS_ADD_MOD_FAILURE
),
153 SNVP(SEC_ERROR_JS_DEL_MOD_FAILURE
),
154 SNVP(SEC_ERROR_OLD_KRL
),
155 SNVP(SEC_ERROR_CKL_CONFLICT
),
156 SNVP(SEC_ERROR_CERT_NOT_IN_NAME_SPACE
),
157 SNVP(SEC_ERROR_KRL_NOT_YET_VALID
),
158 SNVP(SEC_ERROR_CRL_NOT_YET_VALID
),
159 SNVP(SEC_ERROR_UNKNOWN_CERT
),
160 SNVP(SEC_ERROR_UNKNOWN_SIGNER
),
161 SNVP(SEC_ERROR_CERT_BAD_ACCESS_LOCATION
),
162 SNVP(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE
),
163 SNVP(SEC_ERROR_OCSP_BAD_HTTP_RESPONSE
),
164 SNVP(SEC_ERROR_OCSP_MALFORMED_REQUEST
),
165 SNVP(SEC_ERROR_OCSP_SERVER_ERROR
),
166 SNVP(SEC_ERROR_OCSP_TRY_SERVER_LATER
),
167 SNVP(SEC_ERROR_OCSP_REQUEST_NEEDS_SIG
),
168 SNVP(SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST
),
169 SNVP(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS
),
170 SNVP(SEC_ERROR_OCSP_UNKNOWN_CERT
),
171 SNVP(SEC_ERROR_OCSP_NOT_ENABLED
),
172 SNVP(SEC_ERROR_OCSP_NO_DEFAULT_RESPONDER
),
173 SNVP(SEC_ERROR_OCSP_MALFORMED_RESPONSE
),
174 SNVP(SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE
),
175 SNVP(SEC_ERROR_OCSP_FUTURE_RESPONSE
),
176 SNVP(SEC_ERROR_OCSP_OLD_RESPONSE
),
177 SNVP(SEC_ERROR_DIGEST_NOT_FOUND
),
178 SNVP(SEC_ERROR_UNSUPPORTED_MESSAGE_TYPE
),
179 SNVP(SEC_ERROR_MODULE_STUCK
),
180 SNVP(SEC_ERROR_BAD_TEMPLATE
),
181 SNVP(SEC_ERROR_CRL_NOT_FOUND
),
182 SNVP(SEC_ERROR_REUSED_ISSUER_AND_SERIAL
),
183 SNVP(SEC_ERROR_BUSY
),
189 * Given a PRErrorCode, obtain a const C string. Not copied, not
190 * to be freed by caller.
192 const char *SECErrorString(PRErrorCode err
)
194 static char badStr
[100];
195 const SecErrorNameValuePair
*nvp
= errValues
;
197 while(nvp
->name
!= NULL
) {
198 if(nvp
->value
== err
) {
204 /* Not found, not thread safe */
205 sprintf(badStr
, "UNKNOWN (%d(d)", err
);