engine.c revision cd7d5faf5bbb52336a6f85578a90b31a648ac3fa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "includes.h"
#include "log.h"
#include "engine.h"
#define PKCS11_ENGINE "pkcs11"
/*
* Loads the PKCS#11 engine if the UseOpenSSLEngine is set to yes which is the
* default value.
*/
ENGINE *
{
if (use_engine == 0)
return (NULL);
/* get structural reference */
}
/* get functional reference */
if (ENGINE_init(e) == 0) {
}
debug("%s engine initialized, now setting it as default for "
"RSA, DSA, and symmetric ciphers", PKCS11_ENGINE);
/*
* Offloading RSA, DSA and symmetric ciphers to the engine is all we
* want. We don't offload Diffie-Helmann since we use longer DH keys
* operations since that would be beneficial if only big packets were
* processed (~8K). However, that's not the case. For example,
* SSH_MSG_CHANNEL_WINDOW_ADJUST messages are always small. Given the
* fact that digest operations are fast in software and the inherent
* overhead of offloading anything to HW is quite big, not offloading
* digests to HW actually makes SSH data transfer faster.
*/
if (!ENGINE_set_default_RSA(e)) {
}
if (!ENGINE_set_default_DSA(e)) {
}
if (!ENGINE_set_default_ciphers(e)) {
}
return (e);
}
/*
* Finishes the PKCS#11 engine after all remaining structural and functional
* references to the ENGINE structure are freed.
*/
void
pkcs11_engine_finish(void *engine)
{
debug("in pkcs11_engine_finish(), engine pointer is %p", e);
/* UseOpenSSLEngine was 'no' */
return;
debug("unregistering RSA");
debug("unregistering DSA");
debug("unregistering ciphers");
debug("calling ENGINE_finish()");
debug("calling ENGINE_remove()");
debug("calling ENGINE_free()");
}