eng_list.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* crypto/engine/eng_list.c */
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
* project 2000.
*/
/* ====================================================================
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#include "cryptlib.h"
#include "eng_int.h"
/* The linked-list of pointers to engine types. engine_list_head
* incorporates an implicit structural reference but engine_list_tail
* does not - the latter is a computational niceity and only points
* to something that is already pointed to by its predecessor in the
* list (or engine_list_head itself). In the same way, the use of the
* "prev" pointer in each ENGINE is to save excessive list iteration,
* it doesn't correspond to an extra structural reference. Hence,
* engine_list_head, and each non-null "next" pointer account for
* the list itself assuming exactly 1 structural reference on each
* list member. */
/* This cleanup function is only needed internally. If it should be called, we
* register it with the "ENGINE_cleanup()" stack to be called during cleanup. */
static void engine_list_cleanup(void)
{
{
}
return;
}
/* These static functions starting with a lower case "engine_" always
* take place when CRYPTO_LOCK_ENGINE has been locked up. */
static int engine_list_add(ENGINE *e)
{
int conflict = 0;
if(e == NULL)
{
return 0;
}
{
}
if(conflict)
{
return 0;
}
if(engine_list_head == NULL)
{
/* We are adding to an empty list. */
if(engine_list_tail)
{
return 0;
}
engine_list_head = e;
/* The first time the list allocates, we should register the
* cleanup. */
}
else
{
/* We are adding to the tail of an existing list. */
if((engine_list_tail == NULL) ||
{
return 0;
}
engine_list_tail->next = e;
e->prev = engine_list_tail;
}
/* Having the engine in the list assumes a structural
* reference. */
e->struct_ref++;
engine_ref_debug(e, 0, 1)
/* However it came to be, e is the last item in the list. */
engine_list_tail = e;
return 1;
}
static int engine_list_remove(ENGINE *e)
{
if(e == NULL)
{
return 0;
}
/* We need to check that e is in our linked list! */
{
return 0;
}
/* un-link e from the chain. */
if(e->next)
if(e->prev)
if(engine_list_head == e)
engine_list_head = e->next;
if(engine_list_tail == e)
engine_list_tail = e->prev;
engine_free_util(e, 0);
return 1;
}
ENGINE *ENGINE_get_first(void)
{
if(ret)
{
ret->struct_ref++;
}
return ret;
}
ENGINE *ENGINE_get_last(void)
{
if(ret)
{
ret->struct_ref++;
}
return ret;
}
{
if(e == NULL)
{
return 0;
}
if(ret)
{
/* Return a valid structural refernce to the next ENGINE */
ret->struct_ref++;
}
/* Release the structural reference to the previous ENGINE */
ENGINE_free(e);
return ret;
}
{
if(e == NULL)
{
return 0;
}
if(ret)
{
/* Return a valid structural reference to the next ENGINE */
ret->struct_ref++;
}
/* Release the structural reference to the previous ENGINE */
ENGINE_free(e);
return ret;
}
/* Add another "ENGINE" type into the list. */
int ENGINE_add(ENGINE *e)
{
int to_return = 1;
if(e == NULL)
{
return 0;
}
{
}
if(!engine_list_add(e))
{
to_return = 0;
}
return to_return;
}
/* Remove an existing "ENGINE" type from the array. */
int ENGINE_remove(ENGINE *e)
{
int to_return = 1;
if(e == NULL)
{
return 0;
}
if(!engine_list_remove(e))
{
to_return = 0;
}
return to_return;
}
{
#ifndef OPENSSL_NO_RSA
#endif
#ifndef OPENSSL_NO_DSA
#endif
#ifndef OPENSSL_NO_DH
#endif
}
{
{
return NULL;
}
if(iterator)
{
/* We need to return a structural reference. If this is an
* ENGINE type that returns copies, make a duplicate - otherwise
* increment the existing ENGINE's reference count. */
{
if(!cp)
else
{
}
}
else
{
iterator->struct_ref++;
}
}
{
}
return iterator;
}
int ENGINE_up_ref(ENGINE *e)
{
if (e == NULL)
{
return 0;
}
return 1;
}