os/ossrv/ssl/libcrypto/src/crypto/engine/tb_ecdsa.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/engine/tb_ecdsa.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,128 @@
     1.4 +/* ====================================================================
     1.5 + * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.
     1.6 + *
     1.7 + * Redistribution and use in source and binary forms, with or without
     1.8 + * modification, are permitted provided that the following conditions
     1.9 + * are met:
    1.10 + *
    1.11 + * 1. Redistributions of source code must retain the above copyright
    1.12 + *    notice, this list of conditions and the following disclaimer. 
    1.13 + *
    1.14 + * 2. Redistributions in binary form must reproduce the above copyright
    1.15 + *    notice, this list of conditions and the following disclaimer in
    1.16 + *    the documentation and/or other materials provided with the
    1.17 + *    distribution.
    1.18 + *
    1.19 + * 3. All advertising materials mentioning features or use of this
    1.20 + *    software must display the following acknowledgment:
    1.21 + *    "This product includes software developed by the OpenSSL Project
    1.22 + *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
    1.23 + *
    1.24 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
    1.25 + *    endorse or promote products derived from this software without
    1.26 + *    prior written permission. For written permission, please contact
    1.27 + *    licensing@OpenSSL.org.
    1.28 + *
    1.29 + * 5. Products derived from this software may not be called "OpenSSL"
    1.30 + *    nor may "OpenSSL" appear in their names without prior written
    1.31 + *    permission of the OpenSSL Project.
    1.32 + *
    1.33 + * 6. Redistributions of any form whatsoever must retain the following
    1.34 + *    acknowledgment:
    1.35 + *    "This product includes software developed by the OpenSSL Project
    1.36 + *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
    1.37 + *
    1.38 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
    1.39 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.40 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    1.41 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
    1.42 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.43 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    1.44 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    1.45 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.46 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    1.47 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.48 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    1.49 + * OF THE POSSIBILITY OF SUCH DAMAGE.
    1.50 + * ====================================================================
    1.51 + *
    1.52 + * This product includes cryptographic software written by Eric Young
    1.53 + * (eay@cryptsoft.com).  This product includes software written by Tim
    1.54 + * Hudson (tjh@cryptsoft.com).
    1.55 + *
    1.56 + */
    1.57 + /*
    1.58 + © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
    1.59 + */
    1.60 +
    1.61 +#include "eng_int.h"
    1.62 +#if (defined(SYMBIAN) && (defined(__WINSCW__) || defined(__WINS__)))
    1.63 +#include "libcrypto_wsd_macros.h"
    1.64 +#include "libcrypto_wsd.h"
    1.65 +#endif
    1.66 +/* If this symbol is defined then ENGINE_get_default_ECDSA(), the function that is
    1.67 + * used by ECDSA to hook in implementation code and cache defaults (etc), will
    1.68 + * display brief debugging summaries to stderr with the 'nid'. */
    1.69 +/* #define ENGINE_ECDSA_DEBUG */
    1.70 +#ifndef EMULATOR
    1.71 +static ENGINE_TABLE *ecdsa_table = NULL;
    1.72 +#else
    1.73 +GET_STATIC_VAR_FROM_TLS(ecdsa_table,tb_ecdsa,ENGINE_TABLE *)
    1.74 +#define ecdsa_table (*GET_WSD_VAR_NAME(ecdsa_table,tb_ecdsa, s)())
    1.75 +#endif
    1.76 +static const int dummy_nid = 1;
    1.77 +
    1.78 +void ENGINE_unregister_ECDSA(ENGINE *e)
    1.79 +	{
    1.80 +	engine_table_unregister(&ecdsa_table, e);
    1.81 +	}
    1.82 +
    1.83 +static void engine_unregister_all_ECDSA(void)
    1.84 +	{
    1.85 +	engine_table_cleanup(&ecdsa_table);
    1.86 +	}
    1.87 +
    1.88 +int ENGINE_register_ECDSA(ENGINE *e)
    1.89 +	{
    1.90 +	if(e->ecdsa_meth)
    1.91 +		return engine_table_register(&ecdsa_table,
    1.92 +				engine_unregister_all_ECDSA, e, &dummy_nid, 1, 0);
    1.93 +	return 1;
    1.94 +	}
    1.95 +
    1.96 +void ENGINE_register_all_ECDSA()
    1.97 +	{
    1.98 +	ENGINE *e;
    1.99 +
   1.100 +	for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
   1.101 +		ENGINE_register_ECDSA(e);
   1.102 +	}
   1.103 +
   1.104 +int ENGINE_set_default_ECDSA(ENGINE *e)
   1.105 +	{
   1.106 +	if(e->ecdsa_meth)
   1.107 +		return engine_table_register(&ecdsa_table,
   1.108 +				engine_unregister_all_ECDSA, e, &dummy_nid, 1, 1);
   1.109 +	return 1;
   1.110 +	}
   1.111 +
   1.112 +/* Exposed API function to get a functional reference from the implementation
   1.113 + * table (ie. try to get a functional reference from the tabled structural
   1.114 + * references). */
   1.115 +ENGINE *ENGINE_get_default_ECDSA(void)
   1.116 +	{
   1.117 +	return engine_table_select(&ecdsa_table, dummy_nid);
   1.118 +	}
   1.119 +
   1.120 +/* Obtains an ECDSA implementation from an ENGINE functional reference */
   1.121 +const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e)
   1.122 +	{
   1.123 +	return e->ecdsa_meth;
   1.124 +	}
   1.125 +
   1.126 +/* Sets an ECDSA implementation in an ENGINE structure */
   1.127 +int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth)
   1.128 +	{
   1.129 +	e->ecdsa_meth = ecdsa_meth;
   1.130 +	return 1;
   1.131 +	}