10Sstevel@tonic-gate /*
27211Sjp161948 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
30Sstevel@tonic-gate * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate
60Sstevel@tonic-gate /* crypto/engine/hw_pk11_err.c */
7*7616SVladimir.Kotal@Sun.COM /*
8*7616SVladimir.Kotal@Sun.COM * This product includes software developed by the OpenSSL Project for
90Sstevel@tonic-gate * use in the OpenSSL Toolkit (http://www.openssl.org/).
100Sstevel@tonic-gate *
11*7616SVladimir.Kotal@Sun.COM * This project also referenced hw_pkcs11-0.9.7b.patch written by
120Sstevel@tonic-gate * Afchine Madjlessi.
130Sstevel@tonic-gate */
14*7616SVladimir.Kotal@Sun.COM /*
15*7616SVladimir.Kotal@Sun.COM * ====================================================================
160Sstevel@tonic-gate * Copyright (c) 2000-2001 The OpenSSL Project. All rights reserved.
170Sstevel@tonic-gate *
180Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
190Sstevel@tonic-gate * modification, are permitted provided that the following conditions
200Sstevel@tonic-gate * are met:
210Sstevel@tonic-gate *
220Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
23*7616SVladimir.Kotal@Sun.COM * notice, this list of conditions and the following disclaimer.
240Sstevel@tonic-gate *
250Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
260Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in
270Sstevel@tonic-gate * the documentation and/or other materials provided with the
280Sstevel@tonic-gate * distribution.
290Sstevel@tonic-gate *
300Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this
310Sstevel@tonic-gate * software must display the following acknowledgment:
320Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
330Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
340Sstevel@tonic-gate *
350Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
360Sstevel@tonic-gate * endorse or promote products derived from this software without
370Sstevel@tonic-gate * prior written permission. For written permission, please contact
380Sstevel@tonic-gate * licensing@OpenSSL.org.
390Sstevel@tonic-gate *
400Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL"
410Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written
420Sstevel@tonic-gate * permission of the OpenSSL Project.
430Sstevel@tonic-gate *
440Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following
450Sstevel@tonic-gate * acknowledgment:
460Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
470Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
480Sstevel@tonic-gate *
490Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
500Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
510Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
520Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
530Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
540Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
550Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
560Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
570Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
580Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
590Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
600Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE.
610Sstevel@tonic-gate * ====================================================================
620Sstevel@tonic-gate *
630Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young
640Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim
650Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com).
660Sstevel@tonic-gate *
670Sstevel@tonic-gate */
680Sstevel@tonic-gate
690Sstevel@tonic-gate #include <stdio.h>
700Sstevel@tonic-gate #include <openssl/err.h>
710Sstevel@tonic-gate #include "hw_pk11_err.h"
720Sstevel@tonic-gate
730Sstevel@tonic-gate /* BEGIN ERROR CODES */
740Sstevel@tonic-gate #ifndef OPENSSL_NO_ERR
750Sstevel@tonic-gate static ERR_STRING_DATA pk11_str_functs[]=
760Sstevel@tonic-gate {
77*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_INIT, 0), "PK11_INIT"},
78*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_FINISH, 0), "PK11_FINISH"},
79*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DESTROY, 0), "PK11_DESTROY"},
80*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CTRL, 0), "PK11_CTRL"},
81*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_INIT, 0), "PK11_RSA_INIT"},
82*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_FINISH, 0), "PK11_RSA_FINISH"},
83*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_PUB_RSA_KEY, 0), "PK11_GET_PUB_RSA_KEY"},
84*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_PRIV_RSA_KEY, 0), "PK11_GET_PRIV_RSA_KEY"},
85*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_GEN_KEY, 0), "PK11_RSA_GEN_KEY"},
86*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PUB_ENC, 0), "PK11_RSA_PUB_ENC"},
87*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PRIV_ENC, 0), "PK11_RSA_PRIV_ENC"},
88*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PUB_DEC, 0), "PK11_RSA_PUB_DEC"},
89*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PRIV_DEC, 0), "PK11_RSA_PRIV_DEC"},
90*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_SIGN, 0), "PK11_RSA_SIGN"},
91*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_VERIFY, 0), "PK11_RSA_VERIFY"},
92*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RAND_ADD, 0), "PK11_RAND_ADD"},
93*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RAND_BYTES, 0), "PK11_RAND_BYTES"},
94*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_SESSION, 0), "PK11_GET_SESSION"},
95*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_FREE_SESSION, 0), "PK11_FREE_SESSION"},
96*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_LOAD_PUBKEY, 0), "PK11_LOAD_PUBKEY"},
97*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_LOAD_PRIVKEY, 0), "PK11_LOAD_PRIV_KEY"},
98*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PUB_ENC_LOW, 0), "PK11_RSA_PUB_ENC_LOW"},
99*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PRIV_ENC_LOW, 0), "PK11_RSA_PRIV_ENC_LOW"},
100*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PUB_DEC_LOW, 0), "PK11_RSA_PUB_DEC_LOW"},
101*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_RSA_PRIV_DEC_LOW, 0), "PK11_RSA_PRIV_DEC_LOW"},
102*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DSA_SIGN, 0), "PK11_DSA_SIGN"},
103*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DSA_VERIFY, 0), "PK11_DSA_VERIFY"},
104*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DSA_INIT, 0), "PK11_DSA_INIT"},
105*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DSA_FINISH, 0), "PK11_DSA_FINISH"},
106*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_PUB_DSA_KEY, 0), "PK11_GET_PUB_DSA_KEY"},
107*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_PRIV_DSA_KEY, 0), "PK11_GET_PRIV_DSA_KEY"},
108*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DH_INIT, 0), "PK11_DH_INIT"},
109*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DH_FINISH, 0), "PK11_DH_FINISH"},
110*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_MOD_EXP_DH, 0), "PK11_MOD_EXP_DH"},
111*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_DH_KEY, 0), "PK11_GET_DH_KEY"},
112*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_FREE_ALL_SESSIONS, 0), "PK11_FREE_ALL_SESSIONS"},
113*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_SETUP_SESSION, 0), "PK11_SETUP_SESSION"},
114*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DESTROY_OBJECT, 0), "PK11_DESTROY_OBJECT"},
115*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CIPHER_INIT, 0), "PK11_CIPHER_INIT"},
116*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CIPHER_DO_CIPHER, 0), "PK11_CIPHER_DO_CIPHER"},
117*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_GET_CIPHER_KEY, 0), "PK11_GET_CIPHER_KEY"},
118*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DIGEST_INIT, 0), "PK11_DIGEST_INIT"},
119*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DIGEST_UPDATE, 0), "PK11_DIGEST_UPDATE"},
120*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DIGEST_FINAL, 0), "PK11_DIGEST_FINAL"},
121*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CHOOSE_SLOT, 0), "PK11_CHOOSE_SLOT"},
122*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CIPHER_FINAL, 0), "PK11_CIPHER_FINAL"},
123*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_LIBRARY_INIT, 0), "PK11_LIBRARY_INIT"},
124*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_LOAD, 0), "ENGINE_LOAD_PK11"},
125*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DH_GEN_KEY, 0), "PK11_DH_GEN_KEY"},
126*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DH_COMP_KEY, 0), "PK11_DH_COMP_KEY"},
127*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_DIGEST_COPY, 0), "PK11_DIGEST_COPY"},
128*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CIPHER_CLEANUP, 0), "PK11_CIPHER_CLEANUP"},
129*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_ACTIVE_ADD, 0), "PK11_ACTIVE_ADD"},
130*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_ACTIVE_DELETE, 0), "PK11_ACTIVE_DELETE"},
131*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_CHECK_HW_MECHANISMS, 0), "PK11_CHECK_HW_MECHANISMS"},
132*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_INIT_SYMMETRIC, 0), "PK11_INIT_SYMMETRIC"},
133*7616SVladimir.Kotal@Sun.COM { ERR_PACK(0, PK11_F_ADD_AES_CTR_NIDS, 0), "PK11_ADD_AES_CTR_NIDS"},
134*7616SVladimir.Kotal@Sun.COM { 0, NULL}
1350Sstevel@tonic-gate };
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate static ERR_STRING_DATA pk11_str_reasons[]=
1380Sstevel@tonic-gate {
139*7616SVladimir.Kotal@Sun.COM { PK11_R_ALREADY_LOADED, "PKCS#11 DSO already loaded"},
140*7616SVladimir.Kotal@Sun.COM { PK11_R_DSO_FAILURE, "unable to load PKCS#11 DSO"},
141*7616SVladimir.Kotal@Sun.COM { PK11_R_NOT_LOADED, "PKCS#11 DSO not loaded"},
142*7616SVladimir.Kotal@Sun.COM { PK11_R_PASSED_NULL_PARAMETER, "null parameter passed"},
143*7616SVladimir.Kotal@Sun.COM { PK11_R_COMMAND_NOT_IMPLEMENTED, "command not implemented"},
144*7616SVladimir.Kotal@Sun.COM { PK11_R_INITIALIZE, "C_Initialize failed"},
145*7616SVladimir.Kotal@Sun.COM { PK11_R_FINALIZE, "C_Finalize failed"},
146*7616SVladimir.Kotal@Sun.COM { PK11_R_GETINFO, "C_GetInfo faile"},
147*7616SVladimir.Kotal@Sun.COM { PK11_R_GETSLOTLIST, "C_GetSlotList failed"},
148*7616SVladimir.Kotal@Sun.COM { PK11_R_NO_MODULUS_OR_NO_EXPONENT, "no modulus or no exponent"},
149*7616SVladimir.Kotal@Sun.COM { PK11_R_ATTRIBUT_SENSITIVE_OR_INVALID, "attr sensitive or invalid"},
150*7616SVladimir.Kotal@Sun.COM { PK11_R_GETATTRIBUTVALUE, "C_GetAttributeValue failed"},
151*7616SVladimir.Kotal@Sun.COM { PK11_R_NO_MODULUS, "no modulus"},
152*7616SVladimir.Kotal@Sun.COM { PK11_R_NO_EXPONENT, "no exponent"},
153*7616SVladimir.Kotal@Sun.COM { PK11_R_FINDOBJECTSINIT, "C_FindObjectsInit failed"},
154*7616SVladimir.Kotal@Sun.COM { PK11_R_FINDOBJECTS, "C_FindObjects failed"},
155*7616SVladimir.Kotal@Sun.COM { PK11_R_FINDOBJECTSFINAL, "C_FindObjectsFinal failed"},
156*7616SVladimir.Kotal@Sun.COM { PK11_R_CREATEOBJECT, "C_CreateObject failed"},
157*7616SVladimir.Kotal@Sun.COM { PK11_R_DESTROYOBJECT, "C_DestroyObject failed"},
158*7616SVladimir.Kotal@Sun.COM { PK11_R_OPENSESSION, "C_OpenSession failed"},
159*7616SVladimir.Kotal@Sun.COM { PK11_R_CLOSESESSION, "C_CloseSession failed"},
160*7616SVladimir.Kotal@Sun.COM { PK11_R_ENCRYPTINIT, "C_EncryptInit failed"},
161*7616SVladimir.Kotal@Sun.COM { PK11_R_ENCRYPT, "C_Encrypt failed"},
162*7616SVladimir.Kotal@Sun.COM { PK11_R_SIGNINIT, "C_SignInit failed"},
163*7616SVladimir.Kotal@Sun.COM { PK11_R_SIGN, "C_Sign failed"},
164*7616SVladimir.Kotal@Sun.COM { PK11_R_DECRYPTINIT, "C_DecryptInit failed"},
165*7616SVladimir.Kotal@Sun.COM { PK11_R_DECRYPT, "C_Decrypt failed"},
166*7616SVladimir.Kotal@Sun.COM { PK11_R_VERIFYINIT, "C_VerifyRecover failed"},
167*7616SVladimir.Kotal@Sun.COM { PK11_R_VERIFY, "C_Verify failed"},
168*7616SVladimir.Kotal@Sun.COM { PK11_R_VERIFYRECOVERINIT, "C_VerifyRecoverInit failed"},
169*7616SVladimir.Kotal@Sun.COM { PK11_R_VERIFYRECOVER, "C_VerifyRecover failed"},
170*7616SVladimir.Kotal@Sun.COM { PK11_R_GEN_KEY, "C_GenerateKeyPair failed"},
171*7616SVladimir.Kotal@Sun.COM { PK11_R_SEEDRANDOM, "C_SeedRandom failed"},
172*7616SVladimir.Kotal@Sun.COM { PK11_R_GENERATERANDOM, "C_GenerateRandom failed"},
173*7616SVladimir.Kotal@Sun.COM { PK11_R_INVALID_MESSAGE_LENGTH, "invalid message length"},
174*7616SVladimir.Kotal@Sun.COM { PK11_R_UNKNOWN_ALGORITHM_TYPE, "unknown algorithm type"},
175*7616SVladimir.Kotal@Sun.COM { PK11_R_UNKNOWN_ASN1_OBJECT_ID, "unknown asn1 onject id"},
176*7616SVladimir.Kotal@Sun.COM { PK11_R_UNKNOWN_PADDING_TYPE, "unknown padding type"},
177*7616SVladimir.Kotal@Sun.COM { PK11_R_PADDING_CHECK_FAILED, "padding check failed"},
178*7616SVladimir.Kotal@Sun.COM { PK11_R_DIGEST_TOO_BIG, "digest too big"},
179*7616SVladimir.Kotal@Sun.COM { PK11_R_MALLOC_FAILURE, "malloc failure"},
180*7616SVladimir.Kotal@Sun.COM { PK11_R_CTRL_COMMAND_NOT_IMPLEMENTED, "ctl command not implemented"},
181*7616SVladimir.Kotal@Sun.COM { PK11_R_DATA_GREATER_THAN_MOD_LEN, "data is bigger than mod"},
182*7616SVladimir.Kotal@Sun.COM { PK11_R_DATA_TOO_LARGE_FOR_MODULUS, "data is too larger for mod"},
183*7616SVladimir.Kotal@Sun.COM { PK11_R_MISSING_KEY_COMPONENT, "a dsa component is missing"},
184*7616SVladimir.Kotal@Sun.COM { PK11_R_INVALID_SIGNATURE_LENGTH, "invalid signature length"},
185*7616SVladimir.Kotal@Sun.COM { PK11_R_INVALID_DSA_SIGNATURE_R, "missing r in dsa verify"},
186*7616SVladimir.Kotal@Sun.COM { PK11_R_INVALID_DSA_SIGNATURE_S, "missing s in dsa verify"},
187*7616SVladimir.Kotal@Sun.COM { PK11_R_INCONSISTENT_KEY, "inconsistent key type"},
188*7616SVladimir.Kotal@Sun.COM { PK11_R_ENCRYPTUPDATE, "C_EncryptUpdate failed"},
189*7616SVladimir.Kotal@Sun.COM { PK11_R_DECRYPTUPDATE, "C_DecryptUpdate failed"},
190*7616SVladimir.Kotal@Sun.COM { PK11_R_DIGESTINIT, "C_DigestInit failed"},
191*7616SVladimir.Kotal@Sun.COM { PK11_R_DIGESTUPDATE, "C_DigestUpdate failed"},
192*7616SVladimir.Kotal@Sun.COM { PK11_R_DIGESTFINAL, "C_DigestFinal failed"},
193*7616SVladimir.Kotal@Sun.COM { PK11_R_ENCRYPTFINAL, "C_EncryptFinal failed"},
194*7616SVladimir.Kotal@Sun.COM { PK11_R_DECRYPTFINAL, "C_DecryptFinal failed"},
195*7616SVladimir.Kotal@Sun.COM { PK11_R_NO_PRNG_SUPPORT, "Slot does not support PRNG"},
196*7616SVladimir.Kotal@Sun.COM { PK11_R_GETTOKENINFO, "C_GetTokenInfo failed"},
197*7616SVladimir.Kotal@Sun.COM { PK11_R_DERIVEKEY, "C_DeriveKey failed"},
198*7616SVladimir.Kotal@Sun.COM { PK11_R_GET_OPERATION_STATE, "C_GetOperationState failed"},
199*7616SVladimir.Kotal@Sun.COM { PK11_R_SET_OPERATION_STATE, "C_SetOperationState failed"},
200*7616SVladimir.Kotal@Sun.COM { PK11_R_INVALID_HANDLE, "invalid PKCS#11 object handle"},
201*7616SVladimir.Kotal@Sun.COM { PK11_R_KEY_OR_IV_LEN_PROBLEM, "IV or key length incorrect"},
202*7616SVladimir.Kotal@Sun.COM { PK11_R_INVALID_OPERATION_TYPE, "invalid operation type"},
203*7616SVladimir.Kotal@Sun.COM { PK11_R_ADD_NID_FAILED, "failed to add NID" },
204*7616SVladimir.Kotal@Sun.COM { 0, NULL}
2050Sstevel@tonic-gate };
2067211Sjp161948 #endif /* OPENSSL_NO_ERR */
2070Sstevel@tonic-gate
208*7616SVladimir.Kotal@Sun.COM static int pk11_lib_error_code = 0;
209*7616SVladimir.Kotal@Sun.COM static int pk11_error_init = 1;
2100Sstevel@tonic-gate
211*7616SVladimir.Kotal@Sun.COM static void
ERR_load_pk11_strings(void)212*7616SVladimir.Kotal@Sun.COM ERR_load_pk11_strings(void)
213*7616SVladimir.Kotal@Sun.COM {
214*7616SVladimir.Kotal@Sun.COM if (pk11_lib_error_code == 0)
215*7616SVladimir.Kotal@Sun.COM pk11_lib_error_code = ERR_get_next_error_library();
2160Sstevel@tonic-gate
217*7616SVladimir.Kotal@Sun.COM if (pk11_error_init)
218*7616SVladimir.Kotal@Sun.COM {
219*7616SVladimir.Kotal@Sun.COM pk11_error_init = 0;
2200Sstevel@tonic-gate #ifndef OPENSSL_NO_ERR
221*7616SVladimir.Kotal@Sun.COM ERR_load_strings(pk11_lib_error_code, pk11_str_functs);
222*7616SVladimir.Kotal@Sun.COM ERR_load_strings(pk11_lib_error_code, pk11_str_reasons);
2230Sstevel@tonic-gate #endif
224*7616SVladimir.Kotal@Sun.COM }
2250Sstevel@tonic-gate }
2260Sstevel@tonic-gate
227*7616SVladimir.Kotal@Sun.COM static void
ERR_unload_pk11_strings(void)228*7616SVladimir.Kotal@Sun.COM ERR_unload_pk11_strings(void)
229*7616SVladimir.Kotal@Sun.COM {
230*7616SVladimir.Kotal@Sun.COM if (pk11_error_init == 0)
231*7616SVladimir.Kotal@Sun.COM {
2320Sstevel@tonic-gate #ifndef OPENSSL_NO_ERR
233*7616SVladimir.Kotal@Sun.COM ERR_unload_strings(pk11_lib_error_code, pk11_str_functs);
234*7616SVladimir.Kotal@Sun.COM ERR_unload_strings(pk11_lib_error_code, pk11_str_reasons);
2350Sstevel@tonic-gate #endif
236*7616SVladimir.Kotal@Sun.COM pk11_error_init = 1;
237*7616SVladimir.Kotal@Sun.COM }
2380Sstevel@tonic-gate }
2390Sstevel@tonic-gate
240*7616SVladimir.Kotal@Sun.COM void
ERR_pk11_error(int function,int reason,char * file,int line)241*7616SVladimir.Kotal@Sun.COM ERR_pk11_error(int function, int reason, char *file, int line)
2420Sstevel@tonic-gate {
243*7616SVladimir.Kotal@Sun.COM if (pk11_lib_error_code == 0)
244*7616SVladimir.Kotal@Sun.COM pk11_lib_error_code = ERR_get_next_error_library();
245*7616SVladimir.Kotal@Sun.COM ERR_PUT_error(pk11_lib_error_code, function, reason, file, line);
2460Sstevel@tonic-gate }
2477211Sjp161948
248*7616SVladimir.Kotal@Sun.COM void
PK11err_add_data(int function,int reason,CK_RV rv)249*7616SVladimir.Kotal@Sun.COM PK11err_add_data(int function, int reason, CK_RV rv)
2507211Sjp161948 {
2517211Sjp161948 char tmp_buf[20];
2527211Sjp161948
2537211Sjp161948 PK11err(function, reason);
2547211Sjp161948 (void) snprintf(tmp_buf, sizeof (tmp_buf), "%lx", rv);
2557211Sjp161948 ERR_add_error_data(2, "PK11 CK_RV=0X", tmp_buf);
2567211Sjp161948 }
257