1183234Ssimon/* e_capi_err.c */
2183234Ssimon/* ====================================================================
3238405Sjkim * Copyright (c) 1999-2009 The OpenSSL Project.  All rights reserved.
4183234Ssimon *
5183234Ssimon * Redistribution and use in source and binary forms, with or without
6183234Ssimon * modification, are permitted provided that the following conditions
7183234Ssimon * are met:
8183234Ssimon *
9183234Ssimon * 1. Redistributions of source code must retain the above copyright
10280304Sjkim *    notice, this list of conditions and the following disclaimer.
11183234Ssimon *
12183234Ssimon * 2. Redistributions in binary form must reproduce the above copyright
13183234Ssimon *    notice, this list of conditions and the following disclaimer in
14183234Ssimon *    the documentation and/or other materials provided with the
15183234Ssimon *    distribution.
16183234Ssimon *
17183234Ssimon * 3. All advertising materials mentioning features or use of this
18183234Ssimon *    software must display the following acknowledgment:
19183234Ssimon *    "This product includes software developed by the OpenSSL Project
20183234Ssimon *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21183234Ssimon *
22183234Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23183234Ssimon *    endorse or promote products derived from this software without
24183234Ssimon *    prior written permission. For written permission, please contact
25183234Ssimon *    openssl-core@OpenSSL.org.
26183234Ssimon *
27183234Ssimon * 5. Products derived from this software may not be called "OpenSSL"
28183234Ssimon *    nor may "OpenSSL" appear in their names without prior written
29183234Ssimon *    permission of the OpenSSL Project.
30183234Ssimon *
31183234Ssimon * 6. Redistributions of any form whatsoever must retain the following
32183234Ssimon *    acknowledgment:
33183234Ssimon *    "This product includes software developed by the OpenSSL Project
34183234Ssimon *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35183234Ssimon *
36183234Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37183234Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38183234Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39183234Ssimon * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
40183234Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41183234Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42183234Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43183234Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44183234Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45183234Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46183234Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47183234Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE.
48183234Ssimon * ====================================================================
49183234Ssimon *
50183234Ssimon * This product includes cryptographic software written by Eric Young
51183234Ssimon * (eay@cryptsoft.com).  This product includes software written by Tim
52183234Ssimon * Hudson (tjh@cryptsoft.com).
53183234Ssimon *
54183234Ssimon */
55183234Ssimon
56280304Sjkim/*
57280304Sjkim * NOTE: this file was auto generated by the mkerr.pl script: any changes
58183234Ssimon * made to it will be overwritten when the script next updates this file,
59183234Ssimon * only reason strings will be preserved.
60183234Ssimon */
61183234Ssimon
62183234Ssimon#include <stdio.h>
63183234Ssimon#include <openssl/err.h>
64183234Ssimon#include "e_capi_err.h"
65183234Ssimon
66183234Ssimon/* BEGIN ERROR CODES */
67183234Ssimon#ifndef OPENSSL_NO_ERR
68183234Ssimon
69280304Sjkim# define ERR_FUNC(func) ERR_PACK(0,func,0)
70280304Sjkim# define ERR_REASON(reason) ERR_PACK(0,0,reason)
71183234Ssimon
72280304Sjkimstatic ERR_STRING_DATA CAPI_str_functs[] = {
73280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_CERT_GET_FNAME), "CAPI_CERT_GET_FNAME"},
74280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_CTRL), "CAPI_CTRL"},
75280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_CTX_NEW), "CAPI_CTX_NEW"},
76280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_CTX_SET_PROVNAME), "CAPI_CTX_SET_PROVNAME"},
77280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_DSA_DO_SIGN), "CAPI_DSA_DO_SIGN"},
78280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_GET_KEY), "CAPI_GET_KEY"},
79280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_GET_PKEY), "CAPI_GET_PKEY"},
80280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_GET_PROVNAME), "CAPI_GET_PROVNAME"},
81280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_GET_PROV_INFO), "CAPI_GET_PROV_INFO"},
82280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_INIT), "CAPI_INIT"},
83280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_LIST_CONTAINERS), "CAPI_LIST_CONTAINERS"},
84280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_LOAD_PRIVKEY), "CAPI_LOAD_PRIVKEY"},
85280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_OPEN_STORE), "CAPI_OPEN_STORE"},
86280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_RSA_PRIV_DEC), "CAPI_RSA_PRIV_DEC"},
87280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_RSA_PRIV_ENC), "CAPI_RSA_PRIV_ENC"},
88280304Sjkim    {ERR_FUNC(CAPI_F_CAPI_RSA_SIGN), "CAPI_RSA_SIGN"},
89280304Sjkim    {ERR_FUNC(CAPI_F_CERT_SELECT_DIALOG), "CERT_SELECT_DIALOG"},
90280304Sjkim    {ERR_FUNC(CAPI_F_CLIENT_CERT_SELECT), "CLIENT_CERT_SELECT"},
91280304Sjkim    {ERR_FUNC(CAPI_F_WIDE_TO_ASC), "WIDE_TO_ASC"},
92280304Sjkim    {0, NULL}
93280304Sjkim};
94183234Ssimon
95280304Sjkimstatic ERR_STRING_DATA CAPI_str_reasons[] = {
96280304Sjkim    {ERR_REASON(CAPI_R_CANT_CREATE_HASH_OBJECT), "cant create hash object"},
97280304Sjkim    {ERR_REASON(CAPI_R_CANT_FIND_CAPI_CONTEXT), "cant find capi context"},
98280304Sjkim    {ERR_REASON(CAPI_R_CANT_GET_KEY), "cant get key"},
99280304Sjkim    {ERR_REASON(CAPI_R_CANT_SET_HASH_VALUE), "cant set hash value"},
100280304Sjkim    {ERR_REASON(CAPI_R_CRYPTACQUIRECONTEXT_ERROR),
101280304Sjkim     "cryptacquirecontext error"},
102280304Sjkim    {ERR_REASON(CAPI_R_CRYPTENUMPROVIDERS_ERROR), "cryptenumproviders error"},
103280304Sjkim    {ERR_REASON(CAPI_R_DECRYPT_ERROR), "decrypt error"},
104280304Sjkim    {ERR_REASON(CAPI_R_ENGINE_NOT_INITIALIZED), "engine not initialized"},
105280304Sjkim    {ERR_REASON(CAPI_R_ENUMCONTAINERS_ERROR), "enumcontainers error"},
106280304Sjkim    {ERR_REASON(CAPI_R_ERROR_ADDING_CERT), "error adding cert"},
107280304Sjkim    {ERR_REASON(CAPI_R_ERROR_CREATING_STORE), "error creating store"},
108280304Sjkim    {ERR_REASON(CAPI_R_ERROR_GETTING_FRIENDLY_NAME),
109280304Sjkim     "error getting friendly name"},
110280304Sjkim    {ERR_REASON(CAPI_R_ERROR_GETTING_KEY_PROVIDER_INFO),
111280304Sjkim     "error getting key provider info"},
112280304Sjkim    {ERR_REASON(CAPI_R_ERROR_OPENING_STORE), "error opening store"},
113280304Sjkim    {ERR_REASON(CAPI_R_ERROR_SIGNING_HASH), "error signing hash"},
114280304Sjkim    {ERR_REASON(CAPI_R_FUNCTION_NOT_SUPPORTED), "function not supported"},
115280304Sjkim    {ERR_REASON(CAPI_R_GETUSERKEY_ERROR), "getuserkey error"},
116280304Sjkim    {ERR_REASON(CAPI_R_INVALID_DIGEST_LENGTH), "invalid digest length"},
117280304Sjkim    {ERR_REASON(CAPI_R_INVALID_DSA_PUBLIC_KEY_BLOB_MAGIC_NUMBER),
118280304Sjkim     "invalid dsa public key blob magic number"},
119280304Sjkim    {ERR_REASON(CAPI_R_INVALID_LOOKUP_METHOD), "invalid lookup method"},
120280304Sjkim    {ERR_REASON(CAPI_R_INVALID_PUBLIC_KEY_BLOB), "invalid public key blob"},
121280304Sjkim    {ERR_REASON(CAPI_R_INVALID_RSA_PUBLIC_KEY_BLOB_MAGIC_NUMBER),
122280304Sjkim     "invalid rsa public key blob magic number"},
123280304Sjkim    {ERR_REASON(CAPI_R_PUBKEY_EXPORT_ERROR), "pubkey export error"},
124280304Sjkim    {ERR_REASON(CAPI_R_PUBKEY_EXPORT_LENGTH_ERROR),
125280304Sjkim     "pubkey export length error"},
126280304Sjkim    {ERR_REASON(CAPI_R_UNKNOWN_COMMAND), "unknown command"},
127280304Sjkim    {ERR_REASON(CAPI_R_UNSUPPORTED_ALGORITHM_NID),
128280304Sjkim     "unsupported algorithm nid"},
129280304Sjkim    {ERR_REASON(CAPI_R_UNSUPPORTED_PADDING), "unsupported padding"},
130280304Sjkim    {ERR_REASON(CAPI_R_UNSUPPORTED_PUBLIC_KEY_ALGORITHM),
131280304Sjkim     "unsupported public key algorithm"},
132280304Sjkim    {ERR_REASON(CAPI_R_WIN32_ERROR), "win32 error"},
133280304Sjkim    {0, NULL}
134280304Sjkim};
135183234Ssimon
136183234Ssimon#endif
137183234Ssimon
138183234Ssimon#ifdef CAPI_LIB_NAME
139280304Sjkimstatic ERR_STRING_DATA CAPI_lib_name[] = {
140280304Sjkim    {0, CAPI_LIB_NAME},
141280304Sjkim    {0, NULL}
142280304Sjkim};
143183234Ssimon#endif
144183234Ssimon
145280304Sjkimstatic int CAPI_lib_error_code = 0;
146280304Sjkimstatic int CAPI_error_init = 1;
147183234Ssimon
148183234Ssimonstatic void ERR_load_CAPI_strings(void)
149280304Sjkim{
150280304Sjkim    if (CAPI_lib_error_code == 0)
151280304Sjkim        CAPI_lib_error_code = ERR_get_next_error_library();
152183234Ssimon
153280304Sjkim    if (CAPI_error_init) {
154280304Sjkim        CAPI_error_init = 0;
155183234Ssimon#ifndef OPENSSL_NO_ERR
156280304Sjkim        ERR_load_strings(CAPI_lib_error_code, CAPI_str_functs);
157280304Sjkim        ERR_load_strings(CAPI_lib_error_code, CAPI_str_reasons);
158183234Ssimon#endif
159183234Ssimon
160183234Ssimon#ifdef CAPI_LIB_NAME
161280304Sjkim        CAPI_lib_name->error = ERR_PACK(CAPI_lib_error_code, 0, 0);
162280304Sjkim        ERR_load_strings(0, CAPI_lib_name);
163183234Ssimon#endif
164280304Sjkim    }
165280304Sjkim}
166183234Ssimon
167183234Ssimonstatic void ERR_unload_CAPI_strings(void)
168280304Sjkim{
169280304Sjkim    if (CAPI_error_init == 0) {
170183234Ssimon#ifndef OPENSSL_NO_ERR
171280304Sjkim        ERR_unload_strings(CAPI_lib_error_code, CAPI_str_functs);
172280304Sjkim        ERR_unload_strings(CAPI_lib_error_code, CAPI_str_reasons);
173183234Ssimon#endif
174183234Ssimon
175183234Ssimon#ifdef CAPI_LIB_NAME
176280304Sjkim        ERR_unload_strings(0, CAPI_lib_name);
177183234Ssimon#endif
178280304Sjkim        CAPI_error_init = 1;
179280304Sjkim    }
180280304Sjkim}
181183234Ssimon
182183234Ssimonstatic void ERR_CAPI_error(int function, int reason, char *file, int line)
183280304Sjkim{
184280304Sjkim    if (CAPI_lib_error_code == 0)
185280304Sjkim        CAPI_lib_error_code = ERR_get_next_error_library();
186280304Sjkim    ERR_PUT_error(CAPI_lib_error_code, function, reason, file, line);
187280304Sjkim}
188