components/openssl/openssl-1.0.0/engines/pkcs11/hw_pk11_err.c
changeset 363 9c0cad004039
equal deleted inserted replaced
362:e1cadde52f4c 363:9c0cad004039
       
     1 /*
       
     2  * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
       
     3  */
       
     4 
       
     5 /* crypto/engine/hw_pk11_err.c */
       
     6 /*
       
     7  * This product includes software developed by the OpenSSL Project for
       
     8  * use in the OpenSSL Toolkit (http://www.openssl.org/).
       
     9  *
       
    10  * This project also referenced hw_pkcs11-0.9.7b.patch written by
       
    11  * Afchine Madjlessi.
       
    12  */
       
    13 /*
       
    14  * ====================================================================
       
    15  * Copyright (c) 2000-2001 The OpenSSL Project.  All rights reserved.
       
    16  *
       
    17  * Redistribution and use in source and binary forms, with or without
       
    18  * modification, are permitted provided that the following conditions
       
    19  * are met:
       
    20  *
       
    21  * 1. Redistributions of source code must retain the above copyright
       
    22  *    notice, this list of conditions and the following disclaimer.
       
    23  *
       
    24  * 2. Redistributions in binary form must reproduce the above copyright
       
    25  *    notice, this list of conditions and the following disclaimer in
       
    26  *    the documentation and/or other materials provided with the
       
    27  *    distribution.
       
    28  *
       
    29  * 3. All advertising materials mentioning features or use of this
       
    30  *    software must display the following acknowledgment:
       
    31  *    "This product includes software developed by the OpenSSL Project
       
    32  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
       
    33  *
       
    34  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
       
    35  *    endorse or promote products derived from this software without
       
    36  *    prior written permission. For written permission, please contact
       
    37  *    [email protected].
       
    38  *
       
    39  * 5. Products derived from this software may not be called "OpenSSL"
       
    40  *    nor may "OpenSSL" appear in their names without prior written
       
    41  *    permission of the OpenSSL Project.
       
    42  *
       
    43  * 6. Redistributions of any form whatsoever must retain the following
       
    44  *    acknowledgment:
       
    45  *    "This product includes software developed by the OpenSSL Project
       
    46  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
       
    47  *
       
    48  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
       
    49  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    51  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
       
    52  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       
    53  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
       
    54  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    55  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    56  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
       
    57  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
       
    58  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
       
    59  * OF THE POSSIBILITY OF SUCH DAMAGE.
       
    60  * ====================================================================
       
    61  *
       
    62  * This product includes cryptographic software written by Eric Young
       
    63  * ([email protected]).  This product includes software written by Tim
       
    64  * Hudson ([email protected]).
       
    65  *
       
    66  */
       
    67 
       
    68 #include <stdio.h>
       
    69 #include <openssl/err.h>
       
    70 #include "hw_pk11_err.h"
       
    71 
       
    72 /* BEGIN ERROR CODES */
       
    73 #ifndef OPENSSL_NO_ERR
       
    74 static ERR_STRING_DATA pk11_str_functs[]=
       
    75 {
       
    76 { ERR_PACK(0, PK11_F_INIT, 0),			"PK11_INIT"},
       
    77 { ERR_PACK(0, PK11_F_FINISH, 0),		"PK11_FINISH"},
       
    78 { ERR_PACK(0, PK11_F_DESTROY, 0),		"PK11_DESTROY"},
       
    79 { ERR_PACK(0, PK11_F_CTRL, 0),			"PK11_CTRL"},
       
    80 { ERR_PACK(0, PK11_F_RSA_INIT, 0),		"PK11_RSA_INIT"},
       
    81 { ERR_PACK(0, PK11_F_RSA_FINISH, 0),		"PK11_RSA_FINISH"},
       
    82 { ERR_PACK(0, PK11_F_GET_PUB_RSA_KEY, 0),	"PK11_GET_PUB_RSA_KEY"},
       
    83 { ERR_PACK(0, PK11_F_GET_PRIV_RSA_KEY, 0),	"PK11_GET_PRIV_RSA_KEY"},
       
    84 { ERR_PACK(0, PK11_F_RSA_GEN_KEY, 0),		"PK11_RSA_GEN_KEY"},
       
    85 { ERR_PACK(0, PK11_F_RSA_PUB_ENC, 0),		"PK11_RSA_PUB_ENC"},
       
    86 { ERR_PACK(0, PK11_F_RSA_PRIV_ENC, 0),		"PK11_RSA_PRIV_ENC"},
       
    87 { ERR_PACK(0, PK11_F_RSA_PUB_DEC, 0),		"PK11_RSA_PUB_DEC"},
       
    88 { ERR_PACK(0, PK11_F_RSA_PRIV_DEC, 0),		"PK11_RSA_PRIV_DEC"},
       
    89 { ERR_PACK(0, PK11_F_RSA_SIGN, 0),		"PK11_RSA_SIGN"},
       
    90 { ERR_PACK(0, PK11_F_RSA_VERIFY, 0),		"PK11_RSA_VERIFY"},
       
    91 { ERR_PACK(0, PK11_F_RAND_ADD, 0),		"PK11_RAND_ADD"},
       
    92 { ERR_PACK(0, PK11_F_RAND_BYTES, 0),		"PK11_RAND_BYTES"},
       
    93 { ERR_PACK(0, PK11_F_GET_SESSION, 0),		"PK11_GET_SESSION"},
       
    94 { ERR_PACK(0, PK11_F_FREE_SESSION, 0),		"PK11_FREE_SESSION"},
       
    95 { ERR_PACK(0, PK11_F_LOAD_PUBKEY, 0),		"PK11_LOAD_PUBKEY"},
       
    96 { ERR_PACK(0, PK11_F_LOAD_PRIVKEY, 0),		"PK11_LOAD_PRIV_KEY"},
       
    97 { ERR_PACK(0, PK11_F_RSA_PUB_ENC_LOW, 0),	"PK11_RSA_PUB_ENC_LOW"},
       
    98 { ERR_PACK(0, PK11_F_RSA_PRIV_ENC_LOW, 0),	"PK11_RSA_PRIV_ENC_LOW"},
       
    99 { ERR_PACK(0, PK11_F_RSA_PUB_DEC_LOW, 0),	"PK11_RSA_PUB_DEC_LOW"},
       
   100 { ERR_PACK(0, PK11_F_RSA_PRIV_DEC_LOW, 0),	"PK11_RSA_PRIV_DEC_LOW"},
       
   101 { ERR_PACK(0, PK11_F_DSA_SIGN, 0),		"PK11_DSA_SIGN"},
       
   102 { ERR_PACK(0, PK11_F_DSA_VERIFY, 0),		"PK11_DSA_VERIFY"},
       
   103 { ERR_PACK(0, PK11_F_DSA_INIT, 0),		"PK11_DSA_INIT"},
       
   104 { ERR_PACK(0, PK11_F_DSA_FINISH, 0),		"PK11_DSA_FINISH"},
       
   105 { ERR_PACK(0, PK11_F_GET_PUB_DSA_KEY, 0),	"PK11_GET_PUB_DSA_KEY"},
       
   106 { ERR_PACK(0, PK11_F_GET_PRIV_DSA_KEY, 0),	"PK11_GET_PRIV_DSA_KEY"},
       
   107 { ERR_PACK(0, PK11_F_DH_INIT, 0),		"PK11_DH_INIT"},
       
   108 { ERR_PACK(0, PK11_F_DH_FINISH, 0),		"PK11_DH_FINISH"},
       
   109 { ERR_PACK(0, PK11_F_MOD_EXP_DH, 0),		"PK11_MOD_EXP_DH"},
       
   110 { ERR_PACK(0, PK11_F_GET_DH_KEY, 0),		"PK11_GET_DH_KEY"},
       
   111 { ERR_PACK(0, PK11_F_FREE_ALL_SESSIONS, 0),	"PK11_FREE_ALL_SESSIONS"},
       
   112 { ERR_PACK(0, PK11_F_SETUP_SESSION, 0),		"PK11_SETUP_SESSION"},
       
   113 { ERR_PACK(0, PK11_F_DESTROY_OBJECT, 0),	"PK11_DESTROY_OBJECT"},
       
   114 { ERR_PACK(0, PK11_F_CIPHER_INIT, 0),		"PK11_CIPHER_INIT"},
       
   115 { ERR_PACK(0, PK11_F_CIPHER_DO_CIPHER, 0),	"PK11_CIPHER_DO_CIPHER"},
       
   116 { ERR_PACK(0, PK11_F_GET_CIPHER_KEY, 0),	"PK11_GET_CIPHER_KEY"},
       
   117 { ERR_PACK(0, PK11_F_DIGEST_INIT, 0),		"PK11_DIGEST_INIT"},
       
   118 { ERR_PACK(0, PK11_F_DIGEST_UPDATE, 0),		"PK11_DIGEST_UPDATE"},
       
   119 { ERR_PACK(0, PK11_F_DIGEST_FINAL, 0),		"PK11_DIGEST_FINAL"},
       
   120 { ERR_PACK(0, PK11_F_CHOOSE_SLOT, 0),		"PK11_CHOOSE_SLOT"},
       
   121 { ERR_PACK(0, PK11_F_CIPHER_FINAL, 0),		"PK11_CIPHER_FINAL"},
       
   122 { ERR_PACK(0, PK11_F_LIBRARY_INIT, 0),		"PK11_LIBRARY_INIT"},
       
   123 { ERR_PACK(0, PK11_F_LOAD, 0),			"ENGINE_LOAD_PK11"},
       
   124 { ERR_PACK(0, PK11_F_DH_GEN_KEY, 0),		"PK11_DH_GEN_KEY"},
       
   125 { ERR_PACK(0, PK11_F_DH_COMP_KEY, 0),		"PK11_DH_COMP_KEY"},
       
   126 { ERR_PACK(0, PK11_F_DIGEST_COPY, 0),		"PK11_DIGEST_COPY"},
       
   127 { ERR_PACK(0, PK11_F_CIPHER_CLEANUP, 0),	"PK11_CIPHER_CLEANUP"},
       
   128 { ERR_PACK(0, PK11_F_ACTIVE_ADD, 0),		"PK11_ACTIVE_ADD"},
       
   129 { ERR_PACK(0, PK11_F_ACTIVE_DELETE, 0),		"PK11_ACTIVE_DELETE"},
       
   130 { ERR_PACK(0, PK11_F_CHECK_HW_MECHANISMS, 0),	"PK11_CHECK_HW_MECHANISMS"},
       
   131 { ERR_PACK(0, PK11_F_INIT_SYMMETRIC, 0),	"PK11_INIT_SYMMETRIC"},
       
   132 { ERR_PACK(0, PK11_F_ADD_AES_CTR_NIDS, 0),	"PK11_ADD_AES_CTR_NIDS"},
       
   133 { ERR_PACK(0, PK11_F_INIT_ALL_LOCKS, 0),	"PK11_INIT_ALL_LOCKS"},
       
   134 { ERR_PACK(0, PK11_F_RETURN_SESSION, 0),	"PK11_RETURN_SESSION"},
       
   135 { ERR_PACK(0, PK11_F_GET_PIN, 0),		"PK11_GET_PIN"},
       
   136 { ERR_PACK(0, PK11_F_FIND_ONE_OBJECT, 0),	"PK11_FIND_ONE_OBJECT"},
       
   137 { ERR_PACK(0, PK11_F_CHECK_TOKEN_ATTRS, 0),	"PK11_CHECK_TOKEN_ATTRS"},
       
   138 { ERR_PACK(0, PK11_F_CACHE_PIN, 0),		"PK11_CACHE_PIN"},
       
   139 { ERR_PACK(0, PK11_F_MLOCK_PIN_IN_MEMORY, 0),	"PK11_MLOCK_PIN_IN_MEMORY"},
       
   140 { ERR_PACK(0, PK11_F_TOKEN_LOGIN, 0),		"PK11_TOKEN_LOGIN"},
       
   141 { ERR_PACK(0, PK11_F_TOKEN_RELOGIN, 0),		"PK11_TOKEN_RELOGIN"},
       
   142 { ERR_PACK(0, PK11_F_RUN_ASKPASS, 0),		"PK11_F_RUN_ASKPASS"},
       
   143 { 0, NULL}
       
   144 };
       
   145 
       
   146 static ERR_STRING_DATA pk11_str_reasons[]=
       
   147 {
       
   148 { PK11_R_ALREADY_LOADED,		"PKCS#11 DSO already loaded"},
       
   149 { PK11_R_DSO_FAILURE,			"unable to load PKCS#11 DSO"},
       
   150 { PK11_R_NOT_LOADED,			"PKCS#11 DSO not loaded"},
       
   151 { PK11_R_PASSED_NULL_PARAMETER,		"null parameter passed"},
       
   152 { PK11_R_COMMAND_NOT_IMPLEMENTED,	"command not implemented"},
       
   153 { PK11_R_INITIALIZE,			"C_Initialize failed"},
       
   154 { PK11_R_FINALIZE,			"C_Finalize failed"},
       
   155 { PK11_R_GETINFO,			"C_GetInfo faile"},
       
   156 { PK11_R_GETSLOTLIST,			"C_GetSlotList failed"},
       
   157 { PK11_R_NO_MODULUS_OR_NO_EXPONENT,	"no modulus or no exponent"},
       
   158 { PK11_R_ATTRIBUT_SENSITIVE_OR_INVALID,	"attr sensitive or invalid"},
       
   159 { PK11_R_GETATTRIBUTVALUE,		"C_GetAttributeValue failed"},
       
   160 { PK11_R_NO_MODULUS,			"no modulus"},
       
   161 { PK11_R_NO_EXPONENT,			"no exponent"},
       
   162 { PK11_R_FINDOBJECTSINIT,		"C_FindObjectsInit failed"},
       
   163 { PK11_R_FINDOBJECTS,			"C_FindObjects failed"},
       
   164 { PK11_R_FINDOBJECTSFINAL,		"C_FindObjectsFinal failed"},
       
   165 { PK11_R_CREATEOBJECT,			"C_CreateObject failed"},
       
   166 { PK11_R_DESTROYOBJECT,			"C_DestroyObject failed"},
       
   167 { PK11_R_OPENSESSION,			"C_OpenSession failed"},
       
   168 { PK11_R_CLOSESESSION,			"C_CloseSession failed"},
       
   169 { PK11_R_ENCRYPTINIT,			"C_EncryptInit failed"},
       
   170 { PK11_R_ENCRYPT,			"C_Encrypt failed"},
       
   171 { PK11_R_SIGNINIT,			"C_SignInit failed"},
       
   172 { PK11_R_SIGN,				"C_Sign failed"},
       
   173 { PK11_R_DECRYPTINIT,			"C_DecryptInit failed"},
       
   174 { PK11_R_DECRYPT,			"C_Decrypt failed"},
       
   175 { PK11_R_VERIFYINIT,			"C_VerifyRecover failed"},
       
   176 { PK11_R_VERIFY,			"C_Verify failed"},
       
   177 { PK11_R_VERIFYRECOVERINIT,		"C_VerifyRecoverInit failed"},
       
   178 { PK11_R_VERIFYRECOVER,			"C_VerifyRecover failed"},
       
   179 { PK11_R_GEN_KEY,			"C_GenerateKeyPair failed"},
       
   180 { PK11_R_SEEDRANDOM,			"C_SeedRandom failed"},
       
   181 { PK11_R_GENERATERANDOM,		"C_GenerateRandom failed"},
       
   182 { PK11_R_INVALID_MESSAGE_LENGTH,	"invalid message length"},
       
   183 { PK11_R_UNKNOWN_ALGORITHM_TYPE,	"unknown algorithm type"},
       
   184 { PK11_R_UNKNOWN_ASN1_OBJECT_ID,	"unknown asn1 onject id"},
       
   185 { PK11_R_UNKNOWN_PADDING_TYPE,		"unknown padding type"},
       
   186 { PK11_R_PADDING_CHECK_FAILED,		"padding check failed"},
       
   187 { PK11_R_DIGEST_TOO_BIG,		"digest too big"},
       
   188 { PK11_R_MALLOC_FAILURE,		"malloc failure"},
       
   189 { PK11_R_CTRL_COMMAND_NOT_IMPLEMENTED,	"ctl command not implemented"},
       
   190 { PK11_R_DATA_GREATER_THAN_MOD_LEN,	"data is bigger than mod"},
       
   191 { PK11_R_DATA_TOO_LARGE_FOR_MODULUS,	"data is too larger for mod"},
       
   192 { PK11_R_MISSING_KEY_COMPONENT,		"a dsa component is missing"},
       
   193 { PK11_R_INVALID_SIGNATURE_LENGTH,	"invalid signature length"},
       
   194 { PK11_R_INVALID_DSA_SIGNATURE_R,	"missing r in dsa verify"},
       
   195 { PK11_R_INVALID_DSA_SIGNATURE_S,	"missing s in dsa verify"},
       
   196 { PK11_R_INCONSISTENT_KEY,		"inconsistent key type"},
       
   197 { PK11_R_ENCRYPTUPDATE,			"C_EncryptUpdate failed"},
       
   198 { PK11_R_DECRYPTUPDATE,			"C_DecryptUpdate failed"},
       
   199 { PK11_R_DIGESTINIT,			"C_DigestInit failed"},
       
   200 { PK11_R_DIGESTUPDATE,			"C_DigestUpdate failed"},
       
   201 { PK11_R_DIGESTFINAL,			"C_DigestFinal failed"},
       
   202 { PK11_R_ENCRYPTFINAL,			"C_EncryptFinal failed"},
       
   203 { PK11_R_DECRYPTFINAL,			"C_DecryptFinal failed"},
       
   204 { PK11_R_NO_PRNG_SUPPORT,		"Slot does not support PRNG"},
       
   205 { PK11_R_GETTOKENINFO,			"C_GetTokenInfo failed"},
       
   206 { PK11_R_DERIVEKEY,			"C_DeriveKey failed"},
       
   207 { PK11_R_GET_OPERATION_STATE,		"C_GetOperationState failed"},
       
   208 { PK11_R_SET_OPERATION_STATE,		"C_SetOperationState failed"},
       
   209 { PK11_R_INVALID_HANDLE,		"invalid PKCS#11 object handle"},
       
   210 { PK11_R_KEY_OR_IV_LEN_PROBLEM,		"IV or key length incorrect"},
       
   211 { PK11_R_INVALID_OPERATION_TYPE,	"invalid operation type"},
       
   212 { PK11_R_ADD_NID_FAILED,		"failed to add NID" },
       
   213 { PK11_R_ATFORK_FAILED,			"atfork failed" },
       
   214 { PK11_R_TOKEN_LOGIN_FAILED,		"C_Login failed on token" },
       
   215 { PK11_R_MORE_THAN_ONE_OBJECT_FOUND,	"more than one object found" },
       
   216 { PK11_R_INVALID_PKCS11_URI,		"pkcs11 URI provided is invalid" },
       
   217 { PK11_R_COULD_NOT_READ_PIN,		"could not read PIN from terminal" },
       
   218 { PK11_R_PIN_NOT_READ_FROM_COMMAND,	"PIN not read from external command" },
       
   219 { PK11_R_COULD_NOT_OPEN_COMMAND,	"could not popen dialog command" },
       
   220 { PK11_R_PIPE_FAILED,			"pipe failed" },
       
   221 { PK11_R_BAD_PASSPHRASE_SPEC,		"bad passphrasedialog specification" },
       
   222 { PK11_R_TOKEN_NOT_INITIALIZED,		"token not initialized" },
       
   223 { PK11_R_TOKEN_PIN_NOT_SET,		"token PIN required but not set" },
       
   224 { PK11_R_TOKEN_PIN_NOT_PROVIDED,	"token PIN required but not provided" },
       
   225 { PK11_R_MISSING_OBJECT_LABEL,		"missing mandatory 'object' keyword" },
       
   226 { PK11_R_TOKEN_ATTRS_DO_NOT_MATCH,	"token attrs provided do not match" },
       
   227 { PK11_R_PRIV_KEY_NOT_FOUND,		"private key not found in keystore" },
       
   228 { PK11_R_NO_OBJECT_FOUND,		"specified object not found" },
       
   229 { PK11_R_PIN_CACHING_POLICY_INVALID,	"PIN set but caching policy invalid" },
       
   230 { PK11_R_SYSCONF_FAILED,		"sysconf failed" },
       
   231 { PK11_R_MMAP_FAILED,			"mmap failed" },
       
   232 { PK11_R_PRIV_PROC_LOCK_MEMORY_MISSING,	"PROC_LOCK_MEMORY privilege missing" },
       
   233 { PK11_R_MLOCK_FAILED,			"mlock failed" },
       
   234 { PK11_R_FORK_FAILED,			"fork failed" },
       
   235 { 0,	NULL}
       
   236 };
       
   237 #endif	/* OPENSSL_NO_ERR */
       
   238 
       
   239 static int pk11_lib_error_code = 0;
       
   240 static int pk11_error_init = 1;
       
   241 
       
   242 #ifdef PK11_ENGINE_LIB_NAME
       
   243 static ERR_STRING_DATA pk11_engine_lib_name[] =
       
   244 {
       
   245 {0, PK11_ENGINE_LIB_NAME},
       
   246 {0, NULL}
       
   247 };
       
   248 #endif
       
   249 
       
   250 static void
       
   251 ERR_load_pk11_strings(void)
       
   252 	{
       
   253 	if (pk11_lib_error_code == 0)
       
   254 		pk11_lib_error_code = ERR_get_next_error_library();
       
   255 
       
   256 	if (pk11_error_init)
       
   257 		{
       
   258 		pk11_error_init = 0;
       
   259 #ifndef OPENSSL_NO_ERR
       
   260 		ERR_load_strings(pk11_lib_error_code, pk11_str_functs);
       
   261 		ERR_load_strings(pk11_lib_error_code, pk11_str_reasons);
       
   262 #endif
       
   263 
       
   264 #ifdef PK11_ENGINE_LIB_NAME
       
   265 		pk11_engine_lib_name->error =
       
   266 		    ERR_PACK(pk11_lib_error_code, 0, 0);
       
   267 		ERR_load_strings(0, pk11_engine_lib_name);
       
   268 #endif
       
   269 		}
       
   270 }
       
   271 
       
   272 static void
       
   273 ERR_unload_pk11_strings(void)
       
   274 	{
       
   275 	if (pk11_error_init == 0)
       
   276 		{
       
   277 #ifndef OPENSSL_NO_ERR
       
   278 		ERR_unload_strings(pk11_lib_error_code, pk11_str_functs);
       
   279 		ERR_unload_strings(pk11_lib_error_code, pk11_str_reasons);
       
   280 #endif
       
   281 
       
   282 #ifdef PK11_ENGINE_LIB_NAME
       
   283 		ERR_unload_strings(0, pk11_engine_lib_name);
       
   284 #endif
       
   285 
       
   286 		pk11_error_init = 1;
       
   287 		}
       
   288 }
       
   289 
       
   290 void
       
   291 ERR_pk11_error(int function, int reason, char *file, int line)
       
   292 {
       
   293 	if (pk11_lib_error_code == 0)
       
   294 		pk11_lib_error_code = ERR_get_next_error_library();
       
   295 	ERR_PUT_error(pk11_lib_error_code, function, reason, file, line);
       
   296 }
       
   297 
       
   298 void
       
   299 PK11err_add_data(int function, int reason, CK_RV rv)
       
   300 {
       
   301 	char tmp_buf[20];
       
   302 
       
   303 	PK11err(function, reason);
       
   304 	(void) snprintf(tmp_buf, sizeof (tmp_buf), "%lx", rv);
       
   305 	ERR_add_error_data(2, "PK11 CK_RV=0X", tmp_buf);
       
   306 }