1193645Ssimon/* o_init.c */ 2296465Sdelphij/* 3296465Sdelphij * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 4193645Ssimon * project. 5193645Ssimon */ 6193645Ssimon/* ==================================================================== 7193645Ssimon * Copyright (c) 2007 The OpenSSL Project. All rights reserved. 8193645Ssimon * 9193645Ssimon * Redistribution and use in source and binary forms, with or without 10193645Ssimon * modification, are permitted provided that the following conditions 11193645Ssimon * are met: 12193645Ssimon * 13193645Ssimon * 1. Redistributions of source code must retain the above copyright 14296465Sdelphij * notice, this list of conditions and the following disclaimer. 15193645Ssimon * 16193645Ssimon * 2. Redistributions in binary form must reproduce the above copyright 17193645Ssimon * notice, this list of conditions and the following disclaimer in 18193645Ssimon * the documentation and/or other materials provided with the 19193645Ssimon * distribution. 20193645Ssimon * 21193645Ssimon * 3. All advertising materials mentioning features or use of this 22193645Ssimon * software must display the following acknowledgment: 23193645Ssimon * "This product includes software developed by the OpenSSL Project 24193645Ssimon * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 25193645Ssimon * 26193645Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27193645Ssimon * endorse or promote products derived from this software without 28193645Ssimon * prior written permission. For written permission, please contact 29193645Ssimon * openssl-core@openssl.org. 30193645Ssimon * 31193645Ssimon * 5. Products derived from this software may not be called "OpenSSL" 32193645Ssimon * nor may "OpenSSL" appear in their names without prior written 33193645Ssimon * permission of the OpenSSL Project. 34193645Ssimon * 35193645Ssimon * 6. Redistributions of any form whatsoever must retain the following 36193645Ssimon * acknowledgment: 37193645Ssimon * "This product includes software developed by the OpenSSL Project 38193645Ssimon * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 39193645Ssimon * 40193645Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41193645Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42193645Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43193645Ssimon * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44193645Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45193645Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46193645Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47193645Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48193645Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49193645Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50193645Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51193645Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE. 52193645Ssimon * ==================================================================== 53193645Ssimon * 54193645Ssimon * This product includes cryptographic software written by Eric Young 55193645Ssimon * (eay@cryptsoft.com). This product includes software written by Tim 56193645Ssimon * Hudson (tjh@cryptsoft.com). 57193645Ssimon * 58193645Ssimon */ 59193645Ssimon 60193645Ssimon#include <e_os.h> 61193645Ssimon#include <openssl/err.h> 62215697Ssimon 63205128Ssimon/* Internal only functions: only ever used here */ 64215697Ssimon#ifdef OPENSSL_FIPS 65296465Sdelphijextern void int_ERR_lib_init(void); 66215697Ssimon# ifndef OPENSSL_NO_ENGINE 67296465Sdelphijextern void int_EVP_MD_init_engine_callbacks(void); 68296465Sdelphijextern void int_EVP_CIPHER_init_engine_callbacks(void); 69296465Sdelphijextern void int_RAND_init_engine_callbacks(void); 70215697Ssimon# endif 71215697Ssimon#endif 72193645Ssimon 73296465Sdelphij/* 74296465Sdelphij * Perform any essential OpenSSL initialization operations. Currently only 75296465Sdelphij * sets FIPS callbacks 76193645Ssimon */ 77193645Ssimon 78193645Ssimonvoid OPENSSL_init(void) 79296465Sdelphij{ 80193645Ssimon#ifdef OPENSSL_FIPS 81296465Sdelphij static int done = 0; 82296465Sdelphij if (!done) { 83296465Sdelphij int_ERR_lib_init(); 84296465Sdelphij# ifdef CRYPTO_MDEBUG 85296465Sdelphij CRYPTO_malloc_debug_init(); 86296465Sdelphij# endif 87296465Sdelphij# ifndef OPENSSL_NO_ENGINE 88296465Sdelphij int_EVP_MD_init_engine_callbacks(); 89296465Sdelphij int_EVP_CIPHER_init_engine_callbacks(); 90296465Sdelphij int_RAND_init_engine_callbacks(); 91296465Sdelphij# endif 92296465Sdelphij done = 1; 93296465Sdelphij } 94193645Ssimon#endif 95296465Sdelphij} 96296465Sdelphij 97248272Sdelphij#ifdef OPENSSL_FIPS 98193645Ssimon 99248272Sdelphijint CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) 100296465Sdelphij{ 101296465Sdelphij size_t i; 102296465Sdelphij const unsigned char *a = in_a; 103296465Sdelphij const unsigned char *b = in_b; 104296465Sdelphij unsigned char x = 0; 105248272Sdelphij 106296465Sdelphij for (i = 0; i < len; i++) 107296465Sdelphij x |= a[i] ^ b[i]; 108248272Sdelphij 109296465Sdelphij return x; 110296465Sdelphij} 111248272Sdelphij#endif 112