/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <assert.h>
#include <p12err.h>
/*
* OpenSSL provides a framework for pushing error codes onto a stack.
* When an error occurs, the consumer may use the framework to
* pop the errors off the stack and provide a trace of where the
* errors occurred.
*
* Our PKCS12 code plugs into this framework by calling
* ERR_load_SUNW_strings(). To push an error (which by the way, consists
* of a function code and an error code) onto the stack our PKCS12 code
* calls SUNWerr().
*
* Consumers of our PKCS12 code can then call the OpenSSL error routines
* when an error occurs and retrieve the stack of errors.
*/
#ifndef OPENSSL_NO_ERR
/* Function codes and their matching strings */
{ 0, NULL }
};
/* Error codes and their matching strings */
{ SUNW_R_INVALID_ARG, "invalid argument" },
{ SUNW_R_MEMORY_FAILURE, "memory failure" },
{ SUNW_R_MAC_VERIFY_FAILURE, "mac verify failure" },
{ SUNW_R_MAC_CREATE_FAILURE, "mac create failure" },
{ SUNW_R_BAD_FILETYPE, "bad file type" },
{ SUNW_R_BAD_PKEY, "bad or missing private key" },
{ SUNW_R_BAD_PKEYTYPE, "unsupported key type" },
{ SUNW_R_PKEY_READ_ERR, "unable to read private key" },
{ SUNW_R_NO_TRUST_ANCHOR, "no trust anchors found" },
{ SUNW_R_READ_TRUST_ERR, "unable to read trust anchor" },
{ SUNW_R_ADD_TRUST_ERR, "unable to add trust anchor" },
{ SUNW_R_PKCS12_PARSE_ERR, "PKCS12 parse error" },
{ SUNW_R_PKCS12_CREATE_ERR, "PKCS12 create error" },
{ SUNW_R_BAD_CERTTYPE, "unsupported certificate type" },
{ SUNW_R_PARSE_CERT_ERR, "error parsing PKCS12 certificate" },
{ SUNW_R_PARSE_BAG_ERR, "error parsing PKCS12 bag" },
{ SUNW_R_MAKE_BAG_ERR, "error making PKCS12 bag" },
{ SUNW_R_BAD_LKID, "bad localKeyID format" },
{ SUNW_R_SET_LKID_ERR, "error setting localKeyID" },
{ SUNW_R_BAD_FNAME, "bad friendlyName format" },
{ SUNW_R_SET_FNAME_ERR, "error setting friendlyName" },
{ SUNW_R_BAD_TRUST, "bad or missing trust anchor" },
{ SUNW_R_BAD_BAGTYPE, "unsupported bag type" },
{ SUNW_R_CERT_ERR, "certificate error" },
{ SUNW_R_PKEY_ERR, "private key error" },
{ SUNW_R_READ_ERR, "error reading file" },
{ SUNW_R_ADD_ATTR_ERR, "error adding attribute" },
{ SUNW_R_STR_CONVERT_ERR, "error converting string" },
{ SUNW_R_PKCS12_EMPTY_ERR, "empty PKCS12 structure" },
{ SUNW_R_PASSWORD_ERR, "bad password" },
{ 0, NULL }
};
/*
* The library name that our module will be known as. This name
* may be retrieved via OpenSSLs error APIs.
*/
{ 0, SUNW_LIB_NAME },
{ 0, NULL }
};
#endif
/*
* The value of this variable (initialized by a call to
* ERR_load_SUNW_strings()) is what identifies our errors
* to OpenSSL as being ours.
*/
static int SUNW_lib_error_code = 0;
/*
* Called by our PKCS12 code to read our function and error codes
* into memory so that the OpenSSL framework can retrieve them.
*/
void
ERR_load_SUNW_strings(void)
{
assert(SUNW_lib_error_code == 0);
#ifndef OPENSSL_NO_ERR
/*
* Have OpenSSL provide us with a unique ID.
*/
#endif
}
/*
* The SUNWerr macro resolves to this routine. So when we need
* to push an error, this routine does it for us. Notice that
* the SUNWerr macro provides a filename and line #.
*/
void
{
assert(SUNW_lib_error_code != 0);
#ifndef OPENSSL_NO_ERR
#endif
}