1193645Ssimon/* o_init.c */ 2280297Sjkim/* 3280297Sjkim * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 4193645Ssimon * project. 5193645Ssimon */ 6193645Ssimon/* ==================================================================== 7238405Sjkim * Copyright (c) 2011 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 14280297Sjkim * 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 */ 55193645Ssimon 56193645Ssimon#include <e_os.h> 57193645Ssimon#include <openssl/err.h> 58215697Ssimon#ifdef OPENSSL_FIPS 59280297Sjkim# include <openssl/fips.h> 60280297Sjkim# include <openssl/rand.h> 61331638Sjkim 62331638Sjkim# ifndef OPENSSL_NO_DEPRECATED 63331638Sjkim/* the prototype is missing in <openssl/fips.h> */ 64331638Sjkimvoid FIPS_crypto_set_id_callback(unsigned long (*func)(void)); 65331638Sjkim# endif 66215697Ssimon#endif 67193645Ssimon 68280297Sjkim/* 69280297Sjkim * Perform any essential OpenSSL initialization operations. Currently only 70280297Sjkim * sets FIPS callbacks 71193645Ssimon */ 72193645Ssimon 73193645Ssimonvoid OPENSSL_init(void) 74280297Sjkim{ 75280297Sjkim static int done = 0; 76280297Sjkim if (done) 77280297Sjkim return; 78280297Sjkim done = 1; 79193645Ssimon#ifdef OPENSSL_FIPS 80280297Sjkim FIPS_set_locking_callbacks(CRYPTO_lock, CRYPTO_add_lock); 81306195Sjkim# ifndef OPENSSL_NO_DEPRECATED 82306195Sjkim FIPS_crypto_set_id_callback(CRYPTO_thread_id); 83306195Sjkim# endif 84280297Sjkim FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata); 85280297Sjkim FIPS_set_malloc_callbacks(CRYPTO_malloc, CRYPTO_free); 86280297Sjkim RAND_init_fips(); 87193645Ssimon#endif 88238405Sjkim#if 0 89280297Sjkim fprintf(stderr, "Called OPENSSL_init\n"); 90193645Ssimon#endif 91280297Sjkim} 92