X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fopenssl%2Fcrypto.c;fp=src%2Fopenssl%2Fcrypto.c;h=7e6e9f62fcaece3e0a328480fa0fe47ef1f0ef74;hb=1b8f8918360b40a2749d40355266ed7dedbe41b5;hp=0000000000000000000000000000000000000000;hpb=f42e57f663a2663c830c4fb4c01927c2d3c89c09;p=tinc diff --git a/src/openssl/crypto.c b/src/openssl/crypto.c new file mode 100644 index 00000000..7e6e9f62 --- /dev/null +++ b/src/openssl/crypto.c @@ -0,0 +1,45 @@ +/* + crypto.c -- Cryptographic miscellaneous functions and initialisation + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id$ +*/ + +#include "system.h" + +#include +#include +#include + +#include "crypto.h" + +void crypto_init() { + RAND_load_file("/dev/urandom", 1024); + + ENGINE_load_builtin_engines(); + ENGINE_register_all_complete(); + + OpenSSL_add_all_algorithms(); +} + +void crypto_exit() { + EVP_cleanup(); +} + +void randomize(void *out, size_t outlen) { + RAND_pseudo_bytes(out, outlen); +}